1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-04-22 12:42:07 +02:00
tldr/pages/common/ffmpeg.md
andrewonyango dd4135b1e6
update ffmpeg syntax for the -codec switch (#9927)
as far as i can tell, the syntax does not use `:video` and `:audio` for the stream specifier, and instead uses `:v` and `:a`, respectively

i'm on version 4.4.2, on ubuntu

`ffmpeg is already the newest version (7:4.4.2-0ubuntu0.22.04.1)`
2023-03-13 01:07:47 +08:00

1.4 KiB

ffmpeg

Video conversion tool. More information: https://ffmpeg.org.

  • Extract the sound from a video and save it as MP3:

ffmpeg -i {{video.mp4}} -vn {{sound}}.mp3

  • Save a video as GIF, scaling the height to 1000px and setting framerate to 15:

ffmpeg -i {{video.mp4}} -vf 'scale=-1:{{1000}}' -r {{15}} {{output.gif}}

  • Combine numbered images (frame_1.jpg, frame_2.jpg, etc) into a video or GIF:

ffmpeg -i {{frame_%d.jpg}} -f image2 {{video.mpg|video.gif}}

  • Quickly extract a single frame from a video at time mm:ss and save it as a 128x128 resolution image:

ffmpeg -ss {{mm:ss}} -i {{video.mp4}} -frames 1 -s {{128x128}} -f image2 {{image.png}}

  • 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):

ffmpeg -ss {{mm:ss}} -to {{mm2:ss2}} -i {{video.mp4}} -codec copy {{output.mp4}}

  • Convert AVI video to MP4. AAC Audio @ 128kbit, h264 Video @ CRF 23:

ffmpeg -i {{input_video}}.avi -codec:a aac -b:a 128k -codec:v libx264 -crf 23 {{output_video}}.mp4

  • Remux MKV video to MP4 without re-encoding audio or video streams:

ffmpeg -i {{input_video}}.mkv -codec copy {{output_video}}.mp4

  • Convert MP4 video to VP9 codec. For the best quality, use a CRF value (recommended range 15-35) and -b:v MUST be 0:

ffmpeg -i {{input_video}}.mp4 -codec:v libvpx-vp9 -crf {{30}} -b:v 0 -codec:a libopus -vbr on -threads {{number_of_threads}} {{output_video}}.webm