Telstar

Forum o satelitski, kabelski, zemeljski in IP TV
Danes je So Apr 27, 2024 22:32

Vsi časi so UTC+02:00 Evropa/Ljubljana




Napiši novo temo  Odgovori na temo  [ 2 prispevkov ] 
Avtor Sporočilo
OdgovorObjavljeno: Pe Dec 10, 2004 19:19 
Though there are at present no workable GUIs for authoring DVDs complete with menus in Linux, it is currently possible using the command-line & a few tools.

This howto is written in the attempt to help those reading to:
1) Accomplish transferring a video media file (.avi, .mpg, .wmv, .mov, etc.) to DVD media in a format that will allow it to be played on a standalone DVD player.
2) Create professional style menus with audio to allow selection of Titles, Chapters & other menus.

Tools needed:

* Latest mjpegtools 1.6.2
* Latest ffmpeg 0.4.9_pre1
* Latest transcode 0.6.13
* Latest dvd+rw-tools 5.20.4.10.8
* Mencoder (comes with the mplayer package), 'USE="encode" emerge mplayer'
* The GIMP Image Manipulation Program
* Dvdauthor 0.6.10

Tools optional:

* Xine - to test DVD menus before burning, 'emerge xine-ui'
* Normalize - to normalise volume on audio .pcm/.wav files
* Toolame


To make things easier to read, I will be using some real filenames, always keeping them & any created files in the same directory.
For the purpose of the exercise I have chosen 2 video files I have downloaded for free from www.matrix-xp.com & renamed them to 'matrix.avi' & 'outtakes.avi'.
I will also be using the THX theme at the start of the DVD & have named this 'thx.mpg'
Note any copyright issues for your location if you intend to use these for anything other than private use.

Encoding the movies
Know or find out what TV format you will be using.
For most of Europe & Australia, use PAL.
For America, use NTSC.
Here is a full listing of TV formats used in different countries around the world -> http://mightylegends.zapto.org/dvd/tv_standards.html

For PAL:
Code:
transcode -i matrix.avi -y ffmpeg --export_prof dvd-pal --export_asr 2 -o matrix -D0 -E 48000 -b 224 -s2 -m matrix.ac3
transcode -i outtakes.avi -y ffmpeg --export_prof dvd-pal --export_asr 2 -o outtakes -D0 -E 48000 -b 224 -s2 -m outtakes.ac3
transcode -i thx.mpg -y ffmpeg --export_prof dvd-pal --export_asr 2 -o thx -D0 -E 48000 -b 224 -s2 -m thx.ac3


For NTSC:
Code:
transcode -i matrix.avi -y ffmpeg --export_prof dvd-ntsc --export_asr 2 -o matrix -D0 -E 48000 -b 224 -s2 -m matrix.ac3
transcode -i outtakes.avi -y ffmpeg --export_prof dvd-ntsc --export_asr 2 -o outtakes -s2 -E 48000 -b 224 -m outtakes.ac3
transcode -i thx.mpg -y ffmpeg --export_prof dvd-ntsc --export_asr 2 -o thx -D0 -E 48000 -b 224 -s2 -m thx.ac3


The above will produce 6 files 'matrix.m2v/matrix.ac3', 'outtakes.m2v/outtakes.ac3' & thx.m2v/thx.ac3' which have been split from the original into video & audio files. The video(.m2v) has now been re-encoded into a DVD compliant mpeg2 format & the audio(.ac3) has been encoded into an AC3 DVD audio stream.

* If transcode starts encoding with a warning that says something like:
Code:
[export_ffmpeg.so]: WARNING: Selected audio sample rate (48000 Hz) not equal to input sample rate (44100 Hz), use -J

then you'll need to add '-J resample' to your transcode line.
This is critical, as it's a common gotcha that will cause dvdauthor to fail further down the road.

Frame Rate
If the input source file is of a lower framerate than the desired framerate in the encoded output file, then it is necessary to add '-J modfps' to your transcode line or audio/video(AV) will not be in sync (converting from PAL to NTSC for example).

Encoding to PAL: '-J modfps --export_fps 25'
Encoding to NTSC: '-J modfps --export_fps 29.97'

