Four useful ffmpeg commands.

In this blog post I’m listing four ffmpeg commands that I use more than any other.


Extracting frames from video..

ffmpeg -i /home/furycd001/Downloads/video.mp4 /home/furycd001/Downloads/image_%04d.png

Using this command you can extract pretty much every frame from a video. The amount of numbers at the end of filename can be set by changing 04d to 01d or whatever you want. You can also change the filename from image_%04d.png to soy_%02d.png or again whatever you want. Just remember to keep the %04d part at the end or you’ll run into problems.

Cutting parts from a video..

ffmpeg -i input.mp4 -ss 00:00:00 -to 00:00:00 -c:v copy -c:a copy -strict -2 output.mp4

Cutting parts from a video is as easy as running the command above. Just place the time you wish to start at after -ss & then finish after -to. Sometimes if the cut length isn’t long enough i’ll get a blank output, but making it longer always sloves this.

ffmpeg -i input.mp4 -to 00:00:00 -c:v copy -c:a copy -strict -2 output.mp4

If you want cut the video to play from the start up until a certain point, you can remove the -ss start section leaving only the -to section. This will cut everything after the designated time. You can also reverse this by removing -to & leaving -ss. This will cut everything from before the designated time & leave everything else.

Record the entire screen..

ffmpeg -f x11grab -video_size 1920x1080 -framerate 30 -i :0.0 -f pulse -i default -preset ultrafast -crf 18 -pix_fmt yuv420p out.mp4

You can record your entire screen along with audio using the above command. You can check pavucontrol for recording options & mute your microphone for no room audio.

Increase audio volume using ffmpeg..

ffmpeg -i input.mkv -filter:a "volume=4.0" output.mkv;

With this command you can increase the audio volume in a video or audio file. Just change volume=4.0 to volume=8.0 or whatever you require.

Related posts