Display Video on X11 Using FFmpeg xv Device
This article provides a straightforward guide on how to use the
xv (XVideo) output device in FFmpeg to display a video
stream directly in a window on the X11 windowing system. You will learn
how to verify your system’s compatibility, execute the correct FFmpeg
command structure, and customize the output window’s size and title for
real-time video playback.
Prerequisites
To use the xv output device, your system must meet the
following requirements: * An active X11 session (typically Linux or BSD
desktop environments). * An FFmpeg installation compiled with XVideo
support.
You can verify that your FFmpeg binary supports the xv
output device by running the following command in your terminal:
ffmpeg -devicesLook for xv in the output list. It should be marked with
a D (decoding/input supported) or E
(encoding/output supported).
Basic Command Syntax
To display a video file using the xv output device, use
the following basic command structure:
ffmpeg -re -i input.mp4 -f xv "Display"Command breakdown: * -re: Read the
input file at its native frame rate. This is crucial for local files to
prevent FFmpeg from playing the video too quickly. *
-i input.mp4: Specifies the input video file. *
-f xv: Directs FFmpeg to use the XVideo output format. *
"Display": The target X11 display. Passing an empty string
"" or a generic name will target your default display
(usually :0.0).
Customizing the Video Window
You can control the window title and dimensions using specific output private options.
Set a Custom Window Title
Use the -window_title option to change the name
displayed on the window frame:
ffmpeg -re -i input.mp4 -f xv -window_title "My Custom Player" ""Set a Specific Window Size
Use the -window_size option to define the width and
height of the rendering window:
ffmpeg -re -i input.mp4 -f xv -window_size 1280x720 ""Full Practical Example
If you want to play a video file named sample.mkv with a
specific window size of 800x600 pixels and a custom title, run the
following command:
ffmpeg -re -i sample.mkv -f xv -window_title "X11 FFmpeg Player" -window_size 800x600 :0Once executed, a new graphical window will appear on your X11 desktop
displaying the video. You can close the window or press q
in the terminal to stop the playback.