一、代码
string inputFile = "E:Test15.mp4";
string outputFile = "E:Test110.mp4";
int startTime = 5; // 开始时间(秒)
int endtime = 10; // 结束时间(秒)
Process p = new Process();
p.StartInfo.FileName = ".ffmpegffmpeg.exe";//ffmpeg.exe路径
p.StartInfo.UseShellExecute = false;
p.StartInfo.Arguments = $"-i {inputFile} -ss {startTime} -to {endtime} -c:v copy {outputFile} ";
p.StartInfo.UseShellExecute = false;//不使用系统外壳程序启动进程
p.StartInfo.CreateNoWindow = true; //不显示dos程序窗口
p.StartInfo.RedirectStan服务器托管网dardInput = true;
p.StartInfo.服务器托管网RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;//把外部程序错误输出写到StandardError流中
p.StartInfo.UseShellExecute = false;
p.Start();
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.BeginErrorReadLine();//开始异步读取
p.WaitForExit();//
p.Close(); // 关闭进程
p.Dispose(); // 释放资源
二、代码使用解释
2.1 不使用原因-c:v copy
-c:v copy不进行重新编码,直接拷贝原视频中的视频片段,保存为截取视频。视频长度存在较大误差
经测试,截取10秒长度视频,视频显示长度为10秒,但实际为原视频5秒长度(丢帧)
截取视频长度过短,如小于5秒,会出现视频不显示画面问题
2.2使用原因-c:v libx264 -crf 18
指定使用H264标准 crf=18模式对原视频中的视频片段进行重新编码
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
相关推荐: STM32物联网(ESP-01S模块及STM32和ESP-01S通信方式介绍)
文章目录 前言 一、ESP-01S模块介绍 二、STM32和ESP-01S通信方式介绍 三、什么是AT指令 四、创建基础工程 总结 前言 本篇文章我们开始正式进入STM32物联网的专栏,在这个专栏中将会带大家学习使用STM32进行联网,联网模块的话主要就是使用…