HOWTO Create a DVD:Encode
From Gentoo Linux Wiki
Please format this article according to the guidelines and Wikification suggestions, then remove this notice {{Wikify}} from the article
|
Contents |
[edit] Encode from a misc video format
Detecting the source format: Don't worry about it! Whether your source video is encoded with a divx, xvid, mov, mpg, avi or any other popular (and even some unpopular) codec, these tools will automatically detect the source as long as the correct plugins and codecs are installed and compiled correctly.
Below are basic instructions for converting video to Widescreen or Fullscreen for NTSC or PAL. If you find that you need more advanced instructions, see the appropriate link below each section (where applicable).
In order of apparent simplicity:
If you need a short video to test with, download this free matrix spoof.
export VIDEO="MATRIX-XP_engl_L"
[edit] tovid
Tovid is a newish toolbox for DVD generation which contains a wrapper script performing most of the work for you. You will need to emerge tovid using
emerge media-video/tovid
Afterwards, you may simply convert any video by executing
# Use either -pal OR -ntsc
tovid (-pal|-ntsc) -dvd -in ${VIDEO} -out ${VIDEO}.mpg
[edit] ffmpeg
ffmpeg is great if you have a well formatted video. If you don't have any awkward aspect ratio or extraneous letterboxing it's very simple:
NTSC Widescreen
ffmpeg \
-i ${VIDEO}.avi \
-pass [1/2] \
-target ntsc-dvd \
-aspect 16:9 \
${VIDEO}.mpg
NTSC Fullscreen
ffmpeg \
-i ${VIDEO}.avi \
-pass [1/2] \
-target ntsc-dvd \
-aspect 4:3 \
${VIDEO}.mpg
PAL Widescreen
ffmpeg \
-i ${VIDEO}.avi \
-pass [1/2] \
-target pal-dvd \
-aspect 16:9 \
${VIDEO}.mpg
PAL Fullscreen
ffmpeg \
-i ${VIDEO}.avi \
-pass [1/2] \
-target pal-dvd \
-aspect 4:3 \
${VIDEO}.mpg
All the format options (bitrate, codecs, buffer sizes) are automatically set by the "-target" option but can be manually adjusted - be careful though: it will allow you to be stupid and choose an option which breaks the standard.
If ffmpeg complains like this:
ffmpeg2pass-0.log: No such file or directory
with the option -pass 2 then remember to run the same command with -pass 1 and rerun it with -pass 2. This will then use the log file created by the first run.
- For more information, see HOWTO ffmpeg divx to dvd
[edit] MEncoder
NTSC Widescreen
mencoder -of mpeg -mpegopts format=dvd:vaspect=16/9:vframerate=30 -srate 48000 -ofps 30000/1001\
-ovc lavc -oac lavc -lavcopts \
vcodec=mpeg2video:\
vrc_buf_size=1835:\
keyint=18:\
vrc_maxrate=9800:\
vbitrate=4900:\
aspect=16/9:\
acodec=ac3:abitrate=192 \
${VIDEO}.avi -o ${VIDEO}.mpeg2
NTSC Fullscreen
mencoder -of mpeg -mpegopts format=dvd:vaspect=4/3:vframerate=30 -srate 48000 -ofps 30000/1001\
-ovc lavc -oac lavc -lavcopts \
vcodec=mpeg2video:\
vrc_buf_size=1835:\
keyint=18:\
vrc_maxrate=9800:\
vbitrate=4900:\
aspect=4/3:\
acodec=ac3:abitrate=192 \
${VIDEO}.avi -o ${VIDEO}.mpeg2
PAL Widescreen
mencoder -of mpeg -mpegopts format=dvd:vaspect=16/9:vframerate=25 -srate 48000 -ofps 25 \
-ovc lavc -oac lavc -lavcopts vcodec=mpeg2video:\
vrc_buf_size=1835:\
keyint=15:\
vrc_maxrate=9800:\
vbitrate=4900:\
aspect=16/9:\
acodec=ac3:abitrate=192 \
${VIDEO}.avi -o ${VIDEO}.mpeg2
PAL Fullscreen
mencoder -of mpeg -mpegopts format=dvd:vaspect=4/3:vframerate=25 -srate 48000 -ofps 25 \
-ovc lavc -oac lavc -lavcopts vcodec=mpeg2video:\
vrc_buf_size=1835:\
keyint=15:\
vrc_maxrate=9800:\
vbitrate=4900:\
aspect=4/3:\
acodec=ac3:abitrate=192 \
${VIDEO}.avi -o ${VIDEO}.mpeg2
For more information, see HOWTO mencoder divx to dvd or HOWTO Mencoder Introduction Guide
[edit] transcode
# Put these in /etc/make.conf or /etc/portage/package.use, only lzo and mjpeg are 'local' # a52 avi divx4linux dv dvdread ffmpeg imagemagick jpeg lzo mjpeg # mmx mp3 mpeg ogg quicktime sdl theora v4l vorbis xml2 xvid echo "media-video/transcode fame" >> /etc/portage/package.use echo "=media-video/transcode-1.0.0 ~x86" >> /etc/portage/package.keywords echo "=media-video/transcode-1.0.0" >> /etc/portage/package.unmask emerge transcode
NTSC
Widescreen
transcode -i ${VIDEO}.avi\
-y ffmpeg -F mpeg2video \
-Z 720x480\
--export_frc 4 -E 44100 -b 128\
-o title_of_video-dvd
Fullscreen
transcode -i ${VIDEO}.avi\
-y ffmpeg -F mpeg2video\
-Z 704x480\
--export_frc 4 -E 44100 -b 128
-o title_of_video-dvd
PAL
Widescreen
transcode -i ${VIDEO}.avi\
-y ffmpeg -F mpeg2video\
-Z 720x576\
--export_frc 3 -E 44100 -b 128\
-o title_of_video-dvd
Fullscreen
transcode -i ${VIDEO}.avi\
-y ffmpeg -F mpeg2video\
-Z 704x576\
--export_frc 3\
-E 44100 -b 128\
-o title_of_video-dvd
The transcode operation should have created a title_of_video-dvd.m2v (mpeg-2 video) and a title_of_video-dvd.mpa (audio) file in the current directory. We will combine those as follows:
tcmplex -o ${VIDEO}.vob\
-i title_of_video-dvd.m2v\
-p title_of_video-dvd.mpa\
-m d
- For more in depth information see HOWTO_transcode_divx_to_dvd
[edit] avidemux
Avidemux is a free video editor designed for simple cutting, filtering and encoding tasks. You can easily encode dvd with Avidemux by opening the video, selecting Auto->DVD from the menu, and saving the file. More information about this can be found in Avidemux's wiki.
[edit] kino
Kino is used to create movies from dv cameras. It allows one to do simple editing of movies (cut scenes, paste, trim). It has a pretty good interface for capturing the video (one can also use dvgrab if they prefer cli). It uses a qt4linux mov format for capturing by default.
If you already grabbed the movies using dvgrab or grabbed them in kino (but closed it without saving) you can use your favourite file manager to quickly drag and drop the movie files back into the storyboard editor. Once you have the storyboard filled with movie files that fit your likings, go to the export tab. There you can export the video to vcd, svcd, or dvd quality (among others).
For DVD in the export tab select DVD format. You may want to add the flag and value "-r 48000" to the mp2enc field if you are making a dvd for standalone DVD players. Without that option it encodes the audio at 44.1kHz and some players may have problems with this rate. Also enable outputting of the dvdauthor xml file. Then click start and begin encoding (a fast CPU would be nice here, my athlon xp 2800+ takes 1.5hrs to encode 25mins of raw 720x480 footage).
Now if you want to just make the dvd without menus, edit the dvdauthor xml file and make sure the "<dvdauthor>" tag has the dest="" modifier. Otherwise dvdauthor will have problems with the XML file. Basically you need to modify the line to be something like:
<dvdauthor dest="/home/user/rootOfMyDVD/">
Where the DVD structure (VIDEO_TS and AUDIO_TS) will be placed into the dest="" directory. Then you just run on the CLI:
dvdauthor -x dvdauthorXMLFile.xml
Then use k3b to burn the VIDEO_TS and AUDIO_TS directories into the root of a data DVD project.
For more advanced editing cinelerra is basically the only choice on Linux. It is quite powerful, but tends to have a steep learning curve and crashes often (save frequently!). You can import the same .mov that kino (dvgrab) captures into cinelerra (in fact it crashes with most other formats). Then you can use cinelerra to render your finished movie back to mov.
[edit] From multiple DVDs
You may want to combine several home DVDs, or live concerts that are available on the internet. Remember to only use material which is legal to copy.
[edit] vobcopy
If you want to rip from a DVD on your hard drive, then it must be an image. This counts out the DVD you just created with dvdauthor. If you want to rip from an image that is 'open' on the filesystem, you first have to make an image.
$ mkisofs -dvd-video -o DVD.iso /path/to/dvd/ $ sudo mount -o loop DVD.iso /mnt/cdrom
Since vobcopy looks for the DVD device in /dev, you probably have to include the following to your /etc/fstab:
/dev/loop0 /mnt/cdrom iso9660 noauto 0 0
Then you can start ripping. Silly, isn't it?
$ sudo vobcopy -i /mnt/cdrom/ -o COPY/ -m
Notice that you have to be root in order to do this.
[edit] cpvts
cpvts seems to work only with actual DVDs in drive. Mount the DVD, then extract:
$ sudo mount /dev/dvd /mnt/cdrom $ cpvts -d /dev/dvd -s 4096 COPY/
The -s option sets the wanted vob chunk size, here it is 4 GB.
[edit] chaplin
[edit] cpdvd
[edit] dvdbackup
[edit] Extracting subtitles
Try this little script:
| File: dvdsubs2srt |
#!/bin/bash MNTPOINT="/mnt/cdrom" echo "mounting DVD, give root passwd" sudo mount /dev/dvd $MNTPOINT lsdvd echo "Please type in the stream number" read DVDSTREAM; mplayer -dvd-device $MNTPOINT dvd://$DVDSTREAM -vo null -ao null -frames 0 -v 2>&1 | grep sid # ask the user for sid... # the correct number is 0x20 + sid echo "Please type in the subtitle SID, type in hexadecimal and add 0x20. Example: for sid 0, type 0x20" read SID; tccat -i $MNTPOINT -T $DVDSTREAM -L | tcextract -x ps1 -t vob -a $SID > subs subtitle2pgm -o subtitles -c 255,255,0,255 < subs pgm2txt subtitles ispell -d american subtitles*txt srttool -s -w < subs.srtx > subtitles.srt |
[edit] From a DVB source
Moved to HOWTO Master a DVD from DVB transport stream
