The following guidance might be useful in helping to configure the mplayer video player on a Linux server. This recounts how I configured a mplayer on my Linux Web-server detailing exactly what worked for me.
The reason for installing and configuring mplayer on my Linux Web-server was to investigate, in the hope of using, mplayer as means of retrieving still (JPG) images off a Linksys WVC54G IP Web-camera. This particular IP camera is well documented as not being very easy to use with ZoneMinder because of the difficulty of retrieving usable images (direct access to mpeg is not possible, as the camera outputs asf format images only). A method was published (see http://majordomo.squawk.com/njs/blog/2006/03/extracting-jpeg-or-jpg-from-linksys.html) involving the use of mplayer to retrieve single jpgs.
The mplayer software is described in: http://www.mplayerhq.hu/ and http://en.wikipedia.org/wiki/MPlayer.
The following command sequence was followed to bring the Linux system up-to-date with the necessary software using yum:
# uname -a Linux hostname 2.6.9-42.0.8.EL #1 Tue Jan 30 12:10:22 EST 2007 i686 i686 i386 GNU/Linux # more /etc/redhat-release CentOS release 4.4 (Final) # yum install mplayer Setting up Install Process Setting up repositories Reading repository metadata in from local files Parsing package install arguments No Match for argument: mplayer Nothing to do
But yum was clearly not updating for mplayer.
# more /etc/yum.conf [main] cachedir=/var/cache/yum debuglevel=2 logfile=/var/log/yum.log pkgpolicy=newest distroverpkg=centos-release tolerant=1 exactarch=1 retries=20 obsoletes=1 gpgcheck=1 # PUT YOUR REPOS HERE OR IN separate files named file.repo # in /etc/yum.repos.d
Following the advice available from: http://wiki.centos.org/Repositories/RPMForge yum was updated as follows:
# yum install yum-plugin-protectbase Setting up Install Process Setting up repositories update 100% |=========================| 951 B 00:00 base 100% |=========================| 1.1 kB 00:00 addons 100% |=========================| 951 B 00:00 extras 100% |=========================| 1.1 kB 00:00 Reading repository metadata in from local files Parsing package install arguments Resolving Dependencies --> Populating transaction set with selected packages. Please wait. ---> Downloading header for yum-plugin-protectbase to pack into transaction set. yum-plugin-protectbase-1. 100% |=========================| 2.8 kB 00:00 ---> Package yum-plugin-protectbase.noarch 0:1.1-1.c4 set to be updated --> Running transaction check Dependencies Resolved ============================================================================= Package Arch Version Repository Size ============================================================================= Installing: yum-plugin-protectbase noarch 1.1-1.c4 extras 11 k Transaction Summary ============================================================================= Install 1 Package(s) Update 0 Package(s) Remove 0 Package(s) Total download size: 11 k Is this ok [y/N]: y Downloading Packages: (1/1): yum-plugin-protect 100% |=========================| 11 kB 00:00 Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing: yum-plugin-protectbase ######################### [1/1] Installed: yum-plugin-protectbase.noarch 0:1.1-1.c4 Complete! #
Edit the file /etc/yum.conf and add the following line to the [main] section:
plugins=1
Edit the file /etc/yum.repos.d/CentOS-Base.repo and add the following line to the [base] and [update] section:
protect=1
and add the following line to the remaining sections:
protect=0
Download and install the rpmforge-release package first determining/confirming the host architecture:
# uname -i i386
Install DAG's GPG key:
# rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
Verify the downloaded package:
# rpm -K rpmforge-release-0.3.6-1.el4.rf.*.rpm
Install the downloaded package:
# rpm -i rpmforge-release-0.3.6-1.el4.rf.*.rpm error: File not found by glob: rpmforge-release-0.3.6-1.el4.rf.*.rpm
Having now added a yum repository config file and imported the appropriate GPG keys, test:
# yum check-update Loading "protectbase" plugin Setting up repositories rpmforge 100% |=========================| 1.1 kB 00:00 Reading repository metadata in from local files primary.xml.gz 100% |=========================| 1.3 MB 00:05 rpmforge : ################################################## 5430/5430 Added 5430 new packages, deleted 0 old in 129.17 seconds 96 packages excluded due to repository protections
Finally the system is ready to install mplayer, and the full log of this process is shown below:
# yum install mplayer Loading "protectbase" plugin Setting up Install Process Setting up repositories Reading repository metadata in from local files 96 packages excluded due to repository protections Parsing package install arguments Resolving Dependencies --> Populating transaction set with selected packages. Please wait. ---> Downloading header for mplayer to pack into transaction set. mplayer-1.0-0.33.rc1.el4. 100% |=========================| 35 kB 00:00 ---> Package mplayer.i386 0:1.0-0.33.rc1.el4.rf set to be updated --> Running transaction check --> Processing Dependency: libxvidcore.so.4 for package: mplayer --> Processing Dependency: libXvMCW.so.1 for package: mplayer --> Processing Dependency: liblzo.so.1 for package: mplayer --> Processing Dependency: libaa.so.1 for package: mplayer --> Processing Dependency: libopenal.so.0 for package: mplayer --> Processing Dependency: liblirc_client.so.0 for package: mplayer --> Processing Dependency: libfaac.so.0 for package: mplayer --> Processing Dependency: libmad.so.0 for package: mplayer --> Processing Dependency: mplayer-fonts for package: mplayer --> Processing Dependency: libfribidi.so.0 for package: mplayer --> Processing Dependency: libdvdnav.so.4 for package: mplayer --> Processing Dependency: libmpcdec.so.3 for package: mplayer --> Processing Dependency: libx264.so.54 for package: mplayer --> Processing Dependency: libmp3lame.so.0 for package: mplayer --> Restarting Dependency Resolution with new changes. --> Populating transaction set with selected packages. Please wait. ---> Downloading header for x264 to pack into transaction set. x264-0.0.0-0.3.20061214.e 100% |=========================| 4.3 kB 00:00 ---> Package x264.i386 0:0.0.0-0.3.20061214.el4.rf set to be updated ---> Downloading header for openal to pack into transaction set. openal-0.0.8-2.el4.rf.i38 100% |=========================| 4.0 kB 00:00 ---> Package openal.i386 0:0.0.8-2.el4.rf set to be updated ---> Downloading header for fribidi to pack into transaction set. fribidi-0.10.4-6.i386.rpm 100% |=========================| 3.8 kB 00:00 ---> Package fribidi.i386 0:0.10.4-6 set to be updated ---> Downloading header for libdvdnav to pack into transaction set. libdvdnav-0.1.10-3.el4.rf 100% |=========================| 3.7 kB 00:00 ---> Package libdvdnav.i386 0:0.1.10-3.el4.rf set to be updated ---> Downloading header for libXvMCW to pack into transaction set. libXvMCW-0.9.3-1.2.el4.rf 100% |=========================| 2.6 kB 00:00 ---> Package libXvMCW.i386 0:0.9.3-1.2.el4.rf set to be updated ---> Downloading header for libmpcdec to pack into transaction set. libmpcdec-1.2.2-2.el4.rf. 100% |=========================| 3.7 kB 00:00 ---> Package libmpcdec.i386 0:1.2.2-2.el4.rf set to be updated ---> Downloading header for lzo to pack into transaction set. lzo-1.08-4.2.el4.rf.i386. 100% |=========================| 4.4 kB 00:00 ---> Package lzo.i386 0:1.08-4.2.el4.rf set to be updated ---> Downloading header for aalib to pack into transaction set. aalib-1.4.0-5.2.el4.rf.i3 100% |=========================| 6.1 kB 00:00 ---> Package aalib.i386 0:1.4.0-5.2.el4.rf set to be updated ---> Downloading header for lame to pack into transaction set. lame-3.97-1.el4.rf.i386.r 100% |=========================| 5.6 kB 00:00 ---> Package lame.i386 0:3.97-1.el4.rf set to be updated ---> Downloading header for libmad to pack into transaction set. libmad-0.15.1b-4.el4.rf.i 100% |=========================| 3.8 kB 00:00 ---> Package libmad.i386 0:0.15.1b-4.el4.rf set to be updated ---> Downloading header for xvidcore to pack into transaction set. xvidcore-1.1.2-1.el4.rf.i 100% |=========================| 4.0 kB 00:00 ---> Package xvidcore.i386 0:1.1.2-1.el4.rf set to be updated ---> Downloading header for lirc to pack into transaction set. lirc-0.6.6-4.2.el4.rf.i38 100% |=========================| 22 kB 00:00 ---> Package lirc.i386 0:0.6.6-4.2.el4.rf set to be updated ---> Downloading header for faac to pack into transaction set. faac-1.25-2.el4.rf.i386.r 100% |=========================| 3.8 kB 00:00 ---> Package faac.i386 0:1.25-2.el4.rf set to be updated ---> Downloading header for mplayer-fonts to pack into transaction set. mplayer-fonts-1.1-3.0.rf. 100% |=========================| 14 kB 00:00 ---> Package mplayer-fonts.noarch 0:1.1-3.0.rf set to be updated --> Running transaction check --> Processing Dependency: libmp4v2.so.0 for package: faac --> Restarting Dependency Resolution with new changes. --> Populating transaction set with selected packages. Please wait. ---> Downloading header for faad2 to pack into transaction set. faad2-2.0-8.el4.rf.i386.r 100% |=========================| 4.8 kB 00:00 ---> Package faad2.i386 0:2.0-8.el4.rf set to be updated --> Running transaction check Dependencies Resolved ============================================================================= Package Arch Version Repository Size ============================================================================= Installing: mplayer i386 1.0-0.33.rc1.el4.rf rpmforge 4.9 M Installing for dependencies: aalib i386 1.4.0-5.2.el4.rf rpmforge 105 k faac i386 1.25-2.el4.rf rpmforge 130 k faad2 i386 2.0-8.el4.rf rpmforge 443 k fribidi i386 0.10.4-6 base 48 k lame i386 3.97-1.el4.rf rpmforge 588 k libXvMCW i386 0.9.3-1.2.el4.rf rpmforge 10 k libdvdnav i386 0.1.10-3.el4.rf rpmforge 87 k libmad i386 0.15.1b-4.el4.rf rpmforge 82 k libmpcdec i386 1.2.2-2.el4.rf rpmforge 30 k lirc i386 0.6.6-4.2.el4.rf rpmforge 232 k lzo i386 1.08-4.2.el4.rf rpmforge 61 k mplayer-fonts noarch 1.1-3.0.rf rpmforge 1.0 M openal i386 0.0.8-2.el4.rf rpmforge 291 k x264 i386 0.0.0-0.3.20061214.el4.rf rpmforge 681 k xvidcore i386 1.1.2-1.el4.rf rpmforge 521 k Transaction Summary ============================================================================= Install 16 Package(s) Update 0 Package(s) Remove 0 Package(s) Total download size: 9.1 M Is this ok [y/N]: y Downloading Packages: (1/16): x264-0.0.0-0.3.20 100% |=========================| 681 kB 00:03 (2/16): openal-0.0.8-2.el 100% |=========================| 291 kB 00:02 (3/16): fribidi-0.10.4-6. 100% |=========================| 48 kB 00:00 (4/16): libdvdnav-0.1.10- 100% |=========================| 87 kB 00:00 (5/16): libXvMCW-0.9.3-1. 100% |=========================| 10 kB 00:00 (6/16): libmpcdec-1.2.2-2 100% |=========================| 30 kB 00:00 (7/16): lzo-1.08-4.2.el4. 100% |=========================| 61 kB 00:00 (8/16): aalib-1.4.0-5.2.e 100% |=========================| 105 kB 00:00 (9/16): faad2-2.0-8.el4.r 100% |=========================| 443 kB 00:01 (10/16): lame-3.97-1.el4. 100% |=========================| 588 kB 00:02 (11/16): mplayer-1.0-0.33 100% |=========================| 4.9 MB 00:23 (12/16): libmad-0.15.1b-4 100% |=========================| 82 kB 00:00 (13/16): xvidcore-1.1.2-1 100% |=========================| 521 kB 00:02 (14/16): lirc-0.6.6-4.2.e 100% |=========================| 232 kB 00:01 (15/16): faac-1.25-2.el4. 100% |=========================| 130 kB 00:00 (16/16): mplayer-fonts-1. 100% |=========================| 1.0 MB 00:04 Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing: mplayer-fonts ####################### [ 1/16] Installing: lirc ####################### [ 2/16] Installing: xvidcore ####################### [ 3/16] Installing: libmad ####################### [ 4/16] Installing: lame ####################### [ 5/16] Installing: faad2 ####################### [ 6/16] Installing: faac ####################### [ 7/16] Installing: aalib ####################### [ 8/16] Installing: lzo ####################### [ 9/16] Installing: libmpcdec ####################### [10/16] Installing: libXvMCW ####################### [11/16] Installing: libdvdnav ####################### [12/16] Installing: fribidi ####################### [13/16] Installing: openal ####################### [14/16] Installing: x264 ####################### [15/16] Installing: mplayer ####################### [16/16] Installed: mplayer.i386 0:1.0-0.33.rc1.el4.rf Dependency Installed: aalib.i386 0:1.4.0-5.2.el4.rf faac.i386 0:1.25-2.el4.rf faad2.i386 0:2.0-8.el4.rf fribidi.i386 0:0.10.4-6 lame.i386 0:3.97-1.el4.rf libXvMCW.i386 0:0.9.3-1.2.el4.rf libdvdnav.i386 0:0.1.10-3.el4.rf libmad.i386 0:0.15.1b-4.el4.rf libmpcdec.i386 0:1.2.2-2.el4.rf lirc.i386 0:0.6.6-4.2.el4.rf lzo.i386 0:1.08-4.2.el4.rf mplayer-fonts.noarch 0:1.1-3.0.rf openal.i386 0:0.0.8-2.el4.rf x264.i386 0:0.0.0-0.3.20061214.el4.rf xvidcore.i386 0:1.1.2-1.el4.rf Complete!
mplayer should now work!
The mplayer command can be used direct from the command line, and an example of the format and use is shown below. In fact this example is the basic format used in the script used to retrieve a single frame jpg image later.
mplayer -nortc -nojoystick -prefer-ipv4 -nolirc -nocache -user USER -passwd PASSWD -frames 1 -vo jpeg http://yr.cam.ip.addr/img/video.asf
An explanation of the parameters used on the mplayer command line follows. These are largely taken, with some minor adjustments, from http://majordomo.squawk.com/njs/blog/2006/03/extracting-jpeg-or-jpg-from-linksys.html.
## The heavy lifting is all done by mplayer. It opens the camera, does the authentication, gets the stream for one frame, ## and then puts out that frame in a jpeg. The jpeg would be named something like 00000001.jpg, and, if there were more than ## one frame, the next frame would be called 00000002.jog, and so forth. The stuff that surrounds the mplayer command does ## the other work - it makes a temporary directory for the camera output to be put into, then it grabs the last frame output ## (in case you want to grab a couple of frames. The mplayer arguments are as follows: ## ## - user ASCONFIG - the userid configured - this should not be the "admin" user, it should be a user that can only ## get the camera data. ## - passwd ASCONFIG - ditto ## - vc mpeg4ds - not needed at the Fedora core 4 or 5 level, this was required at the Fedora core 1 level to tell mplayer ## which codec to use. If you get warnings or errors, try this option. ## - frames 1 - tells the mplayer program to grab a single frame - if you need more than one frame, try changing this to 2. ## It may cause two jpegs to be written to disk, which is taken care of by the script that I have provided. ## - nojoystick - mplayer can use a joystick to control some functions of the progam - there is no reason to use it or warn ## about not being able to use it for a batch function like this. ## - nortc - no real time clock - not needed for a single frame grab, and there are warnings you don't need that are produced ## when you try to use it, depending on how it is configured. ## - nolirc - this might allow for remote control input for things like pauses. Again, warnings will be produced and the ## remote is not needed for a single frame grab. ## - nocache - depending on the defaults, mplayer might cache many megs of data to output a single frame. The cache operation ## is not needed for a single frame conversion, and the operation is much faster when the caching is not done. ## - prefer-ipv4 - This camera will only work on an IPV4 network. The mplayer program will try to find an IPV6 address for ## the camera, fail, and then fallback to IPV4. This option makes the mplayer program work faster, in this instance. ## - vo jpeg - this option is what makes the output be produced in jpg format. ## - ao null - I would have expected this to make the process go faster - to make it not do any audio processing. Instead it ## completely broke things. You might try it to see if it works for you. If you find that it makes the command fail, ## take it out. If running the capture causes a clicking on your audio or a short burst of audio, then try this option. ## ## http://yr.cam.ip.addr/img/video.asf - change this by taking yr.cam.ip.addr and putting in the ip address or name of ## your camera. /img/video.asf is the unpublished relative url of the video stream. ## 1. http:// - use the hypertext transfer protocol. ## 2. yr.cam.ip.addr - Could be something like 192.168.1.15 or camera1.local or some other name that you have set up ## - if you are using port forewarding to make the camera visible on the internet, you might use the ip address ## of your interface as supplied by your ISP, or a name they supply, or a name that dynamic DNS (or static DNS) ## has mapped to your IP address. ## 3. :80 - The :80 is understood and is the default. If you are using some other port number, you put it ## following the address and a colon, and preceeding the /. If you are accepting the default to port 80, ## as I am, you can (and usually do) leave this off. ## 4. /img/video.asf is the unpublished relative url of the video stream.
In order to make the Linksys WVC54G image(s) available to ZoneMinder the plan was to retrieve a single frame image from Linksys WVC54G using a shell script which employs mplayer to do this as follows:
The bare bones of the shell script used is shown:
#!/bin/sh # Grab a "frame" from the video camera. # put it into the "right" place. # from http://majordomo.squawk.com/njs/blog/2006/03/extracting-jpeg-or-jpg-from-linksys.html TMPDIR="/tmp" MPDIR="/tmp/mplayer" TMPVIDDIR=`mktemp -d -t vidcap.XXXXXXXXXXXXX` TARGETDIR="$MPDIR/vid-archive" cd $TMPVIDDIR || (echo "Cannot cd to $TMPVIDDIR"; exit 1) mplayer -nortc -nojoystick -prefer-ipv4 -nolirc -nocache -user USER -passwd PASSWD -frames 1 -vo jpeg http://yr.cam.ip.addr/img/video.asf D1=`date '+%Y%m%d'` D2=`date '+%Y%m%d_%H%M%S'` if [ ! -s $TARGETDIR/vidcap."$D1" ] then mkdir $TARGETDIR/vidcap."$D1" fi tfile=`ls *.jpg | tail -1` if [ -s "$tfile" ] then cp -f "$tfile" $TARGETDIR/vidcap."$D1"/"$D2".jpg # archive area cp -f "$tfile" /home/www/TestWebSite/webcam/wcv54g_monitor.jpg cp -f "$tfile" /home/www/PublicWebSite/webcam/wcv54g_monitor.jpg else echo "$tfile did not exist" fi rm -rf *.jpg exit 0
The size of the captured image can be altered (and this was found to be necessary due to shared memory limitations when using http://www.zoneminder.com/). The revised command line is shown below:
mplayer -nortc -nojoystick -prefer-ipv4 -nolirc -nocache -user USER -passwd PASSWD -frames 1 -vo jpeg -vf scale=320:240 http://yr.cam.ip.addr/img/video.asf
Schedule a cron job:
* 8-17 * * * /home/work/utils/MplayerFrameGrab.sh >> /dev/null 2>&1
Future work: grab more frequent frames: e.g. with the cron job scheduled each minute adjust the script to grab a frame every, say, 10 or 15 secs.
Configure as shown in the ZoneMinder link to use the jpg file generated as a static file input.
The following general links are useful references when setting up ZoneMinder to run on a Linux server:
URL | Summary/Description |
---|---|
http://wiki.centos.org/Repositories/RPMForge | General RPMForge information |
The following general links are useful references when setting up ZoneMinder to grabs frames off an IP camera such as the the Linksys WVC54G:
URL | Summary/Description |
---|---|
http://majordomo.squawk.com/njs/blog/2006/03/extracting-jpeg-or-jpg-from-linksys.html | First suggested the idea of grabbing a single frame from the Linksys WVC54G IP web-cam using mplayer |
http://www.javalaw.cn/forum/read.php?tid=342&fpage=1 | Another variant of the jpeg extraction description (needs translating from Chinese) |
http://www-128.ibm.com/developerworks/library/os-mosperl/index.html | Frame grabbing Perl script |
The following general links are useful references when setting up MPlayer to run on a Linux server:
URL | Summary/Description |
---|---|
http://www.mplayerhq.hu/DOCS/man/en/mplayer.1.html | Mplayer documentation |
http://wiki.linuxquestions.org/wiki/MPlayer | Mplayer wiki |
http://www.linux-sxs.org/multimedia/mplayer.html | MPlayer, the opensource movie player |
The following general links are useful general references for video editing software a Linux server:
URL | Summary/Description |
---|---|
http://en.wikipedia.org/wiki/Video_editing_software | Video editing software summary information |
http://en.wikipedia.org/wiki/Audio_Video_Interleave | Audio/video summary information |
http://en.wikipedia.org/wiki/Comparison_of_video_editing_software | Video editing software comparsion sheets |
http://grimthing.com/archives/2004/05/20/recording-streaming-audio-with-mplayer/ | Streaming with Mplayer |