FFMpeg toolbox
2 min read editmentary video · audio · media · ffmpegList help (options) for ffmpeg
ffmpeg -h full
How to chunk/segment a video:
ffmpeg -i INPUT.mp4 -acodec copy -f segment -vcodec copy -reset_timestamps 1 -map 0 OUTPUT%d.mp4
Reference: Stack Overflow
Validate/check video for errors:
ffmpeg -v error -i file.avi -f null - 2>error.log
checking multiple videos:
find -name "*.mp4" -exec sh -c "echo '{}' >> errors.log;
ffmpeg -v error -i '{}' -map 0:1 -f null - 2 >> errors.log" \;
Reference: Super User Reference: Stack Overflow
get the meta data for a video using ffprobe
ffprobe -v quiet -print_format json -show_format -show_streams INPUT.mp4
Reference
Concat videos together:
FFmpeg has three concat methods. (in Windows, use double quotes “)
concat protocol
ffmpeg -i 'concat:input1|input2' -codec copy output
concat video filter
ffmpeg -i opening.mkv -i episode.mkv -i ending.mkv \
-filter_complex '[0:0] [0:1] [1:0] [1:1] [2:0] [2:1] concat=n=3:v=1:a=1 [v] [a]' \
-map '[v]' -map '[a]' output.mkv
concat demuxer
$ cat mylist.txt
file '/path/to/file1'
file '/path/to/file2'
file '/path/to/file3'
$ ffmpeg -f concat -i mylist.txt -c copy output
Which one to use
concat protocol: use with formats that support file level concatenation (MPEG-1, MPEG-2 PS, DV). concat filter: use if you need to re-encode such as when applying filters. concat demuxer: use when you want to avoid a re-encode and your format does not support file level concatenation. If in doubt try the concat demuxer.
Disagree? Did I miss something? Comment below .comments powered by Disqus