当前位置:网站首页>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.
边栏推荐
猜你喜欢
随机推荐
排序方法(希尔、快速、堆)
Analysis: Which method is used to build a stock quantitative trading database?
如何灵活运用量化交易接口的优势取长补短?
注释,标识符,数据类型
【C语言初阶】倒置字符串(输入 I like beijing. 输出beijing. like I)
欢迎使用CSDN-markdown编辑器
focal loss原理及简单代码实现
[Mysql]--Transaction, transaction isolation level, dirty read, non-repeatable read, phantom read analysis
光线的数值追踪
浅谈一下量化交易与程序化交易
How to achieve stable profit through the stock quantitative trading interface?
CV复习:过拟合、欠拟合
Redis6.2.1配置文件详解
怎么才可以知道量化程序化交易是否有效?
Suddenly want to analyze the mortgage interest rate and interest calculation
如何通过通达信量化交易接口达到长期的收益?
英语议论文读写02 Engineering
几何光学简介
It is deeply recognized that the compiler can cause differences in the compilation results
如何将List<Map>进行分组数值计算合并排序










![[MySql]实现多表查询-一对一,一对多](/img/7e/8f1af4422a394969b28a553ead2c42.png)