【简易广告机】利用树莓派制作一个简易的广告机(1)

利用树莓派做一个简单的广告机

废话不多说开始

1. 安装 omxplayer

omxplayer 简易介绍:omxplayer是专门针对树莓派的GPU的播放器,支持硬件解码,最高支持分辨率是1080P,omxplayer这个命令行播放器,是专门针对树莓派优化了的GPU的播放器,支持硬件解码。支持格式:MKV、AVI、FLV、MP4。
鄙人亲自验证过,MP4格式视频文件播放流畅不卡顿

废话结束

安装

sudo apt-get install omxplayer

安装完毕

pi@raspberrypi:~ $ sudo apt-get install omxplayer
Reading package lists... Done
Building dependency tree... 50%
Building dependency tree       
Reading state information... Done
omxplayer is already the newest version (20190723+gitf543a0d-1).
The following packages were automatically installed and are no longer required:
  alsa-base gstreamer0.10-alsa gstreamer0.10-plugins-base libgstreamer-plugins-base0.10-0
  libgstreamer0.10-0 libxfce4util-bin libxfce4util-common libxfce4util7 libxfconf-0-2
  pimixer point-rpi vlc-l10n vlc-plugin-notify vlc-plugin-samba vlc-plugin-video-splitter
  vlc-plugin-visualization xfconf
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 20 not upgraded.

因为我的树莓派已经安装过所以系统就跳过了

2. 测试 omxplayer

man omxplayer
OMXPLAYER(1)                                                                   OMXPLAYER(1)

NAME
       omxplayer - Raspberry Pi command line OMX player

       OMXPlayer  is  a  commandline OMX player for the Raspberry Pi. It was developed as a
       testbed for the XBMC Raspberry PI implementation and is quite handy  to  use  stand-
       alone.

SYNOPSIS
       Usage: omxplayer [OPTIONS] [FILE]

         -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

#下面是播放时使用,键盘按键使用

KEY BINDINGS
       Key bindings to control omxplayer while playing:

         1           decrease speed
         2           increase speed
         <           rewind
         >           fast forward
         z           show info
         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
         w           show subtitles
         x           hide subtitles
         d           decrease subtitle delay (- 250 ms)
         f           increase subtitle delay (+ 250 ms)
         q           exit omxplayer
         p / space   pause/resume
         -           decrease volume
         + / =       increase volume
         left arrow  seek -30 seconds
         right arrow seek +30 seconds
         down arrow  seek -600 seconds
         up arrow    seek +600 seconds

KEY CONFIG SYNTAX
       A key config file is a series of rules of the form [action]:[key]. Multiple keys can
       be bound to the same action, and comments are supported by adding a #  in  front  of
       the  line.   The  list of valid [action]s roughly corresponds to the list of default
       key bindings above and are:

         DECREASE_SPEED
         INCREASE_SPEED
         REWIND
         FAST_FORWARD
         SHOW_INFO
         PREVIOUS_AUDIO
         NEXT_AUDIO
         PREVIOUS_CHAPTER
         NEXT_CHAPTER
         PREVIOUS_SUBTITLE
         NEXT_SUBTITLE
         TOGGLE_SUBTITLE
         DECREASE_SUBTITLE_DELAY
         INCREASE_SUBTITLE_DELAY
         EXIT
         PAUSE
         DECREASE_VOLUME
         INCREASE_VOLUME
         SEEK_BACK_SMALL
         SEEK_FORWARD_SMALL
         SEEK_BACK_LARGE
         SEEK_FORWARD_LARGE
         STEP

       Valid [key]s include all alpha-numeric characters and most symbols, as well as:

         left
         right
         up
         down
         esc
         hex [keycode]

       For example:

         EXIT:esc
         PAUSE:p
         #Note that this next line has a space after the :
         PAUSE:
         REWIND:left
         SEEK_FORWARD_SMALL:hex 0x4f43
          EXIT:q

                                August 2019                            OMXPLAYER(1)

以上是 omxplayer 打印的功能信息

我们举一个简单的例子:

 omxplayer -o hdmi ruguodangshi.mp4 

这段话的意思是输出音频流到本机的HDMI设备,同时使用HDMI播放视频

pi@raspberrypi:~/pilearn/play $ ls
gaobaiqiqiu.mp4  huanting.mp4  luzhouyue.mp4  play.sh  ruguodangshi.mp4
pi@raspberrypi:~/pilearn/play $ omxplayer -o hdmi ruguodangshi.mp4 
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
Video codec omx-h264 width 640 height 480 profile 77 fps 23.976025
Audio codec aac channels 2 samplerate 22050 bitspersample 16
Subtitle count: 0, state: off, index: 1, delay: 0
V:PortSettingsChanged: 640x480@23.98 interlace:0 deinterlace:0 anaglyph:0 par:1.00 display:0 layer:0 alpha:255 aspectMode:0

视频成功输出到HDMI后,使用显示器(支持HDMI音频播放)测试,不出意外后就能成功显示视频和音乐。

到此 omxplayer 安装大功告成,下一步进行shell脚本编写

猜你喜欢

转载自blog.csdn.net/shileiwu0505/article/details/106506667