How to install the Movie Player (MPlayer) on Ubuntu 16.04 ?
MPlayer is capable of displaying a webcam video stream.
mplayer tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0
This example assumes that your webcam device is at /dev/video0
The resolution (width=??? & height=???) should be chosen to match the output of your device.
1. sudo apt install mplayer
[setupvars.sh] OpenVINO environment initialized
strong@foreverstrong:~$ mplayer
The program 'mplayer' is currently not installed. You can install it by typing:
sudo apt install mplayer
strong@foreverstrong:~$ sudo apt install mplayer
[sudo] password for strong:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
libllvm4.0
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
esound-common libaudiofile1 libdirectfb-1.2-9 libenca0 libesd0 libgif7 libsdl1.2debian libvorbisidec1
Suggested packages:
pulseaudio-esound-compat mplayer-doc netselect | fping
The following NEW packages will be installed:
esound-common libaudiofile1 libdirectfb-1.2-9 libenca0 libesd0 libgif7 libsdl1.2debian libvorbisidec1 mplayer
0 upgraded, 9 newly installed, 0 to remove and 180 not upgraded.
Need to get 3,324 kB of archives.
After this operation, 8,666 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://cn.archive.ubuntu.com/ubuntu xenial/universe amd64 libdirectfb-1.2-9 amd64 1.2.10.0-5.1 [606 kB]
Get:2 http://cn.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 libaudiofile1 amd64 0.3.6-2ubuntu0.16.04.1 [94.4 kB]
Get:3 http://cn.archive.ubuntu.com/ubuntu xenial/universe amd64 esound-common all 0.2.41-11 [9,558 B]
Get:4 http://cn.archive.ubuntu.com/ubuntu xenial/universe amd64 libesd0 amd64 0.2.41-11 [16.7 kB]
Get:5 http://cn.archive.ubuntu.com/ubuntu xenial/universe amd64 libenca0 amd64 1.18-1 [53.8 kB]
Get:6 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libgif7 amd64 5.1.4-0.3~16.04 [30.5 kB]
Get:7 http://cn.archive.ubuntu.com/ubuntu xenial/main amd64 libsdl1.2debian amd64 1.2.15+dfsg1-3 [168 kB]
Get:8 http://cn.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 libvorbisidec1 amd64 1.0.2+svn18153-0.2+deb7u1build0.16.04.1 [71.1 kB]
Get:9 http://cn.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 mplayer amd64 2:1.2.1-1ubuntu1.1 [2,274 kB]
Fetched 3,324 kB in 38s (86.2 kB/s)
Selecting previously unselected package libdirectfb-1.2-9:amd64.
(Reading database ... 258128 files and directories currently installed.)
Preparing to unpack .../libdirectfb-1.2-9_1.2.10.0-5.1_amd64.deb ...
Unpacking libdirectfb-1.2-9:amd64 (1.2.10.0-5.1) ...
Selecting previously unselected package libaudiofile1:amd64.
Preparing to unpack .../libaudiofile1_0.3.6-2ubuntu0.16.04.1_amd64.deb ...
Unpacking libaudiofile1:amd64 (0.3.6-2ubuntu0.16.04.1) ...
Selecting previously unselected package esound-common.
Preparing to unpack .../esound-common_0.2.41-11_all.deb ...
Unpacking esound-common (0.2.41-11) ...
Selecting previously unselected package libesd0:amd64.
Preparing to unpack .../libesd0_0.2.41-11_amd64.deb ...
Unpacking libesd0:amd64 (0.2.41-11) ...
Selecting previously unselected package libenca0:amd64.
Preparing to unpack .../libenca0_1.18-1_amd64.deb ...
Unpacking libenca0:amd64 (1.18-1) ...
Selecting previously unselected package libgif7:amd64.
Preparing to unpack .../libgif7_5.1.4-0.3~16.04_amd64.deb ...
Unpacking libgif7:amd64 (5.1.4-0.3~16.04) ...
Selecting previously unselected package libsdl1.2debian:amd64.
Preparing to unpack .../libsdl1.2debian_1.2.15+dfsg1-3_amd64.deb ...
Unpacking libsdl1.2debian:amd64 (1.2.15+dfsg1-3) ...
Selecting previously unselected package libvorbisidec1.
Preparing to unpack .../libvorbisidec1_1.0.2+svn18153-0.2+deb7u1build0.16.04.1_amd64.deb ...
Unpacking libvorbisidec1 (1.0.2+svn18153-0.2+deb7u1build0.16.04.1) ...
Selecting previously unselected package mplayer.
Preparing to unpack .../mplayer_2%3a1.2.1-1ubuntu1.1_amd64.deb ...
Unpacking mplayer (2:1.2.1-1ubuntu1.1) ...
Processing triggers for libc-bin (2.23-0ubuntu10) ...
/sbin/ldconfig.real: /opt/intel/common/mdf/lib64/igfxcmrt64.so is not a symbolic link
/sbin/ldconfig.real: /opt/intel/mediasdk/lib64/libva-x11.so.2 is not a symbolic link
/sbin/ldconfig.real: /opt/intel/mediasdk/lib64/libva-drm.so.2 is not a symbolic link
/sbin/ldconfig.real: /opt/intel/mediasdk/lib64/libva.so.2 is not a symbolic link
/sbin/ldconfig.real: /opt/intel/mediasdk/lib64/libmfxhw64.so.1 is not a symbolic link
/sbin/ldconfig.real: /opt/intel/mediasdk/lib64/libmfx.so.1 is not a symbolic link
/sbin/ldconfig.real: /opt/intel/mediasdk/lib64/libva-glx.so.2 is not a symbolic link
/sbin/ldconfig.real: /opt/intel/mediasdk/lib64/libigdgmm.so.1 is not a symbolic link
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for mime-support (3.59ubuntu1) ...
Setting up libdirectfb-1.2-9:amd64 (1.2.10.0-5.1) ...
Setting up libaudiofile1:amd64 (0.3.6-2ubuntu0.16.04.1) ...
Setting up esound-common (0.2.41-11) ...
Setting up libesd0:amd64 (0.2.41-11) ...
Setting up libenca0:amd64 (1.18-1) ...
Setting up libgif7:amd64 (5.1.4-0.3~16.04) ...
Setting up libsdl1.2debian:amd64 (1.2.15+dfsg1-3) ...
Setting up libvorbisidec1 (1.0.2+svn18153-0.2+deb7u1build0.16.04.1) ...
Setting up mplayer (2:1.2.1-1ubuntu1.1) ...
Processing triggers for libc-bin (2.23-0ubuntu10) ...
/sbin/ldconfig.real: /opt/intel/common/mdf/lib64/igfxcmrt64.so is not a symbolic link
/sbin/ldconfig.real: /opt/intel/mediasdk/lib64/libva-x11.so.2 is not a symbolic link
/sbin/ldconfig.real: /opt/intel/mediasdk/lib64/libva-drm.so.2 is not a symbolic link
/sbin/ldconfig.real: /opt/intel/mediasdk/lib64/libva.so.2 is not a symbolic link
/sbin/ldconfig.real: /opt/intel/mediasdk/lib64/libmfxhw64.so.1 is not a symbolic link
/sbin/ldconfig.real: /opt/intel/mediasdk/lib64/libmfx.so.1 is not a symbolic link
/sbin/ldconfig.real: /opt/intel/mediasdk/lib64/libva-glx.so.2 is not a symbolic link
/sbin/ldconfig.real: /opt/intel/mediasdk/lib64/libigdgmm.so.1 is not a symbolic link
strong@foreverstrong:~$
2. USB Webcam
Open a terminal window and type the following:
2.1 mplayer tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0 -fps 30
[setupvars.sh] OpenVINO environment initialized
strong@foreverstrong:~$ ls /dev/video*
/dev/video0
strong@foreverstrong:~$
strong@foreverstrong:~$
strong@foreverstrong:~$ mplayer tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0 -fps 30
MPlayer 1.2.1 (Debian), built with gcc-5.4.0 (C) 2000-2016 MPlayer Team
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.
Playing tv://.
TV file format detected.
Selected driver: v4l2
name: Video 4 Linux 2 input
author: Martin Olschewski <[email protected]>
comment: first try, more to come ;-)
v4l2: your device driver does not support VIDIOC_G_STD ioctl, VIDIOC_G_PARM was used instead.
Selected device: UVC Camera (046d:0825)
Capabilities: video capture streaming
supported norms:
inputs: 0 = Camera 1;
Current input: 0
Current format: YUYV
tv.c: norm_from_string(pal): Bogus norm parameter, setting default.
v4l2: ioctl enum norm failed: Inappropriate ioctl for device
Error: Cannot set norm!
Selected input hasn't got a tuner!
v4l2: ioctl set mute failed: Invalid argument
v4l2: ioctl query control failed: Invalid argument
==========================================================================
Opening video decoder: [raw] RAW Uncompressed Video
Movie-Aspect is undefined - no prescaling applied.
VO: [vdpau] 640x480 => 640x480 Packed YUY2
Selected video codec: [rawyuy2] vfm: raw (RAW YUY2)
==========================================================================
Audio: no sound
FPS forced to be 30.000 (ftime: 0.033).
Starting playback...
V: 0.0 1/ 1 ??% ??% ??,?% 0 0
v4l2: select timeout
V: 0.0 4607/4607 0% 1% 0.0% 0 0
v4l2: ioctl set mute failed: Invalid argument
v4l2: 4605 frames successfully processed, 568 frames dropped.
Exiting... (Quit)
strong@foreverstrong:~$
2.2 mplayer -tv device=/dev/video0 tv://
[setupvars.sh] OpenVINO environment initialized
strong@foreverstrong:~$ mplayer -tv device=/dev/video0 tv://
MPlayer 1.2.1 (Debian), built with gcc-5.4.0 (C) 2000-2016 MPlayer Team
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.
Playing tv://.
TV file format detected.
Selected driver: v4l2
name: Video 4 Linux 2 input
author: Martin Olschewski <[email protected]>
comment: first try, more to come ;-)
v4l2: your device driver does not support VIDIOC_G_STD ioctl, VIDIOC_G_PARM was used instead.
Selected device: UVC Camera (046d:0825)
Capabilities: video capture streaming
supported norms:
inputs: 0 = Camera 1;
Current input: 0
Current format: YUYV
tv.c: norm_from_string(pal): Bogus norm parameter, setting default.
v4l2: ioctl enum norm failed: Inappropriate ioctl for device
Error: Cannot set norm!
Selected input hasn't got a tuner!
v4l2: ioctl set mute failed: Invalid argument
v4l2: ioctl query control failed: Invalid argument
==========================================================================
Opening video decoder: [raw] RAW Uncompressed Video
Movie-Aspect is undefined - no prescaling applied.
VO: [vdpau] 640x480 => 640x480 Packed YUY2
Selected video codec: [rawyuy2] vfm: raw (RAW YUY2)
==========================================================================
Audio: no sound
Starting playback...
v4l2: select timeout
V: 0.0 537/537 ??% ??% ??,?% 0 0
v4l2: ioctl set mute failed: Invalid argument
v4l2: 537 frames successfully processed, 54 frames dropped.
Exiting... (Quit)
strong@foreverstrong:~$
Esc 按鍵退出。
2.3 snapshot
To use MPlayer to take snapshots from your webcam run this command from the terminal:
mplayer tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0 -fps 15 -vf screenshot
From here you have to press s
to take the snapshot. The snapshot will be saved in your current folder as shotXXXX.png.
S 鍵保存圖片,Esc 按鍵退出。
strong@foreverstrong:~/mplayer$ mplayer tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0 -fps 15 -vf screenshot
MPlayer 1.2.1 (Debian), built with gcc-5.4.0 (C) 2000-2016 MPlayer Team
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.
Playing tv://.
TV file format detected.
Selected driver: v4l2
name: Video 4 Linux 2 input
author: Martin Olschewski <[email protected]>
comment: first try, more to come ;-)
v4l2: your device driver does not support VIDIOC_G_STD ioctl, VIDIOC_G_PARM was used instead.
Selected device: UVC Camera (046d:0825)
Capabilities: video capture streaming
supported norms:
inputs: 0 = Camera 1;
Current input: 0
Current format: YUYV
tv.c: norm_from_string(pal): Bogus norm parameter, setting default.
v4l2: ioctl enum norm failed: Inappropriate ioctl for device
Error: Cannot set norm!
Selected input hasn't got a tuner!
v4l2: ioctl set mute failed: Invalid argument
v4l2: ioctl query control failed: Invalid argument
Opening video filter: [screenshot]
==========================================================================
Opening video decoder: [raw] RAW Uncompressed Video
Movie-Aspect is undefined - no prescaling applied.
[swscaler @ 0x5581c626fe80] bicubic scaler, from yuyv422 to rgb24 using MMXEXT
VO: [vdpau] 640x480 => 640x480 Packed YUY2
Selected video codec: [rawyuy2] vfm: raw (RAW YUY2)
==========================================================================
Audio: no sound
FPS forced to be 15.000 (ftime: 0.067).
Starting playback...
V: 0.0 1/ 1 ??% ??% ??,?% 0 0
v4l2: select timeout
V: 0.0 45/ 45 0% 0% 0.0% 0 0
sending VFCTRL_SCREENSHOT!
*** screenshot 'shot0001.png' ***
V: 0.0 99/ 99 0% 0% 0.0% 0 0
v4l2: ioctl set mute failed: Invalid argument
v4l2: 98 frames successfully processed, 139 frames dropped.
Exiting... (Quit)
strong@foreverstrong:~/mplayer$
strong@foreverstrong:~/mplayer$ ll
total 912
drwxrwxr-x 2 strong strong 4096 2月 2 17:00 ./
drwxr-xr-x 29 strong strong 4096 2月 2 16:57 ../
-rw-rw-r-- 1 strong strong 925009 2月 2 17:00 shot0001.png
strong@foreverstrong:~/mplayer$