Featured image of post Fix Choppy or Unsupported Videos on Raspberry Pi Using FFmpeg

Fix Choppy or Unsupported Videos on Raspberry Pi Using FFmpeg

Convert AVI to MP4 Using FFmpeg with H.264 and AAC

When I was troubleshooting playback issues on my Raspberry Pi, I realized that many video formats, especially older ones like .avi, aren’t fully supported by default media players. Some files wouldn’t play at all, others had no sound or were stuttering badly.

After a bit of trial and error, the most reliable solution was to convert the videos to a more modern and compatible format — MP4 with H.264 for video and AAC for audio.

Usage

FFmpeg made the process simple. Here’s the command I used:

1
ffmpeg -i input.avi -c:v libx264 -preset slow -crf 23 -c:a aac -b:a 128k output.mp4

Breakdown of the Command

  • ffmpeg: The command-line tool used for processing audio and video
  • -i input.avi: Specifies the input file. FFmpeg supports a wide range of formats including .avi, .mkv, .mov, .flv, .mpg, .ts, .webm, .wmv, and more
  • -c:v libx264: Uses the H.264 video codec (via the libx264 library)
  • -preset slow: A slower encoding preset which produces better compression (smaller file, same quality)
  • -crf 23: Constant Rate Factor for quality control — 23 is a good balance between size and quality
  • -c:a aac: Uses the AAC audio codec
  • -b:a 128k: Sets audio bitrate to 128kbps
  • output.mp4: The output file name

Why Convert to MP4?

  • Compatibility: MP4 with H.264/AAC is supported by nearly all devices and browsers.
  • Efficiency: Better compression than older AVI formats.
  • Smaller file size with the same perceptual quality.

GUI Options for FFmpeg

There are many graphical user interfaces (GUIs) available for FFmpeg, but personally, I chose the lightweight QWinFF, so I’ll just mention it here briefly.

QWINFF

Installation on Arch Linux:

1
yay -S qwinff

Life is a choice: reboot or be root


Built with Hugo
Theme Stack designed by Jimmy