FFmpeg user manual-common ffplay commands
When compiling FFmpeg source code, if the system contains the SDL-1.2 version, ffplay compilation is generated by default, if the SDL-1.2 is not included or the version is not the SDL-1.2, cannot generate the ffplay file, so, if you want to use ffplay for streaming media playback testing, you need to install the SDL-1.2.
Ffplay is usually used as a player. In fact, ffplay can not only be used as a player, but also be used as an analysis basis for a lot of image-based audio and video data. ffplay can be used to see the Motion Estimation Direction of video images, audio Data waveforms. More parameters will be introduced and used as an example in this section.
6.1 ffplay common parameters
Ffplay is not only a player, but also a tool for testing ffmpeg's codec engine, format engine, and filter engine. It can also perform visualized media parameter analysis and can be viewed through ffplay -- help:
For example, most of the parameters that have been described earlier are not described.
Parameters |
Description |
X |
Force set the width of the video display window |
Y |
Force set the height of the video display window |
S |
Set the video display width and height |
Fs |
Force full screen display |
An |
Shielded audio |
Vn |
Shield video |
Sn |
Subtitle shielding |
Ss |
Locate and drag Based on the set seconds |
T |
Set the length of the video/audio to be played. |
Bytes |
Set the dragging policy. 0 indicates that the image cannot be dragged, 1 indicates that the image can be dragged, and-1 indicates that the image is automatically dragged. |
Nodisp |
Close graphical display window |
F |
Force resolution using the set format |
Window_title |
Set the title of the display window |
Af |
Set the audio filter. |
Codec |
Force codec Decoding |
Autorotate |
Auto rotate video |
Common parameters can be tried manually:
If you want to play the video from 30th seconds and play the file for 10 seconds, you can use the following command
# Ffplay-ss 30-t 10 input.mp4
If you want the title of the player window to be customized during video playback, run the following command:
Ffplay-window_title "Hello World, This is a sample" output.mp4
The display window is shown as follows:
For example, if you use ffplay to open a live network stream, you can use the command
# Ffplay-window_title "playing test" rtmp: // up.v.test.com/live/stream
The video to be played is a real-time live video stream.
You can see that the title of the player's playback window has been displayed as custom content.
The basic parameters are described. The following describes the advanced parameters of ffplay.
6.2 ffplay advanced Parameters
You can see a lot of help information by using the ffplay-help parameter, which includes the introduction of advanced parameters. The following describes in detail
Parameters |
Description |
Ast |
Set the audio stream to be played |
Vst |
Set the video stream to be played |
Sst |
Set the subtitle stream to be played |
Stats |
Output multimedia playback status |
Fast |
Optimization of non-standardized multimedia compatibility |
Sync |
You can set Audio/Video Synchronization settings for reference, video time reference, or external extension time. |
Autoexit |
After multimedia playback is completed, the function automatically exits ffplay. By default, the function does not exit the player. |
Exitonkeydown |
Exit ffplay when there is a press event |
Exitonmousedown |
Exit ffplay when a mouse button event occurs |
Loop |
Set the number of multimedia file loop playback times |
Framedrop |
Frames are automatically dropped when CPU resources are too high. |
Infbuf |
Sets an unlimited Player buffer. This option is common in Real-Time Streaming Media Playback scenarios. |
Vf |
Video filter settings |
Acodec |
Force use of the set audio decoder |
Vcodec |
Force use of the set Video Decoder |
Scodec |
Force use of the set subtitle Decoder |
The following is a combination of these parameters and the preceding parameters:
For example, if a video is played in 20 seconds, the playback duration is 10 seconds. After the video is played, ffplay is automatically exited and the player window title is "Hello World". To confirm that the playback duration is correct, you can use the system command time to view the command running duration.
# Time ffplay-window_title "Hello World"-ss 20-t 10-autoexit output.mp4
After the command is executed, the output is as follows:
Real0m10.783s
User0m8.401s
Sys0m0.915s
For example, if you use the H264 decoder to forcibly decode the mpeg4 video, an error is returned:
# Ffplay-vcodec h264 output.mp4
When mpeg4 is decoded using the h264 decoder, no frame error is returned and the video cannot be parsed.
In the preceding example, we can see that most of the streams are single-node streams. The following is a multi-node stream that is common in the ** industry video:
When multiple programs appear in the video stream, the playing Program is different from the conventional playing mode. You must specify the corresponding stream, which can be specified through the vst, ast, and sst parameters, for example, if you want to play audio and video streams in Program 13, use the following command line to specify:
# Ffplay-vst 4-ast 5 ~ /Movies/movie/ ChinaTV-11.ts
Playback Effect
The information in Program 13 shows that the value of the stream named service_name is CCTV 9, and the image played after the specified audio and video stream is also matched.
If you want to load the subtitle file when using ffplay to play a video, you can load the ASS or SRT subtitle file. The following is an example of loading the SRT subtitle file. Edit the SRT subtitle file first, the content is as follows:
Then load the subtitle file, such as playing data, using the filter command
# Ffplay-window_title "Test Movie"-vf "subtitles = input. srt" output.mp4
You can use this command to see the following effect:
6.3 ffplay Data Visualization Analysis Application
In addition to playing video streaming media files, ffplay can also be used as a visual analysis tool for Video Streaming Media. For example, when playing an audio file, you cannot determine whether the file sound is normal or not, and analyze the noise data, you can directly use ffplay to play the audio file. during playback, the decoded audio data is displayed in the audio waveform:
# Ffplay-showmode 1 outputexample
We can see that the waveform during audio playback can be displayed through the amplitude to see the audio playback status.
For example, you can use a command to decode each macro block when playing a video.
# Ffplay-debug vis_mb_type-window_title "show vis_mb_type"-ss 20-t 10-autoexit output.mp4
Display window content
In the output video information, you can see blocks of different colors. The following describes what these colors represent:
Color |
Macro Block Type Conditions |
Description |
|
IS_PCM (MB_TYPE_INTRA_PCM) |
Lossless (original sampling does not contain prediction information) |
|
(IS_INTRA & IS_ACPRED) | IS_INTRA16x16 |
16x16 intra-Frame Prediction |
|
IS_INTRA4x4 |
4x4 intra-Frame Prediction |
|
IS_DIRECT |
No motion vector processing (B frame sharding) |
|
IS_GMC & IS_SKIP |
16x16 hop Macro Block (P or B frame sharding) |
|
IS_GMC |
Global Motion Compensation (irrelevant to H264) |
|
! USES_LIST (1) |
Reference previous information (P or B-frame sharding) |
|
! USES_LIST (0) |
Reference future information (B-frame sharding) |
|
USES_LIST (0) & USES_LIST (1) |
Reference past and future information (B-frame sharding) |
For example, you can use ffplay to view B-Frame Prediction and P-frame prediction information. to display the information in the window, run the following command:
# Ffplay-vismv pf output.mp4
Display Effect
The arrow in the figure shows the p-frame motion estimation information.
The vismv parameter is used to display the Motion Vector information during image decoding. The parameter can be set to display the Motion Vector Information of three types.
Parameters |
Description |
Pf |
P frame forward motion estimation display |
Bf |
B frame forward motion estimation display |
Bb |
B frame backward motion estimation display |
This vismv parameter will be replaced in the future. In the future, we will use the codecview filter to set it, as shown in the above image. You can also use the following command to complete the configuration.
# Ffplay-flags2 + export_mvs-ss 40 ~ /Movies/objectC/facebook.mp4-vf codecview = mv = pf + bf + bb