Play Video in Command Line with FFmpeg SDL

This guide explains how to use FFmpeg’s Simple DirectMedia Layer (SDL) output device to play videos directly from your command line. You will learn the exact command syntax, the importance of real-time streaming flags, and how to control the playback window.

Verifying SDL Support in FFmpeg

Before attempting to play a video, you must ensure your FFmpeg build was compiled with SDL support. Run the following command in your terminal:

ffmpeg -muxers | grep sdl

If you see sdl or sdl2 in the output list, your FFmpeg installation is ready to render video directly to an SDL window.

The Basic Playback Command

To play a video file using the SDL output device, use the following command structure:

ffmpeg -re -i input.mp4 -f sdl "Video Playback"

Here is what each parameter does:

Handling Video Scaling and Aspect Ratio

If you want to force the playback window to a specific resolution while using the SDL device, you can apply a video filter before sending the output to SDL:

ffmpeg -re -i input.mp4 -vf scale=1280:720 -f sdl "Scaled Video Playback"

The -vf scale=1280:720 flag rescales the video to 720p HD on the fly before rendering it in the SDL window.

Controlling the Playback

Once the SDL window opens, you can control the playback directly from the terminal where the command is running: