Cooking a dvd
I'm just rehashing this and augmenting it.
A dvd looks like something like this, pretty, shiny, cheap |
Imagine you created your own private show and you'd like to burn it on dvd, you stored the files as avi files. Let's suppose you already use a bsd or linux os.
Install dvdauthor, growisofs, ffmpeg. Using apt-get or emerge or yum whatever.
After you have ascertained that you have enough disk space (with this command: df -ah). Convert the avi files to mpeg format, with this command:
find path-avis -name "*avi" -exec ffmpeg -i {} -aspect 4:3 -target pal-dvd path-mpgs/{}.mpg \;
Make sure you don't fill up your hard drive because that will lead to file corruption, you won't like that. If possible make sure that
path-mpgs
is on a non-critical partition, so it won't obliterate or damage any important files.If you have a wide-screen show, use 16:9 instead of 4:3.
A normal dvd has about 4.4 gigabytes, ascertain first how many converted files, i.e. from avi to mpg, you can fit on it (with this command: du -ah files).
Now use dvdauthor to create the files you need to burn on the dvd later:
dvdauthor -o private-show-disc1/ -t private-show-season1-0{1,2,3}.mpg
Notice the
{1,2,3}
bit, that stuffs three episodes on the path private-show-disc1/
, it shoves private-show-season1-01.mpg
and private-show-season1-02.mpg
and private-show-season1-03.mpg
in the path private-show-disc1
. If you can fit another one there, go crazy. Type du -ah private-show-disc1
to check if the size is below the maximum capacity of the dvd; if you go over it, then it's likely the dvd won't burn properly.Finalize with
dvdauthor -o private-show-disc1 -T
to create an index, so your dvd player can jump from scene to scene or episode to episode.Little trick
If you decide to write your own bash script to automate the whole process, you probably need to do some kind of loop to apply a set of operations on a certain pattern.Suppose you have 13 episodes of private-show. You'd like to loop through it with:
for nr in `seq 1 13`; do something_with_file private-show-s1$nr...; done
This will probably get you into trouble, since there are 3 pairs of episodes that have filenames which start with this pattern. Namely,
private-show-s1.title.mpg, private-show-s11.title.mpg, ..s1. and s12. and ..s1. and s13
. This will screw up your automated system, due to nameclashes.Update 15-08-2010: You can prefix some padding of zeroes using this:
for i in $(seq -w 1 13); do some_command_here; done
Say you want to check the size of the files, just do it like this:
for i in $(seq -w 1 13); do du -ah *1x$i*.mpeg; done
I used to do it like this until I found out about the (-w) switch. The following is a tad bit overkill.
for i in $(seq 1 13); do echo 0$i; done | sed 's/0\(..\)/\1/g' | xargs
for nr in `for i in $(seq 1 13); do echo 0$i; done | sed 's/0\(..\)/\1/g' | xargs` do something_with private-show-s1$nr.*.mpg done
for nr in `for i in $(seq 1 13); do echo 0$i; done | sed 's/0\(..\)/\1/g' | xargs` do spumux -P MyShow.1x$nr*xml < MyShow.1x$nr*.mpg \ > MyShow.s1.with-subs/MyShow.s1.1x$nr.with.subs.mpg done
Subtitles
Suppose you have the some files which contain some reference to srt file type or something else, because people in your private show tend to mumble or speak in some jargon that is hard to follow without prior knowledge of the scene's context and themes. This is where dvdauthor - spumux comes in.
You need an template xml file for each mpeg file and it's corresponding srt file.
<subpictures> <stream> <textsub filename="subtitles.srt" font="LiberationSerif-Regular.ttf" characterset="UTF-8" horizontal-alignment="left" vertical-alignment="bottom" left-margin="60" bottom-margin="80" fontsize="18.0" /> </stream> </subpictures>
You'll probably need to change two things:
- Change subtitles.srt to the srt filename you actually have;
- Change the font to something you like and have, have a look at what you got in the path /usr/share/fonts/truetype; and copy that to ~/.spumux/.
- Save this template above as spumux.xml.
for i in `ls -1 *srt` do cp spumux.xml ${i%.srt}.xml sed -i "s/subtitles.srt/$i/" ${i%.srt}.xml done
The suffix renaming bash trick I use here is
${i%.srt}
, that removes the filename suffix (srt), which is then replaced by an xml suffix, to indicate the file format (xml).The 2nd
sed
command replaces the dummy subtitles.srt
to something sensible, like the actual srt file, e.g. private-show-s101.srt
.Now run this:
spumux -P private-show-s101.xml < private-show-s101.mpg > private-show-s101.with-sub-en.mpg
To automate this whole process use a bash for loop:
for i in `ls -1 *xml` do spumux -P $i < ${i%.xml}.mpg > ${i%.xml}-with-sub-en.mpg done
This can be collapsed to a one-liner:
for i in `ls -1 *xml`; do spumux -P $i < ${i%.xml}.mpg > ${i%.xml}-with-sub-en.mpg; done
All of these commands depend on the veracity of the assumption that the filenames are very similar. Please modify where this is not the case.
Burning to dvd
Finally, burn the prepared path (
private-show-disc1
) to a dvd with growisofs -Z /dev/you_know -dvd-video private-show-disc1
and watch it from you dvd player. Enjoy!Fully-automated script
To create a fully automated script one must homogenize all the funky filenames, or not. If you choose the latter strategy make sure those mpeg files are isolated and grouped together.
The algorithm should be like this more or less:
- Convert files to mpeg (if necessary);
- Convert to mpeg with subtitles (if srts are provided).
- Seperate files into burnable (4.4 to 4.7gb?) units, in strict order, first episode first, last episode last, depending on the size,
dvdauthor -o unit$i -t ...files...
- For every burnable unit, finalize,
dvdauthor -o unit$i -T
- Burn every unit to dvd, i.e.
growisofs -Z /some/device -dvd /dev/you_know -dvd-video unit$i
; - Send e-mail or text-message, whatever to signal change of dvd in case either failure or succes; Build sufficient timeout for changing the dvds.
No comments:
Post a Comment
Please help to keep this blog clean. Don't litter with spam.