A Couple of Useful Commands for FFmpeg

21 January 2021

A Couple of Useful Commands for FFmpeg

« Back
Table of Contents

Here is a collection of various useful commands for FFmpeg that perhaps some day may come in handy for you. It also shows a tiny bit of the endless possibilities that FFmpeg has.

Extract frames as images from a video

ffmpeg -i video.mp4 filename%04d.jpg

Make video from a set of images

ffmpeg -framerate 25 -i ./filename%4d.png video.mp4

Extract xx seconds clip from a long video

ffmpeg -ss 00:00:55 -i video.mp4 -t 00:00:10 -vcodec copy -acodec copy videoclip.mp4

Extract and save audio from a video file

ffmpeg -i video.mp4 -vn -acodec copy audio.aac

Add audio to a video

ffmpeg -y -i video.mp4 -i audio.aac -c copy -map 0:v:0 -map 1:a:0 video-with-audio.mp4

Join two video side by side

  • for horizontal stacking of the videos
ffmpeg -i video1.mp4 -i video2.mp4 -filter_complex hstack -c:v ffv1 output.mp4
  • for vertical stacking of the videos
ffmpeg -i ./sample-1.mp4 -i ./sample-out-image1.mp4 -filter_complex vstack -c:v ffv1 output.mp4

Convert all audio Opus files in one folder in to Wav

for %f in (*.opus) do ffmpeg -i "%f" "%~nf.wav"

Convert m4a to wav (20Kh Mono 16 bit)

ffmpeg -i input.m4a -ac 1 -ar 22050 -sample_fmt s16 output.wav

Convert mp4 to gif

ffmpeg -i INPUT.mp4 -vf "fps=25,scale=iw:ih:flags=lanczos,palettegen" palette.png

ffmpeg -i INPUT.mp4 -i palette.png -filter_complex "fps=25,scale=iw:ih:flags=lanczos[x];[x][1:v]paletteuse" output.gif
Pick a star to rate this

Leave a Reply

Your email address will not be published. Required fields are marked *

Unrelated Content

20 September 2025
FFmpeg Wizard Tool

To satisfy the continuously crawling web-search algorithms out there, I thought it would be a good idea to write this special post, to announce our brand new FFmpeg Wizard Tool. It's a really simple tool, but nevertheless it will hopefully be as useful to you as it has been for us. Just go try it […]

READ MORE
27 November 2020
Motivation behind this website

For every service that is offered for a lot of money on the internet, there's always a free or much cheaper alternative, especially if you embrace open-source software. For live-streaming this is also very much the case. We love that,

READ MORE
23 January 2021
Introduction to the new how-to article in the Knowledge Base.

I wrote a new guide on setting up your own live-stream server. Mostly due to your requests. I took the opportunity to simplify and shorten the guide a bit. If you follow this guide step by step, and use your brain a tiny bit, you'll be fine. This guide has so far been tested on […]

READ MORE
25 January 2021
Optimizing First-Frame Bitrate for HLS

When responding to an HLS request, the streaming server determines which video quality (i.e., ts file) the client will attempt to play before switching to a lower or higher quality video. This switch depends on available bandwidth and device type. Switching to the wrong quality first degrades the user experience considerably. For instance, sending a […]

READ MORE
25 January 2021
Adaptive Bit-rate Streaming

“What is adaptive streaming?” This question often leads to answers filled with technical terms like “HLS”, “MPEG-DASH”, “segments” and “codec“. This article is written for people who need to understand the principles, but don’t need to actually implement the technology. If you are looking for specific technical information on adaptive streaming then I recommend you read up on it on this website and elsewhere.

READ MORE
2 February 2021
About Bradmax Video Player WordPress plugin

Let's talk about our favorite video player plugin for WordPress. Here are some reasons why Bradmax Player is our favorite. And below that are detailed instructions on how to set it up. Setting it up may at first seem a bit awkward, but it really isn't. First you must obviously install the Bradmax Player plugin […]

READ MORE
Copyright © 2025. 
All rights reserved.
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram