Stop using shady apps for media conversion
You’ve seen them. They pop up everywhere, promising free, instant media conversion...
Bullshit. These websites are either:
- Slow as hell
- Packed with ads
- Straight-up malware
Why bothering with such bad websites, when you have a simpler, better solution.
FFmpeg is a comprehensive multimedia framework that can decode, encode, transcode, mux, demux, stream, filter, and play almost anything that anyone has created. It supports a wide range of audio and video formats, making it the overall best tool for media conversion.
It's framework is free, open-source, and widely used in both professional and personal settings.
They have a large and active community of users and developers. You can find plenty of resources, tutorials, and forums to help you get started and troubleshoot issues.
Gosh, they even have Assembly Language Lessons...
Getting started with FFmpeg
FFmpeg is available for Windows, macOS, and Linux. You can download pre-compiled binaries from the official website, build it yourself or install it via package managers.
On Windows
- Download the latest FFmpeg build from their website.
- Extract the contents to a directory of your choice.
- Add the
bin
directory to your system's PATH environment variable.
On Linux
For Debian-based distributions (e.g., Debian, Ubuntu):
$ sudo apt update -y
$ sudo apt install -y ffmpeg
For Red Hat-based distros (e.g., RHEL, Fedora):
$ sudo dnf install ffmpeg
On Arch-based distros
$ sudo pacman -S ffmpeg
On macOS
You can install FFmpeg on macOS using Homebrew:
$ brew install ffmpeg
Basic commands
Here are a few basic commands to get you started
Converting Images
FFmpeg can handle various image formats, including but not limited to JPEG, BMP, TIFF, and GIF. The command structure remains the same:
$ ffmpeg -i input.bmp output.png
$ ffmpeg -i input.tiff output.png
$ ffmpeg -i input.gif output.png
Converting videos
You can easily convert a video from one format to another, Just by using the following command:
$ ffmpeg -i input.mp4 output.avi
-i input.mp4
specifies the input video file.
Changing Video Resolution
To change the resolution of a video, use the -vf (video filter) option:
$ ffmpeg -i input.mp4 -vf "scale=640:480" output.mp4
-vf "scale=640:480"
scales the video to a resolution of 640x480 pixels.
Extracting Audio from Video
To extract the audio from a video file and save it for example, as an MP3 file:
$ ffmpeg -i input.mp4 -q:a 0 -map a output.mp3
-q:a 0
sets the audio quality to the highest level.-map
a maps the audio stream to the output file.
Applying Filters
FFmpeg supports a wide range of video filters and watermarks. For example, you can apply one by using:
$ ffmpeg -i input.mp4 -vf "overlay=10:10" -i watermark.png output.mp4
-vf "overlay=10:10"
overlays the watermark.png image at the coordinates (10, 10) on the video.-i watermark.png
specifies the input watermark image file.
Extract a Single Frame as PNG
I you need to extract frames in your video and save it somewhere, here how you can :
$ ffmpeg -i input.mp4 -vf "select=eq(n\,10)" -vframes 1 output.png
-i input.mp4
specifies the input video file.-vf "select=eq(n\,10)"
selects the 11th frame (since frame numbering starts at 0).-vframes 1
ensures only one frame is extracted.
Extract All Frames as PNG
What about extracting all frames at once ?
$ ffmpeg -i input.mp4 frame_%04d.png
frame_%04d.png
specifies the output file naming pattern, where%04d
is a placeholder for a four-digit frame number.
Converting Video to GIF
And what about making it a gif ?
$ ffmpeg -i input.mp4 -vf "fps=10,scale=320:-1:flags=lanczos,palettegen" -y palette.png
$ ffmpeg -i input.mp4 -i palette.png -lavfi "fps=10,scale=320:-1:flags=lanczos[x];[x][1:v]paletteuse" output.gif
There's so much more to check on and I couldn't advise you more to check the (full documentation](https://www.ffmpeg.org/ffmpeg.html) and cheatsheet
Overall, FFmpeg is a very nice tool for media conversion, allowing you to work with media convertion with little to no ressources, locally with a Super Well-known framework built by an amazing community. What else to ask for...