利用ffmpeg切割与合并视频(一)调用ffmpeg程序直接切割
2013-03-27 12:24
579 查看
ffmpeg -ss 00:00:00 -i D:\media\Linux.mpg -vcodec copy -acodec copy -t 00:01:00 C:\Users\a\Desktop\output.mpg
选项介绍:
-ss 截取视频的开始时间 单位为秒
-t 截取视频的时长,单位为秒
-vcodec 视频编码
-acodec 音频编码
-i 输入文件
前提:ffmpeg在系统的Path目录下,这样执行的时候才会找到这个命令
下面这个程序可以将Linux.mpg分割成长度为len分钟的若干个文件。
缺点:由于无法得知源文件的具体长度,无法计算需要分多少份,只好用system(“pause”)在每次分割完成后暂停,然后根据程序的执行情况,手动地用Ctrl+C结束程序的执行。
/* * @brief test001 use ffmpeg.exe directly * @author ray * @date 2013.3.27 */
#include <stdio.h>
#include <stdlib.h>
int main()
{
char szcmd[128];//command
char szoutfile[128];
int hh = 0;
int mm = 0;
int ss = 0;
const int len = 1;//增加步长:1分钟
int res = 0;
int ms, me;
do
{
hh = mm / 60;
ms = mm-hh*60;
me= ms + len;
sprintf(szoutfile, "%d-%d-%d.mpg", hh, ms, me);
sprintf(szcmd, "ffmpeg -i D:\\media\\5min.mpg -ss %d:%d:%d -t 00:01:00 -vcodec copy -acodec copy %s", hh, ms, ss, szoutfile);
puts(szcmd);//same as printf("%s\n",s)
res = system(szcmd); //发出一个DOS命令
mm += 1;
system("pause");
} while (res == 0);
return 0;
}
选项介绍:
-ss 截取视频的开始时间 单位为秒
-t 截取视频的时长,单位为秒
-vcodec 视频编码
-acodec 音频编码
-i 输入文件
前提:ffmpeg在系统的Path目录下,这样执行的时候才会找到这个命令
下面这个程序可以将Linux.mpg分割成长度为len分钟的若干个文件。
缺点:由于无法得知源文件的具体长度,无法计算需要分多少份,只好用system(“pause”)在每次分割完成后暂停,然后根据程序的执行情况,手动地用Ctrl+C结束程序的执行。
/* * @brief test001 use ffmpeg.exe directly * @author ray * @date 2013.3.27 */
#include <stdio.h>
#include <stdlib.h>
int main()
{
char szcmd[128];//command
char szoutfile[128];
int hh = 0;
int mm = 0;
int ss = 0;
const int len = 1;//增加步长:1分钟
int res = 0;
int ms, me;
do
{
hh = mm / 60;
ms = mm-hh*60;
me= ms + len;
sprintf(szoutfile, "%d-%d-%d.mpg", hh, ms, me);
sprintf(szcmd, "ffmpeg -i D:\\media\\5min.mpg -ss %d:%d:%d -t 00:01:00 -vcodec copy -acodec copy %s", hh, ms, ss, szoutfile);
puts(szcmd);//same as printf("%s\n",s)
res = system(szcmd); //发出一个DOS命令
mm += 1;
system("pause");
} while (res == 0);
return 0;
}
相关文章推荐
- android利用jni调用第三方库——第二篇——编写库android程序直接调用第三方库libhello.so
- 用java程序调用ffmpeg执行视频文件格式转换flv
- 用java程序调用ffmpeg执行视频文件格式转换flv
- ffmpeg实现视频切割合并
- 利用ffmpeg来合并视频
- 利用opencv编写dll,在另一个MFC程序中调用显示视频,dll可以用于没有装opencv的电脑中
- java程序调用ffmpeg执行视频文件格式转换flv
- Java通过cmd调用FFmpeg实现大视频文件的分段切割
- C#中使用FFMPEG切割、合并视频。
- [置顶] android利用jni调用第三方库——第二篇——编写库android程序直接调用第三方库libhello.so
- 利用FFmpeg切割视频
- 利用FFmpeg切割视频
- 用java程序调用ffmpeg执行视频文件格式转换flv
- 用java程序调用ffmpeg执行视频文件格式转换flv
- ffmpeg实现视频切割合并
- [视频处理]用java程序调用ffmpeg执行视频文件格式转换flv
- 用java程序调用ffmpeg执行视频文件格式转换flv
- release程序加载调用ffmpeg动态库崩溃
- 利用ffmpeg解析视频文件信息
- 利用ffmpeg做视频解码的顺序