Skip to content

Instantly share code, notes, and snippets.

@michaelkl
Last active April 14, 2018 17:07
Show Gist options
  • Save michaelkl/bfa8107a7cf242e912960192d700f51d to your computer and use it in GitHub Desktop.
Save michaelkl/bfa8107a7cf242e912960192d700f51d to your computer and use it in GitHub Desktop.
Transcoding video with ffmpeg
# Хороший cheat-sheet есть тут:
https://habrahabr.ru/post/333664/
## Transcode video, copy audio in single pass
# see http://trac.ffmpeg.org/wiki/Encode/H.264
ffmpeg -i input -c:v libx264 -preset slow -crf 22 -c:a copy output.mkv
## Rotate video
# see http://stackoverflow.com/questions/3937387/rotating-videos-with-ffmpeg/9570992#9570992
# For the transpose parameter you can pass:
# 0 = 90CounterCLockwise and Vertical Flip (default)
# 1 = 90Clockwise
# 2 = 90CounterClockwise
# 3 = 90Clockwise and Vertical Flip
# Use -vf "transpose=2,transpose=2" for 180 degrees.
ffmpeg -i in.mov -vf "transpose=1" out.mov
## Concatenating files is a bit complicated
# see http://stackoverflow.com/questions/7333232/concatenate-two-mp4-files-using-ffmpeg#11175851
# * Usign 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
## Stabilize video
$ ffmpeg -threads 0 -i deinterlece.avi -vf vidstabdetect=stepsize=6:shakiness=10:accuracy=15 -acodec copy -vcodec rawvideo -y stab_vidstabdetect.avi
$ ffmpeg -threads 0 -i deinterlece.avi -vf vidstabtransform -acodec copy -vcodec rawvideo -y stabilized.avi
## Make mono aac stream
... -c:a aac -b:a 128k -ac 1 ...
## Remove sound
... -an ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment