omxplayer是一款可以使用命令行控制的播放器,图像通过 HDMI显示到屏幕上。
树莓派可以运行omxplayer,在终端使用命令行播放视频。
1. 安装omxplayer
sudo apt-get install omxplayer
将一段mp4视频,通过FTP传输到树莓派中。
2. 使用命令行播放该视频
- 单次播放命令:
omxplayer -o hdmi /home/pi/DJI-MAVIC-AIR2.mp4
- 循环播放命令:
omxplayer -o hdmi /home/pi/DJI-MAVIC-AIR2.mp4 --loop
- 注意:视频文件名称最好不要有空格,会找不到文件。
- 命令参数:
-o hdmi :指定输出方式为 HDMI
--loop :循环播放
-r :调整视频的帧率/分辨率
3. 播放效果
- 注意:VNC界面不会有视频输出。要连接HDMI屏幕才有输出,1080P视频流程播放没有丝毫卡顿。
4. 按键控制
- 按键功能:
q :退出
+ - :控制音量大小
空格键 :暂停
左键、右键 :前进/后退 30s
z Show Info
1 Decrease Speed
2 Increase Speed
j Previous Audio stream
k Next Audio stream
i Previous Chapter
o Next Chapter
n Previous Subtitle stream
m Next Subtitle stream
s Toggle subtitles
d Subtitle delay -250 ms
f Subtitle delay +250 ms
q Exit OMXPlayer
Space or p Pause/Resume
- Decrease Volume
+ Increase Volume
Left Arrow Seek -30 s
Right Arrow Seek +30 s
Down Arrow Seek -600 s
Up Arrow Seek +600 s
5. omxplayer 命令行参数
pi@raspberrypi:~ $ omxplayer --help
-h --help Print this help
-v --version Print version info
-k --keys Print key bindings
-n --aidx index Audio stream index : e.g. 1
-o --adev device Audio out device : e.g. hdmi/local/both/alsa[:device]
-i --info Dump stream format and exit
-I --with-info dump stream format before playback
-s --stats Pts and buffer stats
-p --passthrough Audio passthrough
-d --deinterlace Force deinterlacing
--nodeinterlace Force no deinterlacing
--nativedeinterlace let display handle interlace
--anaglyph type convert 3d to anaglyph
--advanced[=0] Enable/disable advanced deinterlace for HD videos (default enabled)
-w --hw Hw audio decoding
-3 --3d mode Switch tv into 3d mode (e.g. SBS/TB)
-M --allow-mvc Allow decoding of both views of MVC stereo stream
-y --hdmiclocksync Display refresh rate to match video (default)
-z --nohdmiclocksync Do not adjust display refresh rate to match video
-t --sid index Show subtitle with index
-r --refresh Adjust framerate/resolution to video
-g --genlog Generate log file
-l --pos n Start position (hh:mm:ss)
-b --blank[=0xAARRGGBB] Set the video background color to black (or optional ARGB value)
--loop Loop file. Ignored if file not seekable
--no-boost-on-downmix Don't boost volume when downmixing
--vol n set initial volume in millibels (default 0)
--amp n set initial amplification in millibels (default 0)
--no-osd Do not display status information on screen
--no-keys Disable keyboard input (prevents hangs for certain TTYs)
--subtitles path External subtitles in UTF-8 srt format
--font path Default: /usr/share/fonts/truetype/freefont/FreeSans.ttf
--italic-font path Default: /usr/share/fonts/truetype/freefont/FreeSansOblique.ttf
--font-size size Font size in 1/1000 screen height (default: 55)
--align left/center Subtitle alignment (default: left)
--no-ghost-box No semitransparent boxes behind subtitles
--lines n Number of lines in the subtitle buffer (default: 3)
--win 'x1 y1 x2 y2' Set position of video window
--win x1,y1,x2,y2 Set position of video window
--crop 'x1 y1 x2 y2' Set crop area for input video
--crop x1,y1,x2,y2 Set crop area for input video
--aspect-mode type Letterbox, fill, stretch. Default: stretch if win is specified, letterbox otherwise
--audio_fifo n Size of audio output fifo in seconds
--video_fifo n Size of video output fifo in MB
--audio_queue n Size of audio input queue in MB
--video_queue n Size of video input queue in MB
--threshold n Amount of buffered data required to finish buffering [s]
--timeout n Timeout for stalled file/network operations (default 10s)
--orientation n Set orientation of video (0, 90, 180 or 270)
--fps n Set fps of video where timestamps are not present
--live Set for live tv or vod type stream
--layout Set output speaker layout (e.g. 5.1)
--dbus_name name default: org.mpris.MediaPlayer2.omxplayer
--key-config <file> Uses key bindings in <file> instead of the default
--alpha Set video transparency (0..255)
--layer n Set video render layer number (higher numbers are on top)
--display n Set display to output to
--cookie 'cookie' Send specified cookie as part of HTTP requests
--user-agent 'ua' Send specified User-Agent as part of HTTP requests
--lavfdopts 'opts' Options passed to libavformat, e.g. 'probesize:250000,...'
--avdict 'opts' Options passed to demuxer, e.g., 'rtsp_transport:tcp,...'
For example:
./omxplayer -p -o hdmi test.mkv
6. 使用串口通信控制omxplayer
使用串口通信,控制树莓派3B播放视频:串口通信,控制树莓派3B播放视频