Movies are not just simple files, since they have at least some sound tracks. A typical movie has therefore multiple tracks: A video track and two sound tracks to have stereo. To put everything to one single file a container format is required. This container format holds all tracks together. Container formats are:
OGG
AVI
The tracks make use of different codec formats for audio and video. For audio it is mostly mpg3, but for video different codecs are available
DivX
Xvid
MPEG
H264
A good compatibility to have the video running on all kinds of devices is AVI using XVID and a MP3 codec. The selection of codecs are a potential source of incompatibility problems between certain files and applications. So if you get problems with a player try to rip in an other format. Linux uses mostly as default open and license free format, however they do not run well on Windows machines and other devices. To have portable video mpeg seems the way to go.
ffmpeg can easily convert videos:
ffmpeg -i<input>
.avi <output>
.mpg
To see what formats it supports ffmpeg -formats and what codecs: ffmpeg -codecs, or to see the formats ffmpeg -formats
man ffmpeg illustrates that ffmpeg is quite a universal tool.
To rotate 90° clockwise ffmpeg -i <input>
-filter:v transpose=clock -c:v libx264 -preset veryfast -crf 22 -c:a copy -metadata:s:v rotate="" <output>
it also removes meta data since this could also cause the player to rotate the video.
To copy without modifying the recoding ffmpeg -i<input>
.mov -vcodec copy -acodec copy <output>
.avi
To change the pixels ffmpeg -i input.avi -s 1360x768 output.avi
To change the video bitrate using the -b:v option ffmpeg -i input.avi -b:v 2048k output.avi
ffmpeg can also handle other things as inputs than files, as from /dev/video0
ffmpeg -f video4linux2 -i /dev/video0 -s 640x480 test.avi
and alsa ffmpeg -f alsa -ac 1 -i hw:1 -f video4linux2 -i /dev/video0 /tmp/out.mpg or grab an x11 screen ffmpeg -f x11grab -video_size cif -framerate 25 -i :0.0 /tmp/out.mpg
The ffmpeg package comes with other tools as ffprobe <filename>
to see the details of a movie file. ffplay a simple command line player or the streaming server ffstream.
kdenlive is the video editor coming from kde. It is a standalone program since it has not many dependencies to kde
kino video editing software http://www.kinodv.org/. Some terms and concepts must be understood to not get lost. A movie contains different scenes. kino uses a container format not loosing the individual elements of a movie this optimized for editing the movie. However this container format is not that what most users expect from a movie since it is not a simple mp4 or whatever format. The kino container format is to edit the movie and not to just play it. So the container format needs to exported to mp4 or whatever using kino before it is distributed or played. kino supports just dv video format but it is able to convert to it when open a file. In the export a start and stop time can be set so the video can be cut.
A video can highly be compressed to save bandwidth for its transmission and storage size. Video compression must obviously be real-time and requires therefore high processing power. A lot of innovative algorithms and methods have been invented. Currently the H.264 algorithm is the most popular. A video is a sequence of images, typically 24 images a second. Such images are called frames. To make video compression robust sequential frames (12-15) are grouped into Group Of Frames (GOP). The first frame is called I-frame (Intra Coded Frame) and is a regular picture compressed as JPG having macro-blocks of 16*16 pixels that are compressed using a Discrete Cosinus Transformation (DCT). Since the following frames do not differ a lot, they can be highly compressed. Those frames contain just the color and intensity difference of the macro-blocks from the adjacent frames. P-frames (Prediction-Frames) are inserted that are considering differences to the preceding I-frame or P-frame. The H.264 codec goes one step ahead and considers in its B-frames (Bidirectional-Prediction-Frames) the difference to up to 16 preceding and following frames. B-frames are therefore up to 20% smaller than P-frames.
For video for Linux see https://linuxtv.org/downloads/v4l-dvb-apis/intro.html For Gentoo Linux make sure the v4l use flag is set to get user space support. In the user space there is the library libv4l and different plugins and tools from v4l-utils as qv4l2
In the kernel space there are many drivers.
There are different ways how the picture comes to the screen:
Grab and display: grab picture store it and than move it to graphic card
XVideo: direct to graphic cards memory
OpenGL: as Polygons. GLX is the X implementation of OpenGL. With DRI (Direct Rendering Interface) the Hardware Acceleration puts them on screen.
X11: as any other X window
A good way to see how the video is coming to the screen is by starting a screen capture program as ksnapshot, if the video is seen in the capture program than it dir not pass directly to the graphic card.
Useful commands for debugging:
v4l-info
v4l-conf
xvinfo
v4lctl -c /dev/video0 list
v4lctl -c /dev/video0 bright "50%"
v4lctl -c /dev/video0 contrast "45%"
v4lctl -c /dev/video0 color "50%"
v4lctl -c /dev/video0 hue "100%" Does not work no worry
xawtv -debug 1
xdpyinfo shows the X configuration where the XVideo extension should be seen.
DGA stands for direct graphics access.
xdrinfo and driconf to even have a graphical direct rendering tool.
The newer 2.6.xx kernels contain a dummy video driver (VIVI) that can be used instead of a real video device (virtual). This device shows a color bar and a time stamp, as a real device would generate by using V4L2 API. Compile it as module and load it manually: modprobe vivi
VideoOverlay - Used to allow hardware scaling of video images. The following must also be
enabled in /etc/X11/xorg.conf
:
Section "Extensions" Option "XVideo" "Enable" EndSection
Make sure the use flag xv is set in /etc/make.conf
.
If not emerge xorg-x11 with the xv flag set.
Important seems to be that in /etc/X11/xorg.conf
v4l is loaded before vbe.
Load “v4l” Load “vbe”
And finally the xext use flag should be set to not get the dga warning when you start xawtv.
Further check the Xvideo configuration in /etc/X11/xorg.conf
To the section module add
Load "extmod"
Video compression makes uses of very many methods. Since video is a sequence of single pictures (or frames), those pictures can be compressed using a compressed picture format as JPEG. Such pictures appear in a video stream and have the name I-frames (Intra frames). They are important since they allow the video decoder to synchronize to a running video stream.
Between two sequential pictures there are mostly not much changes. Therefore it is a huge potential of compression to just transmit the differences. Two types of frames are defined containing those changes, the P-frame (Predicted frame) contains the difference to the preceding frame. There is also the B-frame (Bidirectional frame) that contains the difference to the preceding but also the following frame.
Often the term Group of Pictures (GOP) is used indicating a I-frame and its following P or B-frames.
When the camera turns or just an object moves in the video, then there is only a movement in the picture. Therefore P and B frame can contain movement information to avoid transmitting the redundant information.
Different copy protection methods are around to prevent copying commercial video:
APS (Analog Protection System) disturbs the synchronization signal of the analog video so it can not be recorded but viewed.
CGMS (Copy Generation Management System) has some decoded data (similar as Teletext) in the VBI (Vertical Blanking Interval) of the video signal.
CSS (Content Scramble System) Works with a digital key inside the digital video and uses a DVD firmware built into the DVD reader hardware.
CPRM (Content Protection for Recordable Media)
DRM Digital rightsw Management (that seems to hopefully will disappear soon)
Additionally every DVD has an unique 64 bit number
File formats on the DVD:
IFO contains the menu on the DVD to select the various options
BUP backup files from IFO
VOB is the movie in mpeg2 but contains additional data packages for navigation and search and probably also copyright data packages. It might be renamed to mpeg2 and played when not copyright protected.
VOR as VOB but created by video recorder
AOB digital audio
Regular media players as kaffeine and Xine can play DVD's, make sure that udf file system is selected in your kernel.
k3b allows to rip video dvd's and cd using a giu.
The package dvdrip is a gui front end for the command line tool transcode and can be used to compress VOB files further to (30%) and outputs them into file formates as OGG and AVI.
dvdrip gives you a tool to rip movies from a DVD. Check out the copyrights and legal situation in your country you might or might not rip your DVD's.
After installing dvdrip check in the preferences that everything is OK. If necessary install the missing packets (e.g. Rip).
Check that the right DVD device is selected in storage page.
In the rip page read the table of contents and check View selected title/chapter(s) for the files that are of interest. Rip the selected title(s)/chapters(s) and you will find after a while the VOB files. Or try the smallest title to test.
In the clip and zoom make sure the Presets is what you want (e.g. 16:9 to PAL)
In transcode check the audio options so your language will be the only one or first. Select the container format (OGG, AVI, MPEG), then click on transcode and you will find after a while your file.
Example a 7 GByte movie DVD is converted to 6.4 GByte VOB files and then compressed to a 0.9 GByte OGG format 4:3.
See https://wiki.archlinux.org/index.php/BluRay
Bluray required a kernel with UDF filesystem support.
Playing mplayer br:////run/media/<path to it>
or mplayer -lavdopts threads=2 br:////run/media/<path to it>
without / at the end.