Created
June 16, 2015 13:55
-
-
Save fcalderan/84377a2a65ab4c7dfcf0 to your computer and use it in GitHub Desktop.
Handy FFmpeg commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Build ffmpeg on MacOs | |
# https://trac.ffmpeg.org/wiki/CompilationGuide/MacOSX | |
> brew install ffmpeg --with-fdk-aac --with-ffplay --with-freetype --with-libass --with-libquvi --with-libvorbis --with-libvpx --with-opus --with-x265 | |
# Conversion to WEBM format: | |
# http://trac.ffmpeg.org/wiki/Encode/VP8 | |
> ffmpeg -i input-file.mp4 -c:v libvpx -crf 10 -b:v 1M -c:a libvorbis output-file.webm | |
# Video quality reduction | |
# (Vary the CRF between around 18 and 24 — the lower, the higher the bitrate) | |
> ffmpeg -i input.mp4 -vcodec libx264 -crf 20 output.mp4 | |
# Change video container (no encoding) | |
> ffmpeg -i video.mkv -vcodec copy -acodec copy video.mp4 | |
# Video Scaling | |
> ffmpeg -i input.avi -vf scale=320:240 output.avi | |
# Convert container of all videos in a folder | |
> OIFS="$IFS"; IFS=$'\n'; for i in $(ls *.mkv); do ffmpeg -i $i -vcodec copy -acodec copy $i.mp4; done; IFS="$OIFS"; | |
# Audio normalization | |
# 1) Get max_volume | |
> ffmpeg -i audio.mp3 -af "volumedetect" -f null /dev/null | |
[Parsed_volumedetect_0 @ 0x7f899a40dc40] n_samples: 14162782 | |
[Parsed_volumedetect_0 @ 0x7f899a40dc40] mean_volume: -16.7 dB | |
[Parsed_volumedetect_0 @ 0x7f899a40dc40] max_volume: -2.4 dB | |
# 2) if max_volume < 0 | |
> ffmpeg -i audio.mp3 -af "volume=2.4dB" audio-normalized.mp3 | |
# Partial video extraction | |
# -ss : initial offset | |
# -t : seconds from offset to extract | |
> ffmpeg -i <video.avi> -ss 00:00:00 -t 10 -codec copy <video-copy.avi> | |
# Frame sequence | |
# (http://linuxers.org/tutorial/how-extract-images-video-using-ffmpeg) | |
# -q:v 2 : quality | |
> ffmpeg -i video/video.mp4 -r 25 -s hd480 -f image2 -q:v 2 frames/frame-%4d.jpg | |
# Merge subs in a video | |
> ffmpeg -i subtitle.srt subtitle.ass | |
> ffmpeg -i video.avi -vf "ass=subtitle.ass" out.avi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment