The Complete Guide to Video and Audio Conversion with FFmpeg in Ubuntu

A powerful command-line tool for all your multimedia conversion needs

Recently, I needed to create a .FLV file in Ubuntu from a .MOV for the Jungle Jim’s video. During this process, I discovered FFmpeg—an incredibly versatile command-line tool that makes converting between media formats remarkably simple.

FFmpeg is a powerful, open-source multimedia framework that can decode, encode, transcode, mux, demux, stream, filter, and play nearly any type of media. It’s the Swiss Army knife of multimedia processing, relied upon by countless applications, websites, and services worldwide.

In this guide, I’ll walk you through installing FFmpeg on Ubuntu, explain the most useful conversion commands, and break down the parameters so you understand exactly what’s happening when you run these commands.

Installing FFmpeg on Ubuntu

Before diving into conversion commands, let’s make sure FFmpeg is properly installed on your system. Ubuntu users have several options for installation:

Method 1: Install from Ubuntu Repositories (Simplest)

Open a terminal and enter the following commands:

sudo apt update
sudo apt install ffmpeg

Verify the installation by checking the version:

ffmpeg -version

Note: The version in the standard repositories may not be the most recent. As of early 2025, Ubuntu repositories typically provide FFmpeg version 6.1, while the latest stable release is 7.1.

Method 2: Install Latest Version via PPA (Recommended)

For the latest features and improvements, you can install FFmpeg from a PPA:

sudo add-apt-repository ppa:ubuntuhandbook1/ffmpeg7
sudo apt update
sudo apt install ffmpeg

This will install the latest FFmpeg 7.x version with additional features and improvements.

Understanding FFmpeg Command Structure

Before diving into specific commands, it’s helpful to understand the basic structure of FFmpeg commands:

ffmpeg [global_options] -i input_file [output_options] output_file
  • global_options: Apply to the entire process
  • -i input_file: Specifies the input file to process
  • output_options: Apply to the output file (codecs, bitrates, etc.)
  • output_file: The destination file name/path

Pro Tip: FFmpeg will automatically determine which encoders and formats to use based on file extensions, but you can specify them explicitly for more control.

Common FFmpeg Conversion Commands

Here are some of the most useful FFmpeg commands for various conversion tasks. Simply open your terminal, navigate to the directory containing your media files, and run these commands (replacing the filenames with your own).

Converting Video Formats

Convert a FLV file to MPG:

ffmpeg -i original_file.flv new_file.mpg

Convert a MPG file to FLV:

ffmpeg -i original_file.mpg new_file.flv

Convert a MOV file to MP4:

ffmpeg -i original_file.mov -c:v libx264 -c:a aac new_file.mp4

What this does: Converts a MOV file to MP4 using the H.264 video codec and AAC audio codec, which offer excellent quality and compatibility.

Working with Audio

Extract audio from a video file as MP3:

ffmpeg -i input_video.mp4 -vn -ar 44100 -ac 2 -ab 192k -f mp3 output_audio.mp3

What this does:

  • -vn: Disables video recording (extracts audio only)
  • -ar 44100: Sets audio sampling rate to 44.1 kHz (CD quality)
  • -ac 2: Sets 2 audio channels (stereo)
  • -ab 192k: Sets audio bitrate to 192 kbps
  • -f mp3: Forces the output format to MP3

Convert WAV to MP3:

ffmpeg -i input.wav -vn -ar 44100 -ac 2 -ab 192k -f mp3 output.mp3

Extract audio from a video file (simplified command):

ffmpeg -i video.mp4 -vn audio_only.mp3

This simpler command works in many cases, as FFmpeg will automatically select reasonable defaults based on the output file extension.

Pro Tip: If you’re unsure about which audio formats your FFmpeg supports, run ffmpeg -encoders | grep audio to see a list of available audio encoders.

Advanced FFmpeg Commands

Once you’re comfortable with basic conversions, you can explore more advanced FFmpeg capabilities:

Video Resizing and Quality Control

Convert and resize a video:

ffmpeg -i input.mp4 -vf "scale=1280:720" -c:a copy output_720p.mp4

What this does: Resizes the video to 1280×720 pixels (720p) while keeping the original audio.

Create a high-quality MP4 with specific encoding settings:

ffmpeg -i input.mov -c:v libx264 -preset slow -crf 18 -c:a aac -b:a 192k output.mp4

What this does:

  • -c:v libx264: Uses H.264 video codec
  • -preset slow: Uses slower encoding for better compression
  • -crf 18: Sets Constant Rate Factor to 18 (high quality, lower = better)
  • -c:a aac: Uses AAC audio codec
  • -b:a 192k: Sets audio bitrate to 192 kbps

Trimming and Combining

Trim a video to a specific duration:

ffmpeg -i input.mp4 -ss 00:00:30 -to 00:02:00 -c copy trimmed_output.mp4

What this does: Extracts a clip starting at 30 seconds and ending at 2 minutes from the original video.

Concatenate multiple videos:

First, create a file list (videos.txt):

file 'video1.mp4'
file 'video2.mp4'
file 'video3.mp4'

Then concatenate them:

ffmpeg -f concat -safe 0 -i videos.txt -c copy combined_video.mp4

Important: For concatenation to work properly, all videos should have the same codec, resolution, and frame rate. If they differ, you might need to re-encode them first.

Troubleshooting Common Issues

Missing Codecs

If you encounter errors about missing encoders, you may need to install additional codec packages:

sudo apt install ubuntu-restricted-extras

Permission Denied

If you see “permission denied” errors:

  • Check that you have read permissions for input files
  • Ensure you have write permissions for the output directory
  • Use sudo if necessary (though this is rarely needed for FFmpeg)

Unknown Encoder

If FFmpeg reports an “Unknown encoder” error, it means your installation was not compiled with support for that codec. You can check available encoders with:

ffmpeg -encoders

Consider installing FFmpeg from a PPA (as described in the installation section) for a version with more codecs.

Conclusion

FFmpeg is an incredibly powerful tool that can handle virtually any multimedia conversion task you throw at it. While it may seem intimidating at first with its command-line interface, the basic commands are straightforward, and the flexibility it offers is unmatched by graphical alternatives.

As you become more comfortable with FFmpeg, you’ll discover even more advanced features like filters, multi-stream processing, and complex encoding parameters. The official FFmpeg documentation is an excellent resource for exploring these capabilities further.

Whether you’re a content creator, developer, or just someone who occasionally needs to convert media files, FFmpeg is an essential tool to have in your Linux toolkit.

Share Your Experience

Do you have a favorite FFmpeg command or trick? Share it in the comments below to help fellow Ubuntu users!

Google: The Meaning Of Open

I liked one of Google’s recent blog posts about “The Meaning of Open“.

Summary of the Article

  • At Google we believe that open systems win.

  • They lead to more innovation, value, and freedom of choice for consumers, and a vibrant, profitable, and competitive ecosystem for businesses.

  • There are two components to our definition of open: open technology and open information.

    • Open technology includes open source, meaning we release and actively support code that helps grow the Internet, and open standards, meaning we adhere to accepted standards and, if none exist, work to create standards that improve the entire Internet (and not just benefit Google).

    • Open information means that when we have information about users we use it to provide something that is valuable to them, we are transparent about what information we have about them, and we give them ultimate control over their information.

  • The conventional wisdom goes that companies should lock in customers to lock out competitors.

  • There are different tactical approaches — razor companies make the razor cheap and the blades expensive, while the old IBM made the mainframes expensive and the software … expensive too.

    • They can also deliver well-designed products in the short run — the iPod and iPhone being the obvious examples — but eventually innovation in a closed system tends towards being incremental at best (is a four blade razor really that much better than a three blade one?)

  • In an open system, a competitive advantage doesn’t derive from locking in customers, but rather from understanding the fast-moving system better than anyone else and using that knowledge to generate better, more innovative products.

  • Open systems have the potential to spawn industries. They harness the intellect of the general population and spur businesses to compete, innovate, and win based on the merits of their products and not just the brilliance of their business tactics. The race to map the human genome is one example.

  • Networks have always depended on standards to flourish. When railroad tracks were first being laid across the U.S. in the early 19th century, there were seven different standards for track width. The network didn’t flourish and expand west until the different railway companies agreed upon a standard width of 4′ 8.5″. (In this case the standards war was an actual war: Southern railroads were forced to convert over 11,000 miles of track to the new standard after the Confederacy lost to the Union in the Civil War.)

  • Next, we need to make it easy for users to find out what information we gather and store about them across all of our products.

  • Finally, we must always give control to the user.

  • Closed systems are well-defined and profitable, but only for those who control them.

  • Open systems are chaotic and profitable, but only for those who understand them well and move faster than everyone else. Closed systems grow quickly while open systems evolve more slowly, so placing your bets on open requires the optimism, will, and means to think long term.

Key Concepts

Open Technology

Open source code and adherence to open standards that benefit the entire internet ecosystem.

Open Information

User-valuable services with transparency and user control over personal information.

Long-Term Innovation

Open systems foster sustained innovation rather than just incremental improvements in closed ecosystems.

“Open systems are chaotic and profitable, but only for those who understand them well and move faster than everyone else.”