ffmpeg的常用功能


cuda版安装https://blog.csdn.net/TracelessLe/article/details/108205992

视频格式转换

  1. mov转mp4

    ffmpeg -i {in-video}.mov -vcodec h264 -acodec aac {out-video}.mp4

    使用gpu进行编解码。

    ffmpeg -hwaccel cuvid -c:v h264_cuvid  -i test3.mov  -acodec aac -c:v h264_nvenc -y test3.mp4
  1. 视频合并与分割

  2. 视频的合并使用以下方法:

    创建一个文本文件,内容如下:

    # this is a comment
    file ‘/path/to/file1’
    file ‘/path/to/file2’
    file ‘/path/to/file3’

    然后使用命令进行合并:

    ffmpeg -f concat -i ~/Downloads/mylist.txt -c copy ~/Downloads/noname.mov

    或者更简单的一个命令搞定:

    ffmpeg -i “concat:noname1.mov|noname2.mov” -c copy noname.mov

裁剪视频

ffmpeg -ss 00:00:00 -t 00:00:30 -i test.mp4 -vcodec copy -acodec copy output.mp4
* -ss 指定从什么时间开始
* -t 指定需要截取多长时间
* -i 指定输入文件
ffmpeg -i input.wmv -ss 30 -c copy -to 40 output.wmv
也可以用 -ss 和 -to 选项, 从第 30 秒截取到第 40 秒

配合编码一起使用,裁剪出来后直接进行编码

ffmpeg -ss 00:00:00 -t 00:00:30 -i test.mp4 -vcodec h264 -acodec aac output.mp4

评论
评论
  目录