Showing posts with label video. Show all posts
Showing posts with label video. Show all posts

Friday, 19 March 2021

How to rip DVD disc on Ubuntu

 I used HandBrake application and it was incredibly easy and fast.

To install it, we need to add developer's package repository first:

$ sudo add-apt-repository ppa:stebbins/handbrake-releases
$ sudo apt-get update

HandBrake installation:

$ sudo apt-get install handbrake-cli handbrake-gtk
Reading package lists... Done
Building dependency tree       
Reading state information... Done
handbrake-gtk is already the newest version (1:1.3.3.1-zhb-1ppa1~focal1).
The following NEW packages will be installed
  handbrake-cli
0 to upgrade, 1 to newly install, 0 to remove and 35 not to upgrade.
Need to get 8,623 kB of archives.
After this operation, 40.9 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://ppa.launchpad.net/stebbins/handbrake-releases/ubuntu focal/main amd64 handbrake-cli amd64 1:1.3.3.1-zhb-1ppa1~focal1 [8,623 kB]
Fetched 8,623 kB in 3s (3,041 kB/s)        
Selecting previously unselected package handbrake-cli.
(Reading database ... 351992 files and directories currently installed.)
Preparing to unpack .../handbrake-cli_1%3a1.3.3.1-zhb-1ppa1~focal1_amd64.deb ...
Unpacking handbrake-cli (1:1.3.3.1-zhb-1ppa1~focal1) ...
Setting up handbrake-cli (1:1.3.3.1-zhb-1ppa1~focal1) ...

After this, the application is installed and we can run it by clicking on its exotically looking icon:


This is the main window of the application:


To rip the DVD disc we need to click on Open Source icon and select the DVD drive. Once this is done, HandBrake automatically reads all video sections (titles) from the DVD (these are videos that we can choose from the main menu that is displayed when we play DVD):


All we have to do now is to select a title and press Start. This will rip selected title into a new m4v (mp4) video file on your local disk. This has to be repeated for each title. Job done!

Wednesday, 17 March 2021

How to play DVD disc on Ubuntu

Here is what I needed to do on my PC in order to play a DVD disc. 

I am running the Ubuntu 20.04:

$ sudo lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.2 LTS
Release: 20.04
Codename: focal


I chose to use VLC media player.


VLC installation:

$ sudo apt install vlc
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  liba52-0.7.4 libaribb24-0 libbasicusageenvironment1 libcddb2 libdca0 libdvbpsi10 libdvdnav4 libdvdread7 libebml4v5 libfaad2 libgroupsock8 libixml10 libkate1 liblivemedia77 libmad0
  libmatroska6v5 libmpcdec6 libmpeg2-4 libopenmpt-modplug1 libplacebo7 libproxy-tools libresid-builder0c2a libsdl-image1.2 libsidplay2 libspatialaudio0 libsrt1 libssh2-1 libupnp13
  libusageenvironment3 libva-wayland2 libvlc-bin libvlc5 libvlccore9 vlc-bin vlc-data vlc-l10n vlc-plugin-base vlc-plugin-notify vlc-plugin-qt vlc-plugin-samba vlc-plugin-skins2
  vlc-plugin-video-output vlc-plugin-video-splitter vlc-plugin-visualization
Suggested packages:
  libdvdcss2
The following NEW packages will be installed
  liba52-0.7.4 libaribb24-0 libbasicusageenvironment1 libcddb2 libdca0 libdvbpsi10 libdvdnav4 libdvdread7 libebml4v5 libfaad2 libgroupsock8 libixml10 libkate1 liblivemedia77 libmad0
  libmatroska6v5 libmpcdec6 libmpeg2-4 libopenmpt-modplug1 libplacebo7 libproxy-tools libresid-builder0c2a libsdl-image1.2 libsidplay2 libspatialaudio0 libsrt1 libssh2-1 libupnp13
  libusageenvironment3 libva-wayland2 libvlc-bin libvlc5 libvlccore9 vlc vlc-bin vlc-data vlc-l10n vlc-plugin-base vlc-plugin-notify vlc-plugin-qt vlc-plugin-samba vlc-plugin-skins2
  vlc-plugin-video-output vlc-plugin-video-splitter vlc-plugin-visualization
0 to upgrade, 45 to newly install, 0 to remove and 18 not to upgrade.
Need to get 13.7 MB of archives.
After this operation, 71.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 liba52-0.7.4 amd64 0.7.4-20 [30.5 kB]
Get:2 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 libaribb24-0 amd64 1.0.3-2 [26.9 kB]
Get:3 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 libusageenvironment3 amd64 2020.01.19-1build1 [6,960 B]
Get:4 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 libbasicusageenvironment1 amd64 2020.01.19-1build1 [15.2 kB]
Get:5 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 libcddb2 amd64 1.3.2-6fakesync1 [34.3 kB]
Get:6 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 libdvbpsi10 amd64 1.3.3-1 [47.1 kB]
Get:7 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 libdvdread7 amd64 6.1.0+really6.0.2-1 [49.9 kB]
Get:8 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 libdvdnav4 amd64 6.0.1-1build1 [39.0 kB]
Get:9 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 libebml4v5 amd64 1.3.10-1build1 [49.1 kB]
Get:10 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 libfaad2 amd64 2.9.1-1 [154 kB]
Get:11 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 libgroupsock8 amd64 2020.01.19-1build1 [20.7 kB]
Get:12 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 libixml10 amd64 1:1.8.4-2ubuntu2 [23.6 kB]
Get:13 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 libkate1 amd64 0.4.1-11build1 [39.4 kB]
Get:14 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 liblivemedia77 amd64 2020.01.19-1build1 [318 kB]
Get:15 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 libmad0 amd64 0.15.1b-10ubuntu1 [63.1 kB]
Get:16 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 libmatroska6v5 amd64 1.5.2-3build1 [124 kB]
Get:17 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 libmpcdec6 amd64 2:0.1~r495-2 [32.4 kB]
Get:18 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 libmpeg2-4 amd64 0.5.1-9 [50.7 kB]
Get:19 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 libopenmpt-modplug1 amd64 0.4.11-1build1 [20.0 kB]
Get:20 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 libplacebo7 amd64 1.7.0-2 [721 kB]
Get:21 http://gb.archive.ubuntu.com/ubuntu focal-updates/universe amd64 libproxy-tools amd64 0.4.15-10ubuntu1.2 [5,440 B]
Get:22 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 libresid-builder0c2a amd64 2.1.1-15ubuntu2 [31.3 kB]
Get:23 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 libsdl-image1.2 amd64 1.2.12-12 [30.0 kB]
Get:24 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 libsidplay2 amd64 2.1.1-15ubuntu2 [89.2 kB]
Get:25 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 libspatialaudio0 amd64 0.3.0+git20180730+dfsg1-2build1 [32.9 kB]
Get:26 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 libsrt1 amd64 1.4.0-1build1 [236 kB]
Get:27 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 libssh2-1 amd64 1.8.0-2.1build1 [75.4 kB]
Get:28 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 libupnp13 amd64 1:1.8.4-2ubuntu2 [87.9 kB]
Get:29 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 libva-wayland2 amd64 2.7.0-2 [8,924 B]
Get:30 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 libvlccore9 amd64 3.0.9.2-1 [428 kB]
Get:31 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 libvlc5 amd64 3.0.9.2-1 [65.8 kB]
Get:32 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 libvlc-bin amd64 3.0.9.2-1 [17.1 kB]
Get:33 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 vlc-bin amd64 3.0.9.2-1 [54.2 kB]
Get:34 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 vlc-data all 3.0.9.2-1 [339 kB]
Get:35 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 libdca0 amd64 0.0.6-1 [91.0 kB]
Get:36 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 vlc-plugin-base amd64 3.0.9.2-1 [2,854 kB]
Get:37 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 vlc-plugin-qt amd64 3.0.9.2-1 [1,054 kB]
Get:38 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 vlc-plugin-video-output amd64 3.0.9.2-1 [160 kB]
Get:39 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 vlc amd64 3.0.9.2-1 [34.0 kB]
Get:40 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 vlc-l10n all 3.0.9.2-1 [5,584 kB]
Get:41 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 vlc-plugin-notify amd64 3.0.9.2-1 [18.2 kB]
Get:42 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 vlc-plugin-samba amd64 3.0.9.2-1 [18.8 kB]
Get:43 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 vlc-plugin-skins2 amd64 3.0.9.2-1 [471 kB]
Get:44 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 vlc-plugin-video-splitter amd64 3.0.9.2-1 [32.4 kB]
Get:45 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 vlc-plugin-visualization amd64 3.0.9.2-1 [36.2 kB]
Fetched 13.7 MB in 4s (3,493 kB/s)                    
Extract templates from packages: 100%
Selecting previously unselected package liba52-0.7.4:amd64.
(Reading database ... 350491 files and directories currently installed.)
Preparing to unpack .../00-liba52-0.7.4_0.7.4-20_amd64.deb ...
Unpacking liba52-0.7.4:amd64 (0.7.4-20) ...
Selecting previously unselected package libaribb24-0:amd64.
Preparing to unpack .../01-libaribb24-0_1.0.3-2_amd64.deb ...
Unpacking libaribb24-0:amd64 (1.0.3-2) ...
Selecting previously unselected package libusageenvironment3:amd64.
Preparing to unpack .../02-libusageenvironment3_2020.01.19-1build1_amd64.deb ...
Unpacking libusageenvironment3:amd64 (2020.01.19-1build1) ...
Selecting previously unselected package libbasicusageenvironment1:amd64.
Preparing to unpack .../03-libbasicusageenvironment1_2020.01.19-1build1_amd64.deb ...
Unpacking libbasicusageenvironment1:amd64 (2020.01.19-1build1) ...
Selecting previously unselected package libcddb2.
Preparing to unpack .../04-libcddb2_1.3.2-6fakesync1_amd64.deb ...
Unpacking libcddb2 (1.3.2-6fakesync1) ...
Selecting previously unselected package libdvbpsi10:amd64.
Preparing to unpack .../05-libdvbpsi10_1.3.3-1_amd64.deb ...
Unpacking libdvbpsi10:amd64 (1.3.3-1) ...
Selecting previously unselected package libdvdread7:amd64.
Preparing to unpack .../06-libdvdread7_6.1.0+really6.0.2-1_amd64.deb ...
Unpacking libdvdread7:amd64 (6.1.0+really6.0.2-1) ...
Selecting previously unselected package libdvdnav4:amd64.
Preparing to unpack .../07-libdvdnav4_6.0.1-1build1_amd64.deb ...
Unpacking libdvdnav4:amd64 (6.0.1-1build1) ...
Selecting previously unselected package libebml4v5:amd64.
Preparing to unpack .../08-libebml4v5_1.3.10-1build1_amd64.deb ...
Unpacking libebml4v5:amd64 (1.3.10-1build1) ...
Selecting previously unselected package libfaad2:amd64.
Preparing to unpack .../09-libfaad2_2.9.1-1_amd64.deb ...
Unpacking libfaad2:amd64 (2.9.1-1) ...
Selecting previously unselected package libgroupsock8:amd64.
Preparing to unpack .../10-libgroupsock8_2020.01.19-1build1_amd64.deb ...
Unpacking libgroupsock8:amd64 (2020.01.19-1build1) ...
Selecting previously unselected package libixml10:amd64.
Preparing to unpack .../11-libixml10_1%3a1.8.4-2ubuntu2_amd64.deb ...
Unpacking libixml10:amd64 (1:1.8.4-2ubuntu2) ...
Selecting previously unselected package libkate1:amd64.
Preparing to unpack .../12-libkate1_0.4.1-11build1_amd64.deb ...
Unpacking libkate1:amd64 (0.4.1-11build1) ...
Selecting previously unselected package liblivemedia77:amd64.
Preparing to unpack .../13-liblivemedia77_2020.01.19-1build1_amd64.deb ...
Unpacking liblivemedia77:amd64 (2020.01.19-1build1) ...
Selecting previously unselected package libmad0:amd64.
Preparing to unpack .../14-libmad0_0.15.1b-10ubuntu1_amd64.deb ...
Unpacking libmad0:amd64 (0.15.1b-10ubuntu1) ...
Selecting previously unselected package libmatroska6v5:amd64.
Preparing to unpack .../15-libmatroska6v5_1.5.2-3build1_amd64.deb ...
Unpacking libmatroska6v5:amd64 (1.5.2-3build1) ...
Selecting previously unselected package libmpcdec6:amd64.
Preparing to unpack .../16-libmpcdec6_2%3a0.1~r495-2_amd64.deb ...
Unpacking libmpcdec6:amd64 (2:0.1~r495-2) ...
Selecting previously unselected package libmpeg2-4:amd64.
Preparing to unpack .../17-libmpeg2-4_0.5.1-9_amd64.deb ...
Unpacking libmpeg2-4:amd64 (0.5.1-9) ...
Selecting previously unselected package libopenmpt-modplug1:amd64.
Preparing to unpack .../18-libopenmpt-modplug1_0.4.11-1build1_amd64.deb ...
Unpacking libopenmpt-modplug1:amd64 (0.4.11-1build1) ...
Selecting previously unselected package libplacebo7:amd64.
Preparing to unpack .../19-libplacebo7_1.7.0-2_amd64.deb ...
Unpacking libplacebo7:amd64 (1.7.0-2) ...
Selecting previously unselected package libproxy-tools.
Preparing to unpack .../20-libproxy-tools_0.4.15-10ubuntu1.2_amd64.deb ...
Unpacking libproxy-tools (0.4.15-10ubuntu1.2) ...
Selecting previously unselected package libresid-builder0c2a.
Preparing to unpack .../21-libresid-builder0c2a_2.1.1-15ubuntu2_amd64.deb ...
Unpacking libresid-builder0c2a (2.1.1-15ubuntu2) ...
Selecting previously unselected package libsdl-image1.2:amd64.
Preparing to unpack .../22-libsdl-image1.2_1.2.12-12_amd64.deb ...
Unpacking libsdl-image1.2:amd64 (1.2.12-12) ...
Selecting previously unselected package libsidplay2.
Preparing to unpack .../23-libsidplay2_2.1.1-15ubuntu2_amd64.deb ...
Unpacking libsidplay2 (2.1.1-15ubuntu2) ...
Selecting previously unselected package libspatialaudio0:amd64.
Preparing to unpack .../24-libspatialaudio0_0.3.0+git20180730+dfsg1-2build1_amd64.deb ...
Unpacking libspatialaudio0:amd64 (0.3.0+git20180730+dfsg1-2build1) ...
Selecting previously unselected package libsrt1:amd64.
Preparing to unpack .../25-libsrt1_1.4.0-1build1_amd64.deb ...
Unpacking libsrt1:amd64 (1.4.0-1build1) ...
Selecting previously unselected package libssh2-1:amd64.
Preparing to unpack .../26-libssh2-1_1.8.0-2.1build1_amd64.deb ...
Unpacking libssh2-1:amd64 (1.8.0-2.1build1) ...
Selecting previously unselected package libupnp13:amd64.
Preparing to unpack .../27-libupnp13_1%3a1.8.4-2ubuntu2_amd64.deb ...
Unpacking libupnp13:amd64 (1:1.8.4-2ubuntu2) ...
Selecting previously unselected package libva-wayland2:amd64.
Preparing to unpack .../28-libva-wayland2_2.7.0-2_amd64.deb ...
Unpacking libva-wayland2:amd64 (2.7.0-2) ...
Selecting previously unselected package libvlccore9:amd64.
Preparing to unpack .../29-libvlccore9_3.0.9.2-1_amd64.deb ...
Unpacking libvlccore9:amd64 (3.0.9.2-1) ...
Selecting previously unselected package libvlc5:amd64.
Preparing to unpack .../30-libvlc5_3.0.9.2-1_amd64.deb ...
Unpacking libvlc5:amd64 (3.0.9.2-1) ...
Selecting previously unselected package libvlc-bin:amd64.
Preparing to unpack .../31-libvlc-bin_3.0.9.2-1_amd64.deb ...
Unpacking libvlc-bin:amd64 (3.0.9.2-1) ...
Selecting previously unselected package vlc-bin.
Preparing to unpack .../32-vlc-bin_3.0.9.2-1_amd64.deb ...
Unpacking vlc-bin (3.0.9.2-1) ...
Selecting previously unselected package vlc-data.
Preparing to unpack .../33-vlc-data_3.0.9.2-1_all.deb ...
Unpacking vlc-data (3.0.9.2-1) ...
Selecting previously unselected package libdca0:amd64.
Preparing to unpack .../34-libdca0_0.0.6-1_amd64.deb ...
Unpacking libdca0:amd64 (0.0.6-1) ...
Selecting previously unselected package vlc-plugin-base:amd64.
Preparing to unpack .../35-vlc-plugin-base_3.0.9.2-1_amd64.deb ...
Unpacking vlc-plugin-base:amd64 (3.0.9.2-1) ...
Selecting previously unselected package vlc-plugin-qt:amd64.
Preparing to unpack .../36-vlc-plugin-qt_3.0.9.2-1_amd64.deb ...
Unpacking vlc-plugin-qt:amd64 (3.0.9.2-1) ...
Selecting previously unselected package vlc-plugin-video-output:amd64.
Preparing to unpack .../37-vlc-plugin-video-output_3.0.9.2-1_amd64.deb ...
Unpacking vlc-plugin-video-output:amd64 (3.0.9.2-1) ...
Selecting previously unselected package vlc.
Preparing to unpack .../38-vlc_3.0.9.2-1_amd64.deb ...
Unpacking vlc (3.0.9.2-1) ...
Selecting previously unselected package vlc-l10n.
Preparing to unpack .../39-vlc-l10n_3.0.9.2-1_all.deb ...
Unpacking vlc-l10n (3.0.9.2-1) ...
Selecting previously unselected package vlc-plugin-notify:amd64.
Preparing to unpack .../40-vlc-plugin-notify_3.0.9.2-1_amd64.deb ...
Unpacking vlc-plugin-notify:amd64 (3.0.9.2-1) ...
Selecting previously unselected package vlc-plugin-samba:amd64.
Preparing to unpack .../41-vlc-plugin-samba_3.0.9.2-1_amd64.deb ...
Unpacking vlc-plugin-samba:amd64 (3.0.9.2-1) ...
Selecting previously unselected package vlc-plugin-skins2:amd64.
Preparing to unpack .../42-vlc-plugin-skins2_3.0.9.2-1_amd64.deb ...
Unpacking vlc-plugin-skins2:amd64 (3.0.9.2-1) ...
Selecting previously unselected package vlc-plugin-video-splitter:amd64.
Preparing to unpack .../43-vlc-plugin-video-splitter_3.0.9.2-1_amd64.deb ...
Unpacking vlc-plugin-video-splitter:amd64 (3.0.9.2-1) ...
Selecting previously unselected package vlc-plugin-visualization:amd64.
Preparing to unpack .../44-vlc-plugin-visualization_3.0.9.2-1_amd64.deb ...
Unpacking vlc-plugin-visualization:amd64 (3.0.9.2-1) ...
Setting up libsdl-image1.2:amd64 (1.2.12-12) ...
Setting up libkate1:amd64 (0.4.1-11build1) ...
Setting up libdvbpsi10:amd64 (1.3.3-1) ...
Setting up libebml4v5:amd64 (1.3.10-1build1) ...
Setting up libdvdread7:amd64 (6.1.0+really6.0.2-1) ...
Setting up libspatialaudio0:amd64 (0.3.0+git20180730+dfsg1-2build1) ...
Setting up vlc-l10n (3.0.9.2-1) ...
Setting up libmpeg2-4:amd64 (0.5.1-9) ...
Setting up libaribb24-0:amd64 (1.0.3-2) ...
Setting up libusageenvironment3:amd64 (2020.01.19-1build1) ...
Setting up libmpcdec6:amd64 (2:0.1~r495-2) ...
Setting up libcddb2 (1.3.2-6fakesync1) ...
Setting up liba52-0.7.4:amd64 (0.7.4-20) ...
Setting up libmatroska6v5:amd64 (1.5.2-3build1) ...
Setting up libixml10:amd64 (1:1.8.4-2ubuntu2) ...
Setting up libresid-builder0c2a (2.1.1-15ubuntu2) ...
Setting up libfaad2:amd64 (2.9.1-1) ...
Setting up libbasicusageenvironment1:amd64 (2020.01.19-1build1) ...
Setting up libvlccore9:amd64 (3.0.9.2-1) ...
Setting up libsidplay2 (2.1.1-15ubuntu2) ...
Setting up libva-wayland2:amd64 (2.7.0-2) ...
Setting up libmad0:amd64 (0.15.1b-10ubuntu1) ...
Setting up libsrt1:amd64 (1.4.0-1build1) ...
Setting up vlc-plugin-qt:amd64 (3.0.9.2-1) ...
Setting up libdca0:amd64 (0.0.6-1) ...
Setting up libssh2-1:amd64 (1.8.0-2.1build1) ...
Setting up libopenmpt-modplug1:amd64 (0.4.11-1build1) ...
Setting up vlc-data (3.0.9.2-1) ...
Setting up libplacebo7:amd64 (1.7.0-2) ...
Setting up vlc-plugin-notify:amd64 (3.0.9.2-1) ...
Setting up libdvdnav4:amd64 (6.0.1-1build1) ...
Setting up libproxy-tools (0.4.15-10ubuntu1.2) ...
Setting up vlc-plugin-video-output:amd64 (3.0.9.2-1) ...
Setting up vlc-plugin-samba:amd64 (3.0.9.2-1) ...
Setting up libgroupsock8:amd64 (2020.01.19-1build1) ...
Setting up vlc-plugin-skins2:amd64 (3.0.9.2-1) ...
Setting up vlc-plugin-video-splitter:amd64 (3.0.9.2-1) ...
Setting up libvlc5:amd64 (3.0.9.2-1) ...
Setting up libupnp13:amd64 (1:1.8.4-2ubuntu2) ...
Setting up vlc-plugin-visualization:amd64 (3.0.9.2-1) ...
Setting up libvlc-bin:amd64 (3.0.9.2-1) ...
Setting up liblivemedia77:amd64 (2020.01.19-1build1) ...
Setting up vlc-bin (3.0.9.2-1) ...
Setting up vlc-plugin-base:amd64 (3.0.9.2-1) ...
Setting up vlc (3.0.9.2-1) ...
Processing triggers for desktop-file-utils (0.24-1ubuntu3) ...
Processing triggers for mime-support (3.64ubuntu1) ...
Processing triggers for hicolor-icon-theme (0.17-2) ...
Processing triggers for gnome-menus (3.36.0-1ubuntu1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
/sbin/ldconfig.real: /usr/local/cuda-8.0/targets/x86_64-linux/lib/libcudnn.so.5 is not a symbolic link

Processing triggers for man-db (2.9.1-1) ...
Processing triggers for bamfdaemon (0.5.3+18.04.20180207.2-0ubuntu2) ...
Rebuilding /usr/share/applications/bamf-2.index...
Processing triggers for libvlc-bin:amd64 (3.0.9.2-1) ...


It was necessary to install several packages. 
 
libdvd-pkg package provides libraries that are needed for playing video DVDs with a media player (such as VLC, SMplayer, Totem, etc.). 
 
libdvdnav4 is a DVD navigation library, which provides an interface to the advanced features of DVDs, like menus and navigation. It contains the VM and other parts useful for writing DVD players.
 
libdvdread7 is a package for reading DVDs.

$ sudo apt install libdvd-pkg libdvdnav4 libdvdread7 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libdvdnav4 is already the newest version (6.0.1-1build1).
libdvdnav4 set to manually installed.
libdvdread7 is already the newest version (6.1.0+really6.0.2-1).
libdvdread7 set to manually installed.
The following NEW packages will be installed
  libdvd-pkg
0 to upgrade, 1 to newly install, 0 to remove and 18 not to upgrade.
Need to get 14.9 kB of archives.
After this operation, 80.9 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://gb.archive.ubuntu.com/ubuntu focal/multiverse amd64 libdvd-pkg all 1.4.2-1-1 [14.9 kB]
Fetched 14.9 kB in 0s (212 kB/s)    
Preconfiguring packages ...
Selecting previously unselected package libdvd-pkg.
(Reading database ... 351510 files and directories currently installed.)
Preparing to unpack .../libdvd-pkg_1.4.2-1-1_all.deb ...
Unpacking libdvd-pkg (1.4.2-1-1) ...
Setting up libdvd-pkg (1.4.2-1-1) ...
libdvd-pkg: dpkg database is locked. You may need to use command "sudo dpkg-reco
nfigure libdvd-pkg".
libdvd-pkg: Building and installation of package(s) [libdvdcss2 libdvdcss-dev] p
ostponed till after next APT operation.





$ sudo dpkg-reconfigure libdvd-pkg
libdvd-pkg: Downloading orig source...
I: libdvdcss_1.4.2
/usr/bin/wget --tries=3 --timeout=40 --read-timeout=40 --continue -O libdvdcss_1.4.2.orig.tar.bz2 \
          http://download.videolan.org/pub/libdvdcss/1.4.2/libdvdcss-1.4.2.tar.bz2 \
        || /usr/bin/uscan --noconf --verbose --rename --destdir=/usr/src/libdvd-pkg --check-dirname-level=0 --force-download --download-current-version /usr/share/libdvd-pkg/debian
--2021-03-17 08:02:21--  http://download.videolan.org/pub/libdvdcss/1.4.2/libdvdcss-1.4.2.tar.bz2
Resolving download.videolan.org (download.videolan.org)... 2a01:e0d:1:3:58bf:fa02:c0de:5, 213.36.253.2
Connecting to download.videolan.org (download.videolan.org)|2a01:e0d:1:3:58bf:fa02:c0de:5|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 366824 (358K) [application/octet-stream]
Saving to: ‘libdvdcss_1.4.2.orig.tar.bz2’

libdvdcss_1.4.2.orig.tar 100%[=================================>] 358.23K  2.27MB/s    in 0.2s    

2021-03-17 08:02:22 (2.27 MB/s) - ‘libdvdcss_1.4.2.orig.tar.bz2’ saved [366824/366824]

libdvd-pkg: Checking orig.tar integrity...
/usr/src/libdvd-pkg/libdvdcss_1.4.2.orig.tar.bz2: OK
libdvd-pkg: Unpacking and configuring...
libdvd-pkg: Building the package... (it may take a while)
libdvd-pkg: Build log will be saved to /usr/src/libdvd-pkg/libdvdcss2_1.4.2-1~local_amd64.build
Current: =ep
Bounding set =cap_chown,cap_dac_override,cap_fowner,cap_wake_alarm,cap_block_suspend,cap_audit_read
Ambient set =
Securebits: 024/0x14/5'b10100
 secure-noroot: no (unlocked)
 secure-no-suid-fixup: yes (unlocked)
 secure-keep-caps: yes (unlocked)
 secure-no-ambient-raise: no (unlocked)
uid=0(root) euid=0(root)
gid=0(root)
groups=0(root)
Guessed mode: UNCERTAIN (0)
libdvd-pkg: Installing...
Selecting previously unselected package libdvdcss-dev:amd64.
(Reading database ... 351541 files and directories currently installed.)
Preparing to unpack .../libdvdcss-dev_1.4.2-1~local_amd64.deb ...
Unpacking libdvdcss-dev:amd64 (1.4.2-1~local) ...
Selecting previously unselected package libdvdcss2:amd64.
Preparing to unpack .../libdvdcss2_1.4.2-1~local_amd64.deb ...
Unpacking libdvdcss2:amd64 (1.4.2-1~local) ...
Setting up libdvdcss2:amd64 (1.4.2-1~local) ...
Setting up libdvdcss-dev:amd64 (1.4.2-1~local) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
/sbin/ldconfig.real: /usr/local/cuda-8.0/targets/x86_64-linux/lib/libcudnn.so.5 is not a symbolic link


Upon installing dependencies, I was able to open and play DVD disc:






References:




Thursday, 17 December 2020

Webcam capture with ffmpeg and OpenCV from Jupyter Notebook

I want to share here my experience with using OpenCV and ffmpeg to capture a webcam output.


Setup:
  • Jupyter notebook running in jupyter-lab
  • Ubuntu 20.04
  • USB web camera
Goal:
  • Capture and display frames from the webcam

OpenCV: Video I/O with OpenCV Overview says that OpenCV: cv::VideoCapture Class calls video I/O backends (APIs) depending on which one is available.

To find out what backends (VideoCaptureAPIs) are available we can use the following code:

import cv2

# cv2a.videoio_registry.getBackends() returns list of all available backends.
availableBackends = [cv2.videoio_registry.getBackendName(b) for b in cv2.videoio_registry.getBackends()]
print(availableBackends)

# Returns list of available backends which works via cv::VideoCapture(int index)
availableCameraBackends = [cv2.videoio_registry.getBackendName(b) for b in cv2.videoio_registry.getCameraBackends()]
print(availableBackends)

The output in my case was: 

['FFMPEG', 'GSTREAMER', 'CV_IMAGES', 'CV_MJPEG']
['FFMPEG', 'GSTREAMER', 'CV_IMAGES', 'CV_MJPEG']

Let's see what is each of these backends:

• FFMPEG is a multimedia framework which can record, convert and stream audio and video.

It contains libavcodec, libavutil, libavformat, libavfilter, libavdevice, libswscale and libswresample which can be used by applications. As well as ffmpeg, ffplay and ffprobe which can be used by end users for transcoding and playing.

• GSTREAMER is a pipeline-based multimedia framework with similar capabilities as ffmpeg.

• CV_IMAGES -  OpenCV Image Sequence (e.g. img_%02d.jpg). Matches cv2.CAP_IMAGES API ID.

• CV_MJPEG - Built-in OpenCV MotionJPEG codec (used for reading video files). Matches cv2.CAP_OPENCV_MJPEG video capture API.

I was surprised to see GSTREAMER listed above as VideoCaptureAPIs documentation says

Backends are available only if they have been built with your OpenCV binaries. 

...and OpenCV package installed in my environment was built only with FFMPEG support:

>>> import cv2
>>> cv2.getBuildInformation()
...
Video I/O:\n    DC1394:                      NO\n    FFMPEG:                      YES\n      avcodec:                   YES (58.35.100)\n      avformat:                  YES (58.20.100)\n      avutil:                    YES (56.22.100)\n      swscale:                   YES (5.3.100)\n      avresample:                YES (4.0.0)\n\n  
...

...which can also be verifed by looking the cmake config in the repository (opencv-feedstock/build.sh at master · conda-forge/opencv-feedstock):

-DWITH_FFMPEG=1     \
-DWITH_GSTREAMER=0  \

Although my conda environment contained all relevant packages:

(my-env) $ conda list | grep 'opencv\|ffmpeg\|gstreamer'
ffmpeg                    4.1.3                h167e202_0    conda-forge
gstreamer                 1.14.5               h36ae1b5_2    conda-forge
opencv                    4.1.0            py36h79d2e43_1    conda-forge

...it is important to know that having ffmpeg and gstreamer packages installed means only that we have their binaries installed (executables and .so libraries) but not Python bindings (modules) or their OpenCV plugins. We are able to launch these applications from terminal but can't import them in Python code.

I tried to force using FFMPEG:

import cv2

deviceId = "/dev/video0"

# videoCaptureApi = cv2.CAP_ANY       # autodetect default API
videoCaptureApi = cv2.CAP_FFMPEG
# videoCaptureApi = cv2.CAP_GSTREAMER 
cap = cv2.VideoCapture("/dev/video2", videoCaptureApi)

cap = cv2.VideoCapture(deviceId)
cap.open(deviceId)
if not cap.isOpened():
    raise RuntimeError("ERROR! Unable to open camera")

try:
    while True:
        ret, frame = cap.read()
        cv2.imshow('frame', frame)
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break
finally:        
    cap.release()
    cv2.destroyAllWindows()

...but cell execution would fail with:

RuntimeError: ERROR! Unable to open camera

I checked ($ v4l2-ctl --list-devices) - my webcam was indeed with index 2. As this was failing at the very beginning I decided to open python interpreter console and debug there only the isolated code snippet which opens the camera:

(my-env) $ export OPENCV_LOG_LEVEL=DEBUG; export OPENCV_VIDEOIO_DEBUG=1

(my-env) $ python 
Python 3.6.6 | packaged by conda-forge | (default, Oct 12 2018, 14:43:46) 
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cap = cv2.VideoCapture("/dev/video2", cv2.CAP_FFMPEG)
[ WARN:0] VIDEOIO(FFMPEG): trying capture filename='/dev/video2' ...
[ WARN:0] VIDEOIO(FFMPEG): can't create capture

I also tried to force using Gstreamer to no avail (which was expected):

>>> cap = cv2.VideoCapture("/dev/video2", cv2.CAP_GSTREAMER)
[ WARN:0] VIDEOIO(GSTREAMER): trying capture filename='/dev/video2' ...
[ INFO:0] VideoIO pluigin (GSTREAMER): glob is 'libopencv_videoio_gstreamer*.so', 1 location(s)
[ INFO:0]     - /home/bojan/anaconda3/envs/my-env/lib/python3.6/site-packages/../..: 0
[ INFO:0] Found 0 plugin(s) for GSTREAMER
[ WARN:0] VIDEOIO(GSTREAMER): backend is not available (plugin is missing, or can't be loaded due dependencies or it is not compatible)

Indeed ~/anaconda3/envs/my-env/lib did not contain ffmpeg plugin (libopencv_videoio_ffmpeg*.so files) or Gstreamer plugin (libopencv_videoio_gstreamer*.so files).

These plugins are installed only if OpenCV is build with following CMake options:

- DWITH_FFMPEG=1     \
-DVIDEOIO_PLUGIN_LIST=ffmpeg

...or (for Gstreamer):

-DWITH_GSTREAMER=1 \
-DVIDEOIO_PLUGIN_LIST=gstreamer \

...and apart from WITH_FFMPEG no other were used in the cmake config that was used to build OpenCV package installed in my environment.

As I didn't want to compile OpenCV myself but to achieve my goal with what I have I decided to see if I can run ffmpg process to stream camera output into a pipe and then read the binary information from it and convert it into frames:

import os
import tempfile
import subprocess
import cv2
import numpy as np

# To get this path execute:
#    $ which ffmpeg
FFMPEG_BIN = '/home/bojan/anaconda3/envs/my-env/bin/ffmpeg'


# To find allowed formats for the specific camera:
#    $ ffmpeg -f v4l2 -list_formats all -i /dev/video3
#    ...
#    [video4linux2,v4l2 @ 0x5608ac90af40] Raw: yuyv422: YUYV 4:2:2: 640x480 1280x720 960x544 800x448 640x360 424x240 352x288 320x240 800x600 176x144 160x120 1280x800
#    ...

def run_ffmpeg(fifo_path):
    ffmpg_cmd = [
        FFMPEG_BIN,
        '-i', '/dev/video2',
        '-video_size', '640x480',
        '-pix_fmt', 'bgr24',        # opencv requires bgr24 pixel format
        '-vcodec', 'rawvideo',
        '-an','-sn',                # disable audio processing
        '-f', 'image2pipe',
        '-',                        # output to go to stdout
    ]
    return subprocess.Popen(ffmpg_cmd, stdout = subprocess.PIPE, bufsize=10**8)

def run_cv_window(process):
    while True:
        # read frame-by-frame
        raw_image = process.stdout.read(640*480*3)
        if raw_image == b'':
            raise RuntimeError("Empty pipe")
        
        # transform the bytes read into a numpy array
        frame =  np.frombuffer(raw_image, dtype='uint8')
        frame = frame.reshape((480,640,3)) # height, width, channels
        if frame is not None:
            cv2.imshow('Video', frame)
        
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break
        process.stdout.flush()
    
    cv2.destroyAllWindows()
    process.terminate()
    print(process.poll())

def run():
    ffmpeg_process = run_ffmpeg()
    run_cv_window(ffmpeg_process)

run()

Et voila! I got the camera capture from Python notebook thanks to ffmpeg and OpenCV.



Monday, 29 July 2019

How to play .mp4 videos on Ubuntu

Install the following packages (and accept EULAs):

$ sudo apt-get update
$ sudo apt install libdvdnav4 libdvdread4 gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly libdvd-pkg
$ sudo dpkg-reconfigure libdvd-pkg
$ sudo apt install ubuntu-restricted-extras

(Tested on Ubuntu 18.04)

Sunday, 4 January 2015

How to rotate MOV video file


Free, cross-platform and easy to use tool is FFmpeg.

On Windows 


Go to Zeranoe FFmpeg builds and download the latest build which is a compressed file (e.g. ffmpeg-20150103-git-504267f-win64-static.7z). Unpack it and open FF Prompt window by clicking on file ff-prompt.bat.

In the prompt type the following command and hit the Enter:

>ffmpeg -i "C:\Users\Bojan\Downloads\IMG_3855.MOV" -vf "transpose=1" "C:\Users
\Bojan\Downloads\IMG_3855_rotated.MOV"
ffmpeg version N-68826-g504267f Copyright (c) 2000-2014 the FFmpeg developers
built on Jan 2 2015 22:12:34 with gcc 4.9.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --
enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-lib
modplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrw
b --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinge
r --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --en
able-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis
--enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-
libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enab
le-zlib
libavutil 54. 16.100 / 54. 16.100
libavcodec 56. 19.100 / 56. 19.100
libavformat 56. 16.102 / 56. 16.102
libavdevice 56. 3.100 / 56. 3.100
libavfilter 5. 6.100 / 5. 6.100
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Users\Bojan\Downloads\IMG_3855.MOV
':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
creation_time : 2015-01-04 15:32:44
Duration: 00:02:12.27, start: 0.000000, bitrate: 773 kb/s
Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp,
62 kb/s (default)
Metadata:
rotate : 90
creation_time : 2015-01-04 15:32:45
handler_name : Core Media Data Handler
Stream #0:1(und): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p, 480x3
60, 707 kb/s, 30 fps, 30 tbr, 600 tbn, 1200 tbc (default)
Metadata:
rotate : 90
creation_time : 2015-01-04 15:32:45
handler_name : Core Media Data Handler
encoder : H.264
Side data:
displaymatrix: rotation of -90.00 degrees
[libx264 @ 0000000002c45fe0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
[libx264 @ 0000000002c45fe0] profile High, level 3.0
[libx264 @ 0000000002c45fe0] 264 - core 144 r2525 40bb568 - H.264/MPEG-4 AVC cod
ec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 r
ef=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed
_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pski
p=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 deci
mate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_
adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=2
5 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.6
0 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mov, to 'C:\Users\Bojan\Downloads\IMG_3855_rotated.MOV':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
encoder : Lavf56.16.102
Stream #0:0(und): Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 360x48
0, q=-1--1, 30 fps, 15360 tbn, 30 tbc (default)
Metadata:
rotate : 90
creation_time : 2015-01-04 15:32:45
handler_name : Core Media Data Handler
encoder : Lavc56.19.100 libx264
Stream #0:1(und): Audio: aac (libvo_aacenc) (mp4a / 0x6134706D), 44100 Hz, m
ono, s16, 128 kb/s (default)
Metadata:
rotate : 90
creation_time : 2015-01-04 15:32:45
handler_name : Core Media Data Handler
encoder : Lavc56.19.100 libvo_aacenc
Stream mapping:
Stream #0:1 -> #0:0 (h264 (native) -> h264 (libx264))
Stream #0:0 -> #0:1 (aac (native) -> aac (libvo_aacenc))
Press [q] to stop, [?] for help
frame= 73 fps=0.0 q=29.0 size= 53kB time=00:00:03.53 bitrate= 122.3kbits/
frame= 114 fps=111 q=29.0 size= 162kB time=00:00:04.90 bitrate= 270.6kbits/
frame= 151 fps= 98 q=29.0 size= 282kB time=00:00:06.14 bitrate= 376.6kbits/

etc...

frame= 3966 fps= 62 q=29.0 size= 13253kB time=00:02:12.29 bitrate= 820.7kbits/
frame= 3968 fps= 61 q=-1.0 Lsize= 13544kB time=00:02:12.34 bitrate= 838.4kbits
/s
video:11342kB audio:2068kB subtitle:0kB other streams:0kB global headers:0kB mux
ing overhead: 0.998874%
[libx264 @ 0000000002c45fe0] frame I:23 Avg QP:22.99 size: 11966
[libx264 @ 0000000002c45fe0] frame P:2549 Avg QP:26.67 size: 3857
[libx264 @ 0000000002c45fe0] frame B:1396 Avg QP:29.93 size: 1079
[libx264 @ 0000000002c45fe0] consecutive B-frames: 32.7% 58.9% 7.0% 1.4%
[libx264 @ 0000000002c45fe0] mb I I16..4: 12.0% 63.2% 24.7%
[libx264 @ 0000000002c45fe0] mb P I16..4: 2.5% 6.0% 2.7% P16..4: 28.7% 20.4
% 9.9% 0.0% 0.0% skip:29.7%
[libx264 @ 0000000002c45fe0] mb B I16..4: 0.3% 0.2% 0.2% B16..8: 35.4% 11.9
% 2.0% direct: 1.9% skip:48.0% L0:51.5% L1:42.8% BI: 5.7%
[libx264 @ 0000000002c45fe0] 8x8 transform intra:53.3% inter:48.8%
[libx264 @ 0000000002c45fe0] coded y,uvDC,uvAC intra: 50.4% 35.4% 3.6% inter: 17
.5% 9.8% 0.3%
[libx264 @ 0000000002c45fe0] i16 v,h,dc,p: 55% 22% 9% 14%
[libx264 @ 0000000002c45fe0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 27% 19% 26% 3% 4%
5% 6% 4% 6%
[libx264 @ 0000000002c45fe0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 36% 16% 26% 3% 3%
4% 4% 4% 4%
[libx264 @ 0000000002c45fe0] i8c dc,h,v,p: 62% 11% 25% 2%
[libx264 @ 0000000002c45fe0] Weighted P-Frames: Y:9.1% UV:2.2%
[libx264 @ 0000000002c45fe0] ref P L0: 77.9% 13.8% 6.1% 2.0% 0.2%
[libx264 @ 0000000002c45fe0] ref B L0: 96.4% 3.5% 0.2%
[libx264 @ 0000000002c45fe0] ref B L1: 99.0% 1.0%
[libx264 @ 0000000002c45fe0] kb/s:702.40

>


Possible values for transpose operation are:

0 = 90 degrees counter-clockwise and vertical flip (default)
1 = 90 degrees clockwise
2 = 90 degrees counter-clockwise
3 = 90 degrees clockwise and vertical flip