FFMPEG commands

Here I come with a compilation of some of the most used commands of ffmpeg. Some of you could refer to this as some of the most used ffmpeg options. You can use this page as a quick reference guide for your ffmpeg operations.

Get video information

ffmpeg -i input_video.avi

You can read more about getting video information with ffmpeg or getting information using ffprobe which can be better.

Extract all images from a video

ffmpeg -i input_video.avi frame%04d.jpg

Here we extract all the frames from a video and save them as frame0000.jpg, frame0001.jpg, frame0002.jpg etc...

Read more about ffmpeg frame extraction.

Extract one image from a video

ffmpeg -i input_video.avi -ss 00:00:07.000 -vframes 1 image.jpg

With this command we extract one frame in the second 7 ofthe video.

As with the prior operation, you can read more about frame extraction here.

Convert images to a video

ffmpeg -i frame%04d.jpf output_video.avi

Here ffmpeg will take all image files in the form frame0000.jpg, frame0001.jpg, frame0002.jpg etc and it will make a video with them.

Change video resolution

ffmpeg -i input_video.avi -vf scale=640:360 output_video.avi

With this command we have resized the video to a resolution of 640 pixels (width) and 360 pixels (height).

Read more about the ffmpeg scale option, and how to use it.

Change video aspect ratio

ffmpeg -i input_video.avi -vf scale=180:320,setsar=1:1 output_video.avi

Here we have resized the input_video to a resolution of 180 pixels (width) and 320 pixels (height) no matter that the aspect ratio gets distorted from the original file.

In this article you can read more about how to change the aspect ratio of a video using ffmpeg.

Cut a video

ffmpeg -i input_video -ss 00:00:00:05.000 -t 8 output_video.avi

With this command we cut the video from the second 5 and a duration of 8 seconds (up to second 13 of the video) and save it as output_video.avi

Crop a video

ffmpeg -i input_video.avi -filter:v “crop=160:90:100:50” output_video.avi

With this command we get the rectangle from position (100,50) and with a width of 160 pixels and height of 90 pixels, and crop it.

Read more about ffmpeg crop operation.

Extract the sound from a video

ffmpeg -i input_video.avi output_audio.m4a

Remove the sound from a video

ffmpeg -i input_video.avi -an output_video.avi

Here we have removed the audio stream from the video file.

Read more about ffmpeg audio removal.

Convert video to mp4

ffmpeg -i input_video.avi output_video.mp4

It is simple to convert from any supported video file to mp4 file. You just need to use the mp4 extension in the output file. Ffmpeg will convert using default options. If you want to specify some of this options you can use:

ffmpeg -i input_video.avi -f mp4 -vcodec libx264 -preset fast -profile:v main -acodec aac output_video.mp4

With any of this you can convert avi to mp4 which is one of the most popular video transformations. Read more about ffmpeg convert to mp4.

Convert video to gif (animated gif)

ffmpeg -i input_video.avi output_file.gif

Like the prior operation, we specify the extension, in this case the output file has .gif extension. You can convert any video type supported to gif including avi to gif conversion and mp4 to gif conversion.

Read more about ffmpeg video conversion to gif and some of its options.

Convert video to 3gp

ffmpeg -i input_video.avi output_video.3gp

Again, we specify 3gp as the extension of the output file to convert any video to 3gp format with default options. If you want to know more about 3gp video conversion click here.

Convert video to webm

ffmpeg -i input_video.avi output_video.webm

Like in the operations before, if we specify the webm extension in the output file it will be enough to transform a video to webm with default options. In this case it can be useful to use some additional options:

ffmpeg -i input_video.avi -f webm -c:v libvpx -b:v 1M -acodec libvorbis output_video.webm

With this command we will convert the video using libvpx library (which encodes in VP8 codec) with a video bitrate of 1 Meg, and using libvorbis as the audio encoder (encodes audio using Vorbis)

Read more about ffmpeg webm coversion.

Convert video to mkv

ffmpeg -i input_video.avi output_video.mkv

And again like in all the transformations before it can be enough using the mkv extension in the output file. But if we want to use some options:

ffmpeg -i input_video.avi -f matroska -vcodec vp8 -acodec libvorbis output_video.mkv

Here we will be converting the video to mkv format using a VP8 video encoder, and encoding the audio using Vorbis.

Read more about ffmpeg mkv conversion.

Concatenate various videos

ffmpeg -i input_video1.avi input_video2.avi -filter_complex “[0:v:0] [0:a:0] [1:v:0] [1:a:0] concat=n=2:v=1:a=1 [v] [a]” -map “[v]” - map “[a]” output_video.avi

With this command we will be concatenating two videos (input_video1.avi and input_video2.avi) and saving the result as output_video.avi.

::...
免责声明:
当前网页内容, 由 大妈 ZoomQuiet 使用工具: ScrapBook :: Firefox Extension 人工从互联网中收集并分享;
内容版权归原作者所有;
本人对内容的有效性/合法性不承担任何强制性责任.
若有不妥, 欢迎评注提醒:

或是邮件反馈可也:
askdama[AT]googlegroups.com


订阅 substack 体验古早写作:


点击注册~> 获得 100$ 体验券: DigitalOcean Referral Badge

关注公众号, 持续获得相关各种嗯哼:
zoomquiet


自怼圈/年度番新

DU22.4
关于 ~ DebugUself with DAMA ;-)
粤ICP备18025058号-1
公安备案号: 44049002000656 ...::