Use tcprobe (part of the transcode package) to find out what frame rate you will be encoding from. An example below shows an original file to be of frame type 'Film NTSC (23.976)':
Code:
tcprobe -i input_file.avi

[tcprobe] RIFF data, AVI video
[avilib] V: 23.976 fps, codec=XVID, frames=144695, width=592, height=240
[avilib] A: 48000 Hz, format=0x55, bits=0, channels=2, bitrate=129 kbps,
[avilib] 251455 chunks, 97463160 bytes, VBR
[tcprobe] summary for /movies/input_file.avi, (*) = not default, 0 = not detected
import frame size: -g 592x240 [720x576] (*)
frame rate: -f 23.976 [25.000] frc=1 (*)
audio track: -a 0 [0] -e 48000,0,2 [48000,16,2] -n 0x55 [0x2000] (*) bitrate=129 kbps
length: 144695 frames, frame_time=41 msec, duration=1:40:34.993

Therefore it would be necessary to add the '-J modfps' option to the transcode line for encoding to both PAL or NTSC, as the source file's frame rate is lower.
If '-J resample' is already being used as above, then the option should look like '-J resample,modfps --export_fps 25'

Aspect Ratio
The above transcode lines will convert & encode to an aspect ratio of 4:3. If an aspect ratio of 16:9 is desired then replace '--export_asr 2' with '--export_asr 3' in your transcode line. Dvdauthor will only work correctly on files with aspect ratios of either 4:3 or 16:9

Combine the new audio & video files into one DVD mpg.
Code:
mplex -f 8 -o matrix_dvd.mpg matrix.m2v matrix.ac3
mplex -f 8 -o outtakes_dvd.mpg outtakes.m2v outtakes.ac3
mplex -f 8 -o thx_dvd.mpg thx.m2v thx.ac3


Test the files in mplayer or xine. eg. 'mplayer -vo xv matrix_dvd.mpg'

For non-standard file types such as .wmv,.mov,.asf etc. it's necessary to first encode the movie to .avi with mencoder, like this:
For PAL:
Code:
mencoder -o output_file.avi -ovc lavc -oac lavc -ofps 25 your_movie.mov

For NTSC:
Code:
mencoder -o output_file.avi -ovc lavc -oac lavc -ofps 29.97 your_movie.mov

Then proceed as normal with the above transcode line.
*If mencoder errors out with the message:
Quote:
Couldn't open codec mp2, br=224
then try adding one of the following to your mencoder line:
-channels 2
-srate 22050
-srate 32000
-srate 48000

Notes

* If transcode errors out & refuses to encode your file, use mplayer to feed the file to transcode like this:
Code:
transcode -i matrix.avi -x mplayer,mplayer -y ffmpeg --export_prof dvd-pal--export_asr 2 -o matrix -D0 -E 48000 -b 224 -s2 -m matrix.ac3

* Remember that you can preview the .m2v file with mplayer or xine while it is still being encoded with transcode. No need to wait until encoding is completely finished before seeing the result, handy for very large movies.
* To preview whether AV sync is going to be correct, only encode a small amount of the movie by adding '-c 0-00:05:00' to the end of your transcode line. This will encode just the first 5 minuntes of the movie, then you will need to merge(mux) the two AV streams as mentioned below using mplex


Tweakage (optional)
It is possible to halve the encoding times & reduce the encoded file output size by over half by reducing the DVD resolution (720x576 for PAL, 720x480 for NTSC) down to a VCD resolution (352x288 for PAL, 352x240 for NTSC).
On average, this means that instead of only being able to fit one full length 90min. movie on one 4.7GB DVD, you can fit 3-4.
The video quality does suffer, but not in a visually noticeable way. Quality will always be subjective, but for my eyes I can only really see a difference when viewing on a PC while TV playback quality is still superb (your mileage may vary, depends greatly on the quality of the original file).
For PAL:
Code:
transcode -i matrix.avi -y ffmpeg -F mpeg2 -Z 352x288 --export_asr 2 --export_fps 25 -o matrix -D0 -E 48000 -b 224 -N 0x2000 -s2 -m matrix.ac3

For NTSC:
Code:
transcode -i matrix.avi -y ffmpeg -F mpeg2 -Z 352x240 --export_asr 2 --export_fps 29.97 -o matrix -D0 -E 48000 -b 224 -N 0x2000 -s2 -m matrix.ac3

One major drawback of using this method is that transcode's '--export_prof' option cannot be used, so if an aspect ratio conversion is necessary, we lose the benefits of auto clip/zoom which '--export_prof' provides.
You will know an aspect ratio conversion is necessary if the encoded output file's video is squashed/stretched using the above transcode lines.
An easy way around this is to do a dummy run using '--export_prof' on the input file & let transcode do the calculations, like so:
Code:
transcode -i matrix.avi -y ffmpeg --export_prof dvd --export_asr 2 -c 0-00:00:00 2>&1 | grep "pre clip frame"

An example output would look something like:
Code:
[transcode] V: pre clip frame | 592x450 (-106,0,-104,0)

It is the '--pre_clip' values in brackets that we need. Using those we can now also do the aspect ratio conversion like this:
For PAL:
Code:
transcode -i matrix.avi -y ffmpeg -F mpeg2 -Z 352x288 --export_asr 2 --pre_clip=-106,0,-104,0 --export_fps 25 -o matrix -D0 -E 48000 -b 224 -N 0x2000 -s2 -m matrix.ac3

For NTSC:
Code:
transcode -i matrix.avi -y ffmpeg -F mpeg2 -Z 352x240 --export_asr 2 --pre_clip=-106,0,-104,0 --export_fps 29.97 -o matrix -D0 -E 48000 -b 224 -N 0x2000 -s2 -m matrix.ac3


Creating the menus
For PAL:
Open up The Gimp and make a new image of size 720Ă—576, with a resolution of 75dpi in the x-axis and 80dpi in the y-axis.

For NTSC:
Make a new image of size 720x480, with a resolution of 81dpi in the x-axis & 72dpi in the y-axis.

Right click on the image, select Image -> Alpha -> Add channel.
Right click on the image, select image -> Layers -> Layers, Channels & Paths
Create a layer called 'button_highlight'.
Create a layer called 'button_select'.
Select the background layer & draw the menu background.

I chose to use the matrix 'green data dribble' as the background, which I downloaded from a free wallpaper website.
Scaled the image to the correct 720x576, right click image -> Image -> Scale Image & set. Then copy/pasted it into the background layer of my new image.
Here is the image -> http://mightylegends.zapto.org/dvd/matrix.jpg

I wanted to have selectable snapshots of each movie in the menu.
Snapshots were taken using xine, images were scaled using gimp, then pasted into the background layer.
Here is the image -> http://mightylegends.zapto.org/dvd/matr ... ground.jpg

Select the button_highlight layer & draw the button outlines. To see howto draw perfect rectangles, squares & circles in the gimp, see here -> http://www.cubicdesign.com/gimp/1_3/
Here is the image -> http://mightylegends.zapto.org/dvd/matr ... hlight.png

Hide the button_highlight layer & save the background layer.
Do this by selecting the button_highlight layer & using the Opacity slider in the Layers, Channels & Paths dialog box to make it disappear.
Click on the background layer, right click on the image, select File -> Save as
Save background layer as 'matrix_menu_background.jpg'.
(NOTE - Background MUST be a .jpg)

Save the button_highlight layer in the same way. Use the opacity slider to bring the button_highlight layer back up, & hide the background layer.
Click on the button_highlight layer, right click on the image, select File -> Save as
Save button_highlight layer as 'matrix_menu_highlight.png'.
(NOTE - Button layer MUST be a .png)

Select the button_select layer & draw the button outlines exactly the same as button_highlight, but in a different color. An easy way to do this is to open matrix_menu_highlight.png, right click image, select Image -> Colors -> Color map rotation, set the colour to something different, but that will still be visible against the menu background colour.
Save new colour image as 'matrix_menu_select.png'.
(NOTE - MUST also be a .png)
Here is the image -> http://mightylegends.zapto.org/dvd/matr ... select.png

