Docs/Desktop/Multimedia/Video
From Mandriva Community Wiki
Mandriva Linux comes with the following video applications:
- MythTV
- tvtime
- xawtv
- Kaffeine
- Xine
- Mplayer (also has GUI interfaces: gmplayer and kmplayer)
- VLC
- Ogle
- Totem
[edit] DVD Playback
This topic answers 3 main questions:
- Q: How do I play a DVD in Mandriva Linux?
- Q: How do I play encrypted DVD's in Mandriva Linux?
- Q: How do I use DVD menus in Mandriva Linux?
Q: How do I play a DVD in Mandriva Linux?
There are many programs on Linux that play DVD's, almost all of which are general purpose Media Players that you can use for any video or audio playing.
The major applications are:
There are many more players that use either Xine or MPlayer as the player backend and provide a more user-friendly front-end that integrates into the various Desktop Managers.
Some KDE applications include:
- Kaffeine (uses Xine or MPlayer) http://kaffeine.sourceforge.net/
- Codeine (uses Xine or MPlayer) http://www.kde-apps.org/content/show.php?content=17161
- KPlayer (uses Xine or MPlayer) http://kplayer.sourceforge.net/
- KMPlayer (uses Xine or MPlayer) http://kmplayer.kde.org/
Some Gnome applications include:
- Totem (uses Xine or GStreamer) http://www.gnome.org/projects/totem/
- Gxine (uses Xine) http://xinehq.de/
- ogle_gui (uses Ogle) http://www.dtek.chalmers.se/groups/dvd/
How to install a Media Player:
- First ensure you have a full set of Software Repositories configured, including Contrib and PLF.
- Next use the Software Installer to install your chosen Media Player, it is strongly recommended that you install the PLF versions of these players if available, as they have extra features turned on that it is not legal for Mandriva to distribute.
Q: I'm trying to play a Commercial DVD, but all I get is a warning that the DVD is encrypted / that I am not in the right region / all I see is garbage, what gives???
Commercial DVD's are protected by 2 forms of DRM, namely Region Encoding and CSS Encryption. Region Encoding prevents you from playing DVD's from outside your region on your DVD player, in order to protect the movie studios local distribution network from imported copies, e.g. Zone 1 USA DVD's cannot be played on Region 2 UK DVD players. CSS Encryption prevents you from playing DVD's on unlicensed players that might allow copying of the DVD, licensees of the DVD encryption must agree to stringent terms, which include closed-source. There are no licensed players available for Linux, so technically speaking in many countries there is no legal way offered for Linux users to view the DVD's they own the right to watch.
Fortunately, a Norwegian known as DVDJon cracked the encryption in only 23 lines of code and released it onto the internet. This code also by-passes the Region Encoding allowing you to watch any region DVD you like. After prolonged legal battles the movie studios appear to have stopped attempting to close the stable door and appear to be leaving us to watch our legally purchased DVD's in peace so long as we do not illegally share them. However, it is still illegal for Mandriva to distribute the DeCSS hack, any attempt on their part would certainly lead to legal action. That's where the PLF (Penguin Liberation Front) come into play. There are countries where DeCSS is perfectly legal, or legally ambiguous enough, to allow the hosting of the required files by PLF.
If it is legal to do so in your country, or you are willing to break the law and not hold me liable for doing so, then here are the instructions to install the decryption libraries.
Let me repeat that, the following is illegal in many countries, only perform this step if it is legal to do so in your country, or if you are willing to take full personal responsibilty for the possible consequences of your actions.
- First ensure you have a full set of Software Repositories configured, including Contrib and PLF.
- Next use the Software Installer to upgrade your chosen Media Player to the PLF version, if one is available and you haven't already done so.
- Finally use the Software Installer to install the following packages from PLF:
- libdvdcss2
- libcss0
You should now be able to watch your encrypted DVD's in peace. If your chosen Media Player still does not play the encrypted DVD's, then you will probably need to switch to a player that does support doing so, such as Xine or MPlayer or their many derivatives.
Q: I want to use the DVD menus to select options/extra material/hidden easter eggs, but all my player does is start playng the movie, what gives?
Most Media Players do not support DVD menus out of the box, being designed to simply play video files, and for a long time there was no support for DVD menus. Finally Ogle developed a plugin for menus which was soon adopted by Xine and many other projects. As with many things in Linux, DVD Menus are implemented as common plugin libraries that are shared by many players, and are only installed if you want them to be installed. Therefore to enable DVD menus you need to install the correct plugin for your chosen player, if that player supports Menus.
NOTE: MPlayer and derivatives do not support DVD menus due to limitations in MPlayer. You will need to use a different player instead.
- First ensure you have a full set of Software Repositories configured, including Contrib and PLF.
- Next use the Software Installer to upgrade your chosen Media Player to the PLF version, if one is available and you haven't already done so.
- Finally use the Software Installer to install the following packages:
- libdvdnav
- libdvdplay
- vlc-plugin-dvdnav (only if using VLC)
- gstreamer-libdvdnav (only if using GStreamer based player)
Xine and derivatives, and Ogle are known to use libdvdnav. VLC is known to use libdvdplay.
[edit] DVD and DivX links
- http://www.geocities.com/desktopmandrake/xine.htm - Desktop Mandriva Linux - DVD & DivX on Linux
- http://dvdripping-guid.berlios.de/ - Linux Media-DVD Ripping
- http://www.bunkus.org/dvdripping4linux/ - DVD ripping and transcoding with Linux
- http://diablonetwork.net/dvd.html - DVD Ripping for Linux
- https://listman.redhat.com/pipermail/psyche-list/2002-October/000323.html - How to make your own RedHat 8.0 DVD from the CD ISO images
- http://www.troubleshooters.com/linux/coasterless_dvd.htm - Coasterless DVD Burning
[edit] VideoConferencing
- GnomeMeeting
- Other Resources
- http://www.pclinuxonline.com/modules.php?name=Surveys&op=results&pollID=184 just a survey. Some comments may have useful information. Something to check and sort out.
[edit] Video from a Digital Camcorder
Linux now works very well with ieee1394 "firewire" (also called "i-link") camcorders. These can be used for capturing video, transferring it both to and from the camera, and even as backup devices. The applications to use are:
- gscanbus (GUI to list attached firewire devices)
- dvgrab and kino for capturing (CLI and GUI respectively)
- ffmpeg (or vlc, mencoder, or transcode) to convert files from one format to another.
- kino, kdenlive, cinelerra for video editing.
- dvbackup to use a DV camera as a tape drive (about 13 GB/tape).
- kino to export DV back to tape.
[edit] Video from an Analogue Camcorder
Whilst there are a number of packages offering neat graphical tools for capturing and processing video from digital sources, it can be quite difficult to find what is necessary and available for those of us with older, analogue camcorders. This is the position I started from.
The good news is that it is perfectly possible to capture your video and end up with a VCD or DVD of the content, at least if you can find a capture card based on the Zoran set of drivers. These include Buz, DC10, DC10+ and LML33. The same tools probably work with other cards and drivers, but I have no experience of them. From the mjpegtools web page they probably work with Matrox Marvel G200/G400/G450 Rainbow Runner G-Series cards.
The bad news is that while there is a fair bit of documention in man pages and a Mjpegtools How-To, and the mjpegtools mailing list is actively supported by the developers the beginner finds the whole thing overwhelming. This page, then, sets out to document what I did to create a video from approximately 45 minutes of Hi8 tape.
So - what do you need? A capture card that has well-known drivers, because you are quite likely to need some support in the first stages. I recommend a Zoran based card, models of which are frequently available on Ebay. If you want to be able to see your output you will need to have xawtv working - though this does not require you to have a tv card installed. I had great problems with this, which turned out to be due to the fact that I had no .xawtv file in my home directory. I have reproduced mine here, as I was helped by someone giving me their file. Please note, this and all the follows, is based on PAL settings. The mjpegtools do clearly document the alternative settings for NTSC.
.xawtv [global] ratio = 4:3 freqtab = europe-west pixsize = 80 x 24 pixcols = 8 jpeg-quality = 75 keypad-ntsc = off keypad-partial = off osd = yes osd-position = 30 , 20 use-wm-fullscreen = no [defaults] input = svideo norm = pal capture = over
Mandriva Linux does supply an rpm of mjpegtools, but they are incomplete, and I cannot recommend using them in this context (it does not support SDL, and without it your hardware will probably not function correctly). Instead, download the latest set of tools from http://mjpeg.sourceforge.net/. For a graphical inteface download Linux Video Studio from http://ronald.bitfreak.net/, and to complete the set for creating DVDs, download DVDAuthor from http://dvdauthor.sourceforge.net/ I also used Audacity to edit a sound file for the slide-show content.
I would also recommend printing out the man page for each tool before using it. You will want to compare the settings I suggest with the man page, to see whether they match your own requirements.
This, then, is how I tackled my own project.
[edit] Capturing the Stream
Hardware setup is obvious to the experienced, but not necessarily so to the beginner, so - S-Video cable or composite input cable from the camcorder to your capture card (DC10+ in my case) and a composite lead from the camcorder to your soundcard Line-In.
Capturing can be done in Linux Video Studio (and some other packages that produce a standard .avi stream). Alternatively you can do it simply from the Command Line Interface (CLI) with
lavrec -f a -i P -d 2 -q 80 -s -l 60 -R l -U filename.avi
If you have a working xawtv you will be able to monitor the recording as it happens. Without xawtv you can still make the capture, but you will have to either use the camcorder viewfinder or the soundtrack to monitor the input. Stop the recording simply by using Ctrl-C.
If you know the length of the stream you want to capture you can add the parameter -t nnnn, where nnnn represents the time in seconds.
There is a limit of around 2GB for an .avi stream, so lavrec stays safely inside that limit by cutting off at around 1.7GB. This is probably not enough for your requirement, so you need to create a series of .avi files that can easily be linked. This is achieved by adding %02d to the file name.
lavrec -f a -i P -d 2 -q 80 -s -l 60 -t 3600 -R l -U filename%02d.avi
would record for 1 hour, creating a series of files called filename01.avi, filename02.avi etc. (you are not limited to 2 places of decimal - %05d would give you 5 places).
[edit] Playback and Simple Editing
Any .avi file can be played back in totem, xine, mplayer etc. However, again a CLI tool is useful, because it allows you to do simple editing such as tidying up the beginning and end of a stream, or cutting out a few frames where you wobbled.
glav -p S filename.avi
will play back your stream in a simple gui, where you can advance at normal speed, fast forward, frame-by-frame forward (and all of these in reverse) and cut out sections of file. The mjpegtools are non-destructive, and the end result of your editing is stored in a text file with an .eli suffix (edit-list).
[edit] Scene Editing
There are CLI tools for almost everything you need to do, but if you want to juggle the order of scenes, or any other complicated editing of that kind I would recommend that you turn to Linux Video Studio (LVS). Here you can create a new edit list (or open an existing one and add to it) that will document the changes you need to split the stream into scenes and manipulate them as you wish.
Again, the changes are non-destructive. You can at any point return to the original .avi file and change what you had done - it is only the text file that will be overwritten.
[edit] Moving to an Mpeg2 Movie format
The next stage is that you have to create a stream in mpeg2 movie format. If you have an edit list for the file you will use the .eli, otherwise the .avi file:
lav2yuv filename.eli | yuvscaler -O DVD | yuvdenoise | mpeg2enc -f 8 -I 1 -q 7 -o filename.m2v
Note the -O here is set to DVD. This could be set at -O VCD for SVCD output. The resulting stream is, though, silent, so now you need to capture the sound in MP2 format, with
lav2wav filename.avi | mp2enc -v 2 -o filename.mp2
[edit] Adding the Sound to your Mpeg2 File
mplex -f 8 filename.mp2 video m2v -o filename.mpg
prepares the output for a DVD, and
mplex -f4 filename.m2v filename.mp2 -o filename.mpg
prepares it for an SVCD.
[edit] Creating a Title Screen
Like many home videos the source stream began and ended abruptly, so I wanted to do something to improve that. I first created a 5-second movie consisting of one frame from the main stream, overlaid with a text title. First, I needed to ascertain the frame number that I wanted to use for the backdrop, so I used the same glav command as above to play the file. When I got to the right area I made a 1-frame selection, saving the selection to an .eli. Reading that eli in a text editor gave me the frame number that I needed to create a .jpg file, using lavtrans:
lavtrans -o file.jpg -f i 7388 inputfile.avi
(where 7388 is the frame number required to be saved as a jpg)
I then opened file.jpg in Gimp2 and added the text overlay for the title, resaving the file to use as a basis for the title screen. This needed to be a short .avi, which was created with jpeg2yuv and yuv2lav:
jpeg2yuv -f 25:1 -L 1 -I t -l 125 -j image20.jpg | yuv2lav -o image20.avi
(In version 1.6.2 there is a bug that prevents this exiting at frame 125, so you need to watch the output carefully and stop the stream (Ctrl-C) on or soon after frame 125. Stopping short of your target will cause problems if you need to create a transition.)
In this instance I decided that the title screen should remain silent, so I created a 5 second stream of silence (!) in an .mp2 file, using the same command as before, then created the m2v file from the .avi an mplexed - all exactly the same as before, using the filenames title.m2v, title.mp2, title.mpg.
[edit] The End-piece - a slideshow with music
In order to tidy up the ending I decided to select a few significant frames from the main stream, changing them into a series of 5-second .avi files, using the same technique as for the title screen. I also created a jpg in Gimp2 of the same size as the captured jpgs, which was completely black. As the subject matter was solemn I wanted a softer ending, so I decided on a fade between each slide and some quiet music added. To create each blend file I used
ypipe -v 2 "lav2yuv -v 2 -o -25 image01.eli" "lav2yuv -v 2 -f 25 image02.eli" | transist.flt -o 0 -O 255 -d 25 | yuv2lav -v 0 -f a -q 80 -o transition.avi
The final frame was the all-black frame, so that the last slide also faded away. With hindsight I would have created the black avi from 50 frames and made a 2-second fadeout of the final picture, instead of the 1-second used for the others.
The easiest way to join these together is to use LVS. Use Create a New Edit List, then use Add Scene to add each slide avi followed by the appropriate transition avi, then save the resulting eli. I now wanted to create an avi from that eli so that I could add sound. This is done with
lavtrans -o filename.avi -f a inputfile.eli
Now it is necessary to know the play length of the resulting file, so glav again provides the answer. The music I needed was present in the main recorded stream, so I grabbed a section of sound from the avi using another form of the lav2wav command:
lav2wav musicclip.avi > musicclip.wav
This is because I wanted to edit the file in Audacity. I selected a clean start to the soundtrack, then cut it off at the required length. Finally, I experimented with fading out the end of the clip, as it is almost impossible to get a melodic end at the exact time-span required. When this is satisfactory and the file re-exported to a wav file, it must be added to the coda stream, using
lavaddwav AVI_file WAV_file Output_file
At this point you have a working avi file that shows your slides for approximately 5 seconds, fading into the next slide over 1 second. This is then used to create your m2v, mp2 and mpg files in the same way as previously.
[edit] Getting the Details of your .avi File
lavinfo filename.avi
gives a good deal of information about file size and format, and is often useful in deciding on parameters for the various commands.
[edit] Authoring a DVD
If your requirement is to play DVDs on the computer there are few problems. However, if you want to play the results on a hardware DVD player you have to ascertain which format of disks your player will handle. Some older models will not handle any home-recordable media. Others will handle DVD-R and DVD-RW, while many of the newer ones handle DVD+R and DVD+RW. Your DVD burner also must be able to support the format that your player reads. In an ideal world both the burner and player will support all formats and you can choose your media by availability.
You must also ensure that you have plenty of disk space. While your mpg file is a fraction of the size of the .avi files, it is still considerable, and the authoring process requires space a little more than twice the size of the mpg file(s) being authored. You must now prepare the file that lays out the DVD structure
[edit] Laying out the Structure
$ cd where-the-mpg-files-reside $ dvdauthor -x my-dvd.xml
where my-dvd.xml looks like
<dvdauthor dest="my-dvd/"> <!-- EDIT ME --> <vmgm /> <titleset> <titles> <pgc> <vob file="intro.mpg" /> <!-- EDIT ME --> <vob file="main.mpg" /> <!-- EDIT ME --> <vob file="coda.mpg" /> <!-- EDIT ME --> </pgc> </titles> </titleset> </dvdauthor>
That will layout the dvd file structure in the directory ./my-dvd/ Make sure that ./my-dvd is either empty or does not exist: dvdauthor keeps appending titles to the destination directory, so it is important to start from a clean state.
[edit] Check the authoring
using xine (version 0.9.2x if possible :)
$ xine dvd:/$PWD/my-dvd/
(the trailing / is important)
[edit] Make a Raw Image
Make an raw disk image using mkisofs/hdd
$ mkisofs -dvd-video -o my-dvd.raw ./my-dvd
- you need a recent version of mkisofs for -dvd-video support version >= 2.0 ?
- you can combine this step with the burning step below to save disk space and typing, but for the first try its better to make the raw image and then burn.
[edit] Burn the DVD
Burn my-dvd.raw to a dvd+/-rw disk using dvd+rw tools or dvdrecord/cdrecord as appropriate for your dvd drive.
For +RW (recent versions of growisofs are supposed to with -RW too, I haven't tried)
$ dvd+rw-format /dev/hdd <!-- EDIT ME -->
(if you have previously written to a DVD+RW disk you may need dvd+rw-format /dev/hdd -force)
$ growisofs -dvd-compat -Z /dev/hdd=my-dvd.raw <!-- EDIT ME -->
- replace /dev/hdd by the appropriate device
- need permission to write to /dev/hdd
- avoid gui front ends that tie you to a mouse and spoil all fun :)
- not -dvd-compat may or may not be needed)
For -RW with dvdrecord
$ dvdrecord -dao dev=0,0,0 -v my-dvd.raw
The resulting dvd should play main.mpg followed by ending.mpg with no menus or other frills. It gets authored as three chapters corresponding to the three sources as a single title. The playback may not be seamless between the three sources (although I had no problems), so it is recommended that you encode and mplex the source for each title as a single file.
[edit] Acknowledgements
For detailed help on using mjpegtools and Linux Video Studio, the developers Bernhard Praschinger and Ronald S. Bultje. For equally detailed help with DVD authoring, Selva Nair, on the mjpegtools mailing list. General advice also from other members of the mjpegtools mailing list and the dvdauthor mailing list.