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.