2014-05-30 19:27:55 +01:00
|
|
|
# ffmpeg
|
|
|
|
|
2016-01-07 17:31:27 +00:00
|
|
|
> Video conversion tool.
|
2019-06-07 11:58:12 +01:00
|
|
|
> More information: <https://ffmpeg.org>.
|
2014-05-30 19:27:55 +01:00
|
|
|
|
2016-01-07 17:31:27 +00:00
|
|
|
- Extract the sound from a video and save it as MP3:
|
2014-05-30 19:27:55 +01:00
|
|
|
|
2024-01-31 03:55:19 +00:00
|
|
|
`ffmpeg -i {{path/to/video.mp4}} -vn {{path/to/sound.mp3}}`
|
2014-05-30 19:27:55 +01:00
|
|
|
|
2024-03-20 10:50:28 +00:00
|
|
|
- Transcode a FLAC file to Red Book CD format (44100kHz, 16bit):
|
|
|
|
|
|
|
|
`ffmpeg -i {{path/to/input_audio.flac}} -ar 44100 -sample_fmt s16 {{path/to/output_audio.wav}}`
|
|
|
|
|
2022-06-04 15:35:40 +01:00
|
|
|
- Save a video as GIF, scaling the height to 1000px and setting framerate to 15:
|
2014-05-30 19:27:55 +01:00
|
|
|
|
2023-12-28 15:48:20 +00:00
|
|
|
`ffmpeg -i {{path/to/video.mp4}} -vf 'scale=-1:{{1000}}' -r {{15}} {{path/to/output.gif}}`
|
2014-05-30 19:27:55 +01:00
|
|
|
|
2021-01-31 17:05:18 +00:00
|
|
|
- Combine numbered images (`frame_1.jpg`, `frame_2.jpg`, etc) into a video or GIF:
|
2014-05-30 19:27:55 +01:00
|
|
|
|
2023-12-28 15:48:20 +00:00
|
|
|
`ffmpeg -i {{path/to/frame_%d.jpg}} -f image2 {{video.mpg|video.gif}}`
|
2017-09-23 05:11:41 +01:00
|
|
|
|
2018-08-12 17:20:09 +01: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 19:28:30 +01:00
|
|
|
|
2024-03-20 10:50:28 +00:00
|
|
|
`ffmpeg -ss {{mm:ss}} -to {{mm2:ss2}} -i {{path/to/input_video.mp4}} -codec copy {{path/to/output_video.mp4}}`
|
2018-05-06 19:28:30 +01:00
|
|
|
|
2017-10-25 14:46:31 +01:00
|
|
|
- Convert AVI video to MP4. AAC Audio @ 128kbit, h264 Video @ CRF 23:
|
2017-10-23 22:24:54 +01:00
|
|
|
|
2023-12-28 15:48:20 +00:00
|
|
|
`ffmpeg -i {{path/to/input_video}}.avi -codec:a aac -b:a 128k -codec:v libx264 -crf 23 {{path/to/output_video}}.mp4`
|
2017-10-23 22:24:54 +01:00
|
|
|
|
2017-10-28 12:52:22 +01:00
|
|
|
- Remux MKV video to MP4 without re-encoding audio or video streams:
|
2017-10-23 22:24:54 +01:00
|
|
|
|
2023-12-28 15:48:20 +00:00
|
|
|
`ffmpeg -i {{path/to/input_video}}.mkv -codec copy {{path/to/output_video}}.mp4`
|
2017-12-07 14:15:22 +00:00
|
|
|
|
2023-03-12 17:07:47 +00:00
|
|
|
- Convert MP4 video to VP9 codec. For the best quality, use a CRF value (recommended range 15-35) and -b:v MUST be 0:
|
2017-12-07 14:15:22 +00:00
|
|
|
|
2023-12-28 15:48:20 +00:00
|
|
|
`ffmpeg -i {{path/to/input_video}}.mp4 -codec:v libvpx-vp9 -crf {{30}} -b:v 0 -codec:a libopus -vbr on -threads {{number_of_threads}} {{path/to/output_video}}.webm`
|