FFplay is a media player with a console interface. It uses ffmpeg libraries to work with codecs. Many options that are valid for ffmpeg also work in ffplay. For example, sound settings (e.g. -af volume\channels), video buffer settings(e.g. -vf subtitles) and more.
In Linux repositories, it is usually present along with ffmpeg, so it can be installed with a simple command
sudo apt install ffmpeg
But, probably, it would be better to compile it on your machine with good settings. It will be more optimized. In addition, you can choose a lot more options that will become available. For example, encoding and decoding on gpu. Although the latest versions in the repositories include support for nvidia, but support may not be available for some other video cards.
The main options ffplay
A simple start to watch a video looks like this
The window size can be simply stretched by mouse OR can be set with additional options, for example, if you want to use aliases.
ffplay -x 1280 -y 720 example.mp4
Configuration banner while ffplay starts shows the compilation settings and ffmpeg version.
You can hide the configuration banner using following command
ffplay -hide_banner example.mp4
To rewind the video use the ← and → arrows of keyboard. This rewinds the video for ten seconds.
↑ and ↓ arrows rewinds the video for 1 minute. PgDn and PgUp for 10 minutes.
If you want to go to a specific point, use this command
ffplay -ss 01:13:50 example.mkv
This is a Hours : Minutes : Seconds format.
ffplay -ss 3600 example.mkv
And this is seconds format.
You can control the sound volume with this command
ffplay -af volume=2.2 example.mp4
This will increase the sound volume 2.2 times. Use a value of 0.5 to double decrease the volume
ffplay -af volume=0.5 example.mp4
To select an audio track, use this command and specify the index
ffplay -ast 2 example.mp4
Keep in mind that you need to specify the number of the stream. Numbering starts from zero. Their number is noticed when ffplay starts. Video and subtitle streams are also counted. Often 0 is video stream, and 1, 2… are audio streams. Then usually the subtitle numbers are noticed.
ffplay -vf subtitles="/path/subtitles.srt" example.mp4
ffplay -vf subtitles="example.mkv" example.mkv
If the container has multiple subtitle tracks, you can specify an index
ffplay -vf subtitles="example.mkv:si=3" example.mkv
The third subtitle track will be selected.
Youtube and other media resources
FFplay, can’t independently play video from sites. It can only connect to direct transfer, play the video stream directly. So, if you have a link to a direct media stream (something like a radio), you can use just http protocol, like ffplay http://adress.
But, ffplay supports pipes, so a direct stream of media data can be connected to its stdin. All you need is a program that can extract videos from sites. So you can connect the stdout of this program to the stdin ffplay.
In this situation, an excellent choice would be youtube-dl. I already have an article about it.
It supports hundreds of sites!
So, you can play not only YouTube videos, but also from any other media resource!
Here’s what it looks like.
youtube-dl -o - -f 22 https://youtube_link | ffplay -hide_banner -loglevel panic -i -
How to write a log in a separate file
This may be necessary when we want to extract information about a media file through some scripts.
FFREPORT=file=/tmp/ffreport.log:level=32 ffplay example.mp4
There are many levels there. But this is the most basic. It displays the same thing that we see in the console when ffplay is running.
Some useful hotkeys (while ffplay is playing)
Right click on the video
This is imaginary video progress. Try it! The more right to click, the closer to the end of the video!
Space or "p" key
Pause and unpause.
Left and Right arrow buttons
Rewinds video 10 seconds backward and forward.
Up and Down arrow buttons - As above, but for 60 seconds PgDown, PgUp - for 10 minutes (Or from chapter to chapter if it available)
If you pause, you can rewind video frame by frame. This is useful if you want to take a screenshot. So, the key for this
Pause and then press 's' key
We must be able to exit the ffplay
Now that’s all. I would be grateful for any comments.