Putting it all together
Convert the menu background into a DVD .mpg.
For PAL:
Code:
jpeg2yuv -n 50 -I p -f 25 -j matrix_menu_background.jpg | mpeg2enc -n p -f 8 -o matrix_menu_background.m2v


For NTSC:
Code:
jpeg2yuv -n 50 -I p -f 29.97 -j matrix_menu_background.jpg | mpeg2enc -n n -f 8 -o matrix_menu_background.m2v


Create some background audio for the menu:
Code:
mplayer yourmusicfile.mp3 -vo null -ao pcm -aofile menu_audio.pcm


Use 'normalize' to make audio softer/louder if necessary:
Code:
normalize -a -10dB menu_audio.pcm


Convert to AC3 audio:
Code:
ffmpeg -i menu_audio.pcm -ab 224 -ar 48000 menu_audio.ac3


If you do not want any audio present in your menu, it is still necessary to create a silent audio file for mplex so the DVD menus will work correctly. Like this:
For PAL:
Code:
dd if=/dev/zero bs=4 count=1920 | toolame -b 128 -s 48 /dev/stdin menu_audio.ac3

For NTSC:
Code:
dd if=/dev/zero bs=4 count=1601.6 | toolame -b 128 -s 48 /dev/stdin menu_audio.ac3


Merge background menu video/audio:
Code:
mplex -f 8 -o matrix_menu.mpg matrix_menu_background.m2v menu_audio.ac3


Use spumux to merge button_highlight & button_select images into the menu video.
Spumux is part of the dvdauthor package. It is configured via an .xml file. Here is the xml config file we will use, save it as 'spumux.xml':
Code:
<subpictures>
<stream>
<spu start="00:00:00.0" end="00:00:00.0"
highlight="matrix_menu_highlight.png"
select="matrix_menu_select.png"
autooutline="infer"
autoorder="rows"/>
</stream>
</subpictures>


Create final menu .mpg:
Code:
spumux spumux.xml < matrix_menu.mpg > matrix_menu_final.mpg


A successful output should look something like this:
Code:
INFO: Picture had 2 colors
INFO: Converting filenames to ANSI_X3.4-1968
INFO: Picture had 2 colors INFO: Picture had 2 colors
INFO: Constructing blank img
INFO: Autodetect 0 = 0x0-720x576
INFO: Pickbuttongroups, success with 1 groups, useimg=1
INFO: Found EOF in .sub file.
INFO: Max_sub_size=4456 WARN: Read 0, expected 4
INFO: 1 subtitles added, 0 subtitles skipped, stream: 32, offset: 0.18


Authoring the DVD
Dvdauthor is configured via a .xml file. Here is the .xml config file we will use, save it as 'dvdauthor.xml':
Code:
<dvdauthor dest="DVD">

<vmgm>
<menus>
<pgc>
<vob file="thx_dvd.mpg"/>
<post> jump titleset 1 menu; </post>
</pgc>
</menus>
</vmgm>

<titleset>
<menus>
<pgc>
<button> jump title 1; </button>
<button> jump title 2; </button>
<vob file="matrix_menu_final.mpg"/>
<post> jump cell 1; </post>
</pgc>
</menus>

<titles>
<pgc>
<vob file="matrix_dvd.mpg"/>
<post> call menu; </post>
</pgc>

<pgc>
<vob file="outtakes_dvd.mpg" />
<post> call menu; </post>
</pgc>
</titles>

</titleset>

</dvdauthor>


Create a directory named 'DVD'.
Create the DVD file structure with:
Code:
dvdauthor -x dvdauthor.xml


Test the new menus in xine before burning:
Code:
xine dvd:/full/path/to/DVD/VIDEO_TS/

Xine should play from the folder as though it's playing from a DVD.

