当前位置:网站首页>Example of file operations - downloading and merging streaming video files
Example of file operations - downloading and merging streaming video files
2022-08-09 16:18:00 【Huang Duoyan】
目录
前言
cLanguage file operations that is red,If you only look at the code does not use the computer can't effectively.Recently I watch online learning video,I have a sudden inspiration,Think of can be downloaded by streaming media files and merge to be familiar with the file operations.
一、操作环境
win11Chinese family andvs2022
二、操作步骤
1.Study login page
2.按F12,Open the developer tools window
3.按下ctrl+R,Record page activity,然后点击Fetch/XHR
4.在下面的列表中,找到扩展名为m3u8的文件,右击->copy->copy link address
5.Paste into the notepad to observe
Can find its full path ishttps://r1-ndr.ykt.cbern.com.cn/edu_product/78/video/76b578c33eca409e850c294a4b25273e/3a3d0d00cf4057722d63668579b3f696.1280.720.false/3a3d0d00cf4057722d63668579b3f696.1280.720.m3u8Remember this file in the web folder,后面要用到.
6.在第4The list of steps for them3u8再右击,选open in new tab,Download the file,After use notepad to open the watch
You can see inside list a lotts文件,And file name length is50个字符.
7.在vsThe building up of empty projectcopy,将这个m3u8Copying files to the project filecopy.vcxproj同一文件夹下,比如 D:\实验室\copy\copy ,注意有两个copy
8.According to the graphic add source files
9.编写程序代码
a)下载.c
#include<stdio.h>
#include<string.h>
#include<stdlib.h>//此程序必须在win10/11上运行,否则需要安装curl!
#pragma warning(disable:4996)
extern void download()//下载所有的ts文件
{
FILE* fp = fopen("3a3d0d00cf4057722d63668579b3f696.1280.720.m3u8", "r");
char name[51];//待下载的文件名
char cmd[500];//To invoke the command line
while (fscanf(fp, "%s", name) != EOF)
if (strlen(name) == 50)//The same file name length is just
{
sprintf(cmd, "curl https://r1-ndr.ykt.cbern.com.cn/edu_product/78/video/76b578c33eca409e850c294a4b25273e/3a3d0d00cf4057722d63668579b3f696.1280.720.false/%s -o .\\%s", name, name);//组装调用curl下载文件的命令
system(cmd);//执行命令
}
fclose(fp);
}
b)合并.c
#include<stdio.h>
#include<string.h>
#pragma warning(disable:4996)
extern void merge()//合并ts文件
{
FILE* fpM = fopen("merge.ts", "wb+");
FILE* fp = fopen("3a3d0d00cf4057722d63668579b3f696.1280.720.m3u8", "r");
FILE* temp = NULL;
char name[51];
while (fscanf(fp, "%s", name) != EOF)
if (strlen(name) == 50)//The same file name length is just
{
temp = fopen(name, "rb");
char ch = fgetc(temp);
while (!feof(temp))
{
fputc(ch, fpM);
ch = fgetc(temp);//The last execution on the trip,Couldn't read the file,chThe value of is still the last time,之后feof(temp)成立
}
}
fclose(fpM);
fclose(fp);
fclose(temp);
}
10.执行程序
在 入口.c 中编写如下代码:
main()
{
download();
merge();
}
Then click on the toolbar“本地windows调试器”按钮执行.
耐心等待一会儿,然后到 D:\实验室\copy\copy 下提取merge.ts即可.
说明
1.Today does not study the use of purec语言下载文件,So the download file called when the system comescurl命令.
2.It is not hard to see the use of a text file to read and write and binary file reading and writing process.
边栏推荐
猜你喜欢
随机推荐
量化程序化交易如何去使用以及执行?
C语言运算符优先级
C#轻量级ORM使用 Dapper+Contrib
【C语言初阶】求最小公倍数的三种方法
6大论坛,30+技术干货议题,2022首届阿里巴巴开源开放周来了!
docker安装seata(指定配置文件、数据库、容器数据卷等)
光线的数值追踪
流程控制学习
WebGL:BabylonJS入门——初探:数据展示
Matlab修改Consolas字体
一些需要思考的物理问题
Talking about Shallow Cloning and Deep Cloning of ArraryList
简单记录下offsetof和container_of
WebGL:BabylonJS入门——初探:注入活力
Different compilers, different modes, impact on results
贝塞尔函数
大咖说·对话生态|当Confluent遇见云:实时流动的数据更有价值
回收站一直显示未清空的图标问题
Mathematica 数据分析(简明)
运算符学习