Summary
Often when watching or processing video, I have small, simple needs, such as intercepting a certain period of the video, or splitting a video into multiple videos according to the number of matches, because this need is so simple, it is not cost-effective to install a video processing software. So I tried to learn how to use it to process a simple video, and this article summarises the commands I used.
Install
[root@liqiang.io]# yum install epel-release
[root@liqiang.io]# rpm -v --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
[root@liqiang.io]# rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
[root@liqiang.io]# yum install -y ffmpeg ffmpeg-devel
Frequently Commands
Merge Videos
[root@liqiang.io]# cat filelist.txt
file '1.mp4'
file '2.mp4'
file '3.mp4'
file '4.mp4'
[root@liqiang.io]# ffmpeg -f concat -i filelist.txt -c copy final.mp4
Split Videos
[root@liqiang.io]# ffmpeg -ss 00:00:00 -t 00:08:40 -i IMG_2266.MOV -acodec copy -vcodec copy game3.mp4
[root@liqiang.io]# ffmpeg -ss 00:09:20 -t 00:18:00 -i IMG_2266.MOV -acodec copy -vcodec copy game4.mp4
-t
的意思是时长,例如第二句的意思就是从视频的 09:20 分开始,截取一段时长为 18:00 的视频,所以这里实际山视频在原视频的时间段为09:20 ~ 27:20
Convert MP4 to Mp3
Simplify method:
[root@liqiang.io]# ffmpeg -i filename.mp4 filename.mp3
Precise control:
[root@liqiang.io]# ffmpeg -i video.mp4 -b:a 192K -vn music.mp3