ffmpeg 合并文件
1.下载*.ts
2.创建文本,方便合并 *.ts
用c#代码来修改。
// 判断文件是否存在,不存在则创建,否则读取值显示到窗体
using System.Diagnostics;
if (!File.Exists("D:\\1.txt"))
{
// 创建写入文件
FileStream fs1 = new FileStream("D:\\1.txt", FileMode.Create, FileAccess.Write);
StreamWriter sw = new StreamWriter(fs1);
// 开始写入值
for (int i = 0; i <= 268; i++)
{
string msg1 = string.Format("file \'{0:D3}.ts'\", i);// {0:D3} D3默认3个10进制数,且用0填充,
sw.WriteLine(msg1);
}
sw.Close();
fs1.Close();
}
else
{}
ffmpeg文件合并 文件1.ts ~ 100.ts 流媒体文件
可以试试
或者 file 1.ts
或者 file 'D:\1.ts'
1.txt 格式
file `1.ts`
file `2.ts`
...
file `100.ts`
3. 文件改名
string folderPath = @"D:\CPan-DL";
string folderPath2 = @"D:\CPan-DL\1";//找到后,改名且 移动到新的文件夹中
string[] files = Directory.GetFiles(folderPath, "*.ts", SearchOption.AllDirectories); //"*.ts" 这个按照自己的文件来处理,可以*.*
int index = 0;
foreach (string file in files)
{
Console.WriteLine(file);
index = file.LastIndexOf("_");
//if (index == -1)
//{ continue; }
if (index >= 0)
{
string newStr = folderPath2 + "\\" + file.Substring(index+1); //Path.GetFileName(file);
//File.Move(oldExe, newExe);
File.Move(file, newStr);
}
}
4.合并文件
命 令 (-vcodec copy -acodec copy 等于 -c copy)
.\ffmpeg.exe -f concat -i .\1.txt -c copy .\output.mkv
注意如果直接生成mp4文件会卡顿,所以先生成相同类型的mkv,再转成MP4
.\ffmpeg.exe -i output.ts output.mp4

浙公网安备 33010602011771号