Tech/OSS/FFMPEG

From lathama
< Tech‎ | OSS(Redirected from Tech/HowTo/FFMPEG)
Jump to navigation Jump to search

FFMPEG tips and tricks

There can be a deep rabbit hole of details around codecs, scales, and aspect ratios. Test, review and be sure you like the output.


Get a thumbnail from ten seconds in
ffmpeg -i filename.mp4 -ss 00:00:10.000 -vframes 1 filename.png
Get a thumbnail from each mp4 in a directory ten seconds in naming the thumbnail filename.mp4.png
for f in *.mp4; do ffmpeg -i "$f" -ss 00:00:10.000 -vframes 1 "$f".png ;done
Trim the first 1 minute and 20 seconds off the video
ffmpeg -i filename.mp4 -ss 00:01:20 -c:v copy -c:a copy output.mp4

Special note that ffmpeg can not overwrite the input file to trim in place.

Trim 7 minutes out starting at 3 minutes and 22 seconds.
ffmpeg -i filename.mp4 -ss 00:03:23 -t 00:07:00 -c:v copy -c:a copy output.mp4
Reduce the volume by half
ffmpeg -i filename.mp4 -filter:a "volume=0.5" output.mp4
List the resolutions of files in a directory
for f in *.mp4; do echo '$f' && ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=s=x:p=0 '$f' ;done
Upscale a video to 1080P
ffmpeg -i filename.mp4 -filter:v "scale=1920x1080" output.mp4
Downscale to 720p from 1080 height.
ffmpeg -i filename.mp4 -vf scale=-1:720 output.mp4
Convert a MKV to an MP4
ffmpeg -i filename.mkv output.mp4