Understanding the hierarchical structure of a DVD
VMGM
VMGM (or Root Menu) is the highest level of structure within a video DVD.
TitleSet
Every DVD has at least 1 titleset. All the files associated with a given titleset start with VTS_nn where nn is the titleset number (starting from 1).
Title
Each titleset contains 1 or more titles. Each title is effectively a standalone movie. If you start xine and just tell it to play a dvd, and that dvd doesn't have a top-level menu, then it will just play the first title of the first titleset and then stop.
Chapter
Titles are subdivided into chapters. Chapters provide entry points to the movie, but when the player reaches the end of a chapter it will continue to the next chapter.

Menus can be associated with either the whole disk (VMGM=Video Manager Menu) or with a titleset (VTSM=Video Titleset Menu), there can be more than one menu of either type.
VMGM menus are typically used when selection of more than one VTSM in a different Titleset is required, as one VTSM cannot jump to another VTSM in a different Titleset.

Limitations on the targets of navigation menus:
A VMGM menu can only jump to:

* Another VMGM menu.
* The first VTSM of a titleset.
* The start of a titleset.

A VTSM menu can only jump to:

* Another VTSM in the same titleset.
* A title or chapter within the titleset.
* The first VMGM of the disk.

Note:
My DVD player (and others?) defaults to the first VTSM when pressing the 'Disc' button on the remote. If this is the case, & you want to setup menu access to different VTSMs at the VMGM level, then you may need to setup the first VTSM like so:
Code:
<titleset>
<menus>
<pgc>
<post> jump vmgm menu; </post>
</pgc>
</menus>
<titles>....
So that pressing 'Disc' will take you to the VMGM Menu.

Create the DVD image & burn it
Use growisofs, part of the dvd+rw-tools package.
Code:
growisofs -Z /dev/dvd -dvd-video DVD/


Final Notes
Hopefully the DVD worked
Of course, more sophisticated menus can be generated by adding Chapters to your movies & having menus within menus within menus - this is a kickstart guide only, using 2 titles.
It may seem complex & time consuming first time through, but once it's been done a couple of times it becomes very quick & easy.
Encoding from command line with no GUI's running also means very fast encode times. (approx. 3 times faster than windows on my meagre XP 1800+)
Some work on a GUI would be nice, but with so many tools required to do the job, this would be a large task requiring a development team I believe.

Credits
Scott T. Smith - creator of the wonderful dvdauthor
Thomas Oestrich & T. Bitterberg - creators of transcode
The ffmpeg team
The mjpeg team
Wolfgang Wershofen - for precise & detailed help
Ian Pointer - for his article at linuxjournal.com, Issue# 116
James A. Pattie - for his 'DVDs under Linux' presentation
James Tappin - for his dvdauthor tutorial

Links

* Wolfgang Wershofen has done some interesting work on different xml configs & a set of scripts to automate the whole menu making process. They can be found here ->
http://www.wershofen.de/donwloads/dvdauthor.xml
http://www.wershofen.de/downloads/dvdau ... ple.tar.gz
http://www.wershofen.de/downloads/dvdwizard.tar.gz
* http://www.linuxjournal.com - An interesting article on DVD authoring under Linux
* http://www.pcxperience.org/james/dvd/presentations/ - James Pattie's DVD presentations
* http://www.tappin.me.uk/Linux/dvd.html - James Tappin's dvdauthor tutorial (recommended reading for those transferring DV to DVD)


Na vrh
   
 Naslov prispevka:
OdgovorObjavljeno: Pe Dec 10, 2004 19:22 
Se lazja resitev je pa WinE in DVD Lab Pro.....vse v enem-sicer za winse vendar deluje :D za podnapise urejat pa uporabite subtitle workshop, za ripanje pa sub rip ;)
Lep pozdrav


Na vrh
   
Prikaži prispevke prejšnjih:  Razvrsti po  
Napiši novo temo  Odgovori na temo  [ 2 prispevkov ] 

Vsi časi so UTC+02:00 Evropa/Ljubljana


Kdo je na strani

Po forumu brska: 0 registriranih uporabnikov in 30 gostov


Ne morete pisati prispevkov v temi
Ne morete odgovarjati na teme v forumu
Ne morete urejati prispevkov v temi
Ne morete brisati vaših prispevkov forumu
Ne morete dodati priponk prispevkom

Pojdi na:  
cron
Teče na phpBB® Forum Software © phpBB Limited