2014-05-30 11:27:55 -07:00
|
|
|
# ffmpeg
|
|
|
|
|
2016-01-07 18:31:27 +01:00
|
|
|
> Video conversion tool.
|
2014-05-30 11:27:55 -07:00
|
|
|
|
2016-01-07 18:31:27 +01:00
|
|
|
- Extract the sound from a video and save it as MP3:
|
2014-05-30 11:27:55 -07:00
|
|
|
|
2017-10-26 00:46:31 +11:00
|
|
|
`ffmpeg -i {{video.mp4}} -vn {{sound}}.mp3`
|
2014-05-30 11:27:55 -07:00
|
|
|
|
2016-12-24 01:29:40 +01:00
|
|
|
- Convert frames from a video or GIF into individual numbered images:
|
2014-05-30 11:27:55 -07:00
|
|
|
|
2017-09-23 09:41:41 +05:30
|
|
|
`ffmpeg -i {{video.mpg|video.gif}} {{frame_%d.png}}`
|
2014-05-30 11:27:55 -07:00
|
|
|
|
2017-09-23 09:41:41 +05:30
|
|
|
- Combine numbered images (frame_1.jpg, frame_2.jpg, etc) into a video or GIF:
|
2014-05-30 11:27:55 -07:00
|
|
|
|
2017-09-23 09:41:41 +05:30
|
|
|
`ffmpeg -i {{frame_%d.jpg}} -f image2 {{video.mpg|video.gif}}`
|
|
|
|
|
2017-10-24 08:24:54 +11:00
|
|
|
- Quickly extract a single frame from a video at time mm:ss and save it as a 128x128 resolution image:
|
2017-09-23 09:41:41 +05:30
|
|
|
|
2017-10-24 08:24:54 +11:00
|
|
|
`ffmpeg -ss {{mm:ss}} -i {{video.mp4}} -frames 1 -s {{128x128}} -f image2 {{image.png}}`
|
2014-05-30 11:27:55 -07:00
|
|
|
|
2018-08-12 18:20:09 +02:00
|
|
|
- Trim a video from a given start time mm:ss to an end time mm2:ss2 (omit the -to flag to trim till the end):
|
2018-05-06 20:28:30 +02:00
|
|
|
|
2018-08-12 18:20:09 +02:00
|
|
|
`ffmpeg -ss {{mm:ss}} -to {{mm2:ss2}} -i {{video.mp4}} -codec copy {{output.mp4}}`
|
2018-05-06 20:28:30 +02:00
|
|
|
|
2017-10-26 00:46:31 +11:00
|
|
|
- Convert AVI video to MP4. AAC Audio @ 128kbit, h264 Video @ CRF 23:
|
2017-10-24 08:24:54 +11:00
|
|
|
|
2017-10-26 00:46:31 +11:00
|
|
|
`ffmpeg -i {{input_video}}.avi -codec:audio aac -b:audio 128k -codec:video libx264 -crf 23 {{output_video}}.mp4`
|
2017-10-24 08:24:54 +11:00
|
|
|
|
2017-10-28 22:52:22 +11:00
|
|
|
- Remux MKV video to MP4 without re-encoding audio or video streams:
|
2017-10-24 08:24:54 +11:00
|
|
|
|
2017-10-28 22:52:22 +11:00
|
|
|
`ffmpeg -i {{input_video}}.mkv -codec copy {{output_video}}.mp4`
|
2017-12-07 15:15:22 +01:00
|
|
|
|
2017-12-28 13:29:45 +01:00
|
|
|
- Convert MP4 video to VP9 codec. For the best quality, use a CRF value (recommended range 15-35) and -b:video MUST be 0:
|
2017-12-07 15:15:22 +01:00
|
|
|
|
2017-12-28 17:35:56 +05:30
|
|
|
`ffmpeg -i {{input_video}}.mp4 -codec:video libvpx-vp9 -crf {{30}} -b:video 0 -codec:audio libopus -vbr on -threads {{number_of_threads}} {{output_video}}.webm`
|