AVI + AVI + Linux = DVD
August 11th, 2005This one is for the code vault, and for my own personal reference.
Situation:
- You have a movie you really like, but for some reason (such as being a dirty movie pirate.. arrrr!) the movie has been split into multiple files of <700MB for burning across multiple CDRs.
- You infact own a DVD burner, and as such, want to combine these files seamlessly into one, and burn it to a single DVDR.
- You are an uber-geek (in the eyes of your grandma) and use linux and are not afraid of using the command line
Using 6 simple commands you can successfully burn this movie to DVD without skippy playback or out-of-sync audio. Here’s how:
Tools you will need for the task:
First we concatenate the two/three/four AVI files:
cat firstfile.avi secondfile.avi > concatenatedfile.avi
Then we use a bit of mencoder wizardry:
mencoder -o finalmovie.avi -noidx -oac copy -ovc copy concatenatedfile.avi
That will leave you with a perfectly synced and concatenated single AVI of the movie in question. Now to make that movie into a DVD. (Just a note: change ntsc-dvd to pal-dvd if you live in a non-NTSC country such as Australia.)
ffmpeg -i finalmovie.avi -y -target ntsc-dvd -sameq -aspect 16:9 finalmovie.mpg
Now we move on to making that MPEG version of the movie into a directory with proper VIDEO.TS and IFO files for your DVD player to read.
dvdauthor --title -o dvd -f finalmovie.mpg
Then run the following:
dvdauthor -o dvd -T
And one final step to make that DVD structure into a burnable image:
mkisofs -dvd-video -o dvd.iso dvd/
After all of that is complete, you can burn the image using your favourite burning application, throw the disc in your DVD player and get watching.
Footnote: If you are a confident, knowledgeable and impatient bugger, you can cut out the mkisofs step above and burn the files straight to disc something like this (change the -speed variable to suit your burner):
growisofs -dvd-compat -dvd-video -speed=4 -Z /dev/dvd ./dvd/*
This concludes today’s lesson. Now where’s my popcorn.
This entry was posted on Thursday, August 11th, 2005 at 3:36 pm and is filed under Linux. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
August 29th, 2005 at 4:18 am
[...] Ripped from http://movabletripe.com/ [...]
September 30th, 2005 at 11:28 am
I just tried using this as a step-by-step guide and when i got to dvdauthor part it gave me this output.
DVDAuthor::dvdauthor, version 0.6.11.
Build options: gnugetopt magick iconv freetype fribidi
Send bugs to
INFO: dvdauthor creating VTS
STAT: Picking VTS 01
STAT: Processing finalmovie.mpg…
WARN: System header found, but PCI/DSI information is not where expected
(make sure your system header is 18 bytes!)
WARN: Skipping sector, waiting for first VOBU…
WARN: Skipping sector, waiting for first VOBU…
WARN: Skipping sector, waiting for first VOBU…
WARN: Skipping sector, waiting for first VOBU…
WARN: Skipping sector, waiting for first VOBU…
WARN: Skipping sector, waiting for first VOBU…
WARN: Skipping sector, waiting for first VOBU…
WARN: Skipping sector, waiting for first VOBU…
WARN: Skipping sector, waiting for first VOBU…
WARN: Skipping sector, waiting for first VOBU…
WARN: Skipping sector, waiting for first VOBU…
WARN: Skipping sector, waiting for first VOBU…
WARN: Skipping sector, waiting for first VOBU…
WARN: Skipping sector, waiting for first VOBU…
WARN: Skipping sector, waiting for first VOBU…
WARN: Skipping sector, waiting for first VOBU…
WARN: Skipping sector, waiting for first VOBU…
WARN: Skipping sector, waiting for first VOBU…
WARN: Skipping sector, waiting for first VOBU…
ERR: SCR moves backwards, remultiplex input.
what does this mean… that i have to change the system header to 18 bytes somehow?
December 19th, 2005 at 9:39 am
thanks for mencoder -noidx! unpublished and very valuable!
February 19th, 2006 at 6:05 am
-noidx seems to fix many a/v sync errors over here when creating a kvcd (++ quality on standalone). I used to get al kind of ERR: SCR: errors without it but with it I haven’t had any problems yet.
February 24th, 2006 at 3:41 pm
after reading this “cat firstfile.avi secondfile.avi > concatenatedfile.avi”
I thought, save yourself some time and just append the second file to the first
cat secondfile.avi >> firstfile.avi
then if you want, rename firstfile.avi concatenatedfile.avi, that is, if you’re not sure what I mean.
February 25th, 2006 at 12:34 pm
cat secondfile.avi >> firstfile.aviYeah, that would work fine, but it is a moot point as to which is better. In my opinion,
cat firstfile.avi secondfile.avi > concatenatedfile.aviis easier to read, and after you addmv firstfile.avi concatenatedfile.aviI don’t think your version really saves that much time.But each would work just as fine as the other. I don’t think there are any performace gains either way, and if there are I am sure they would be marginal.
February 26th, 2006 at 7:51 am
well it’s either wait for the system to cat 2 files to one, or just cut that time in half by appending the second to the first, it’s fairly obvious the it will take less time to do this, and the mv is instant if on the same partition, and I only added that to better explain to novice users what took place, you don’t have to rename the file.
February 26th, 2006 at 6:54 pm
I see what you are saying now. I will have to give that a whirl and see how dramatic the time savings are. Logic would say half, but I would like to actually see if that is truely the case. I guess I had never really noticed the difference before because this is something I have rolled into a mini-script, and basically set-and-forget.
The time saving I was refering to regarding the
mvwas simply ‘typing time’ - obviously the rename itself is instant. I hadn’t quite figured out what you were getting at before. Don’t worry. It is all clear to me now…March 26th, 2006 at 9:02 am
cat secondfile.avi >> firstfile.aviThe above version saves disk space too, but I wouldn’t
personally use it because it (almost) irreversably alters
one of your source files. If its interrupted in process
(say “Out of disk space”), then what?
March 26th, 2006 at 1:23 pm
That is a very good point Bender. Saving disk space is not too much of a concern, as hard drives are cheap. But losing the original data because of an interrupt? That would be a huge annoyance to say the least.
I think I will stick with my original
cat firstfile.avi secondfile.avi > concatenatedfile.avi, even if it does cost me a few extra minutes of my time.April 10th, 2006 at 8:47 pm
You can skip the concatenatedfile.avi by doing the trick suggested here: http://cmp.felk.cvut.cz/~svoboda/MakingVideos/index.html.
cat 1.avi 2.avi | mencoder -noidx -ovc copy -oac copy -o output.avi -
April 11th, 2006 at 12:02 am
Congratulations! is the best how to!
April 15th, 2006 at 11:02 am
I prefer just using one step with Mencoder, it is a little harsh at first but not so bad once you get the documentation. But you don’t have to deal with preprocessing anything. Though I would imagine that ffmpeg is faster in some instances (? at least to remember the commands..).
cat ../files_you_want_to_combine*.{mpg|avi|bin|vob|rm|wmv…) | \
mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=dvd \
-vf scale=720:480,harddup -srate 48000 -af lavcresample=48000 \
-lavcopts vcodec=mpeg2video:vrc_buf_size=1835: \
vrc_maxrate=9800:vbitrate=5000:keyint=12: \
acodec=ac3:abitrate=224:aspect=4/3 -ofps 30000/1001 -o \ my_movie.mpg -
Then
dvdauthor -o test -v 720×480 -a ac3 my_movie.mpg
dvdauthor -T -o test
(skip creating the iso… and pass mkisofs_options from growisofs [-dvd-video])
growisofs -Z /dev/cd0 -dvd-video ./test/
The main argument being that you can adjust audio formats depending on what kind of busted thing you have downloaded or created. Or you can change to acceptable resolutions depending on how small the original is.. TV’s can make up for smaller pictures which are scaled via the electron gun vs cpu cycles in my opinion.
I found this link helpful.
http://www.mplayerhq.hu/DOCS/HTML/en/menc-feat-vcd-dvd.html#menc-feat-vcd-dvd-lvc
I will say I that I still see a few artifacts on my dvd player that don’t seem to be there with mplayer. But it view rewritables so I am happy to experiment. I am sure I will mess with ffmpeg.
Thanks. Nice site.
-=Bill
April 15th, 2006 at 11:11 pm
Another way to merge two avi’s:
avimerge -c -o output.avi -i input1.avi input2.aviThe
-cflag is vital. It will drop a couple of video frames (if necessary) in order to keep the audio in perfect sync. avimerge is available as part of the transcode package.May 2nd, 2006 at 4:15 pm
How do you *append* to a DVD-R? My want to add a show to a DVD-R I started burned in my JVC DR-MV1. It can record shows incrementally, so I’m sure there has to be a Linux solution!
May 2nd, 2006 at 7:47 pm
Tony, I am afraid I am a little out of my depth if you are talking multi-session DVD-R recording and authoring. For the sake of a 50¢ blank DVD-R, I would make life a little easier on myself and simply rip the movies you have already created using your DR-MV1 and author yourself a new disc, adding the clips you want at that stage.
I am sure your could achieve what you are trying to do, and some of the gurus that read this site (and correct me daily) will probably have more than a few ideas on how to do it, but hours of work in getting such a multi-session DVD re-burning/re-authoring script to work is barely worth the effort in order to save myself 50¢ for a new disc. If you are really concerned, spent $1.50 and buy a DVD-RW until you have perfected the process.
I would also suggest you take a look at the tovid set of scripts. They are easy to install, and utilise pretty much all of the tools I have used above within a few easy to use scripts. There is a GUI as well (tovidgui), however, at this stage I prefer using the very simple command line options.
August 28th, 2006 at 7:32 am
When I used this:
ffmpeg -i finalmovie.avi -y -target ntsc-dvd -sameq -aspect 16:9 finalmovie.mpg
I ended up with a mpeg at 6.1 gig
What command to use to make it fit on single sided dvd-r?
August 29th, 2006 at 5:22 am
DVDShrink can be installed using Wine, and can shrink it down to size
August 29th, 2006 at 10:03 pm
You can also try dvdrequant, which I have personally had some success with when requantisizing a DVD-9 to a DVD-5.
January 8th, 2007 at 5:29 am
I am getting repeated buffer underflows when running ffmpeg……. dvd @ 0×82c8a80]buffer underflow. How would i fix this? I’ve read that a few dont hurt anything, but repeated underflows will hose the final output.
February 16th, 2007 at 2:17 pm
Great instructions but have a weird issue. Finalmovie.avi is perfect, but when I do the ffmpeg step the resulting fimalmovie.mpg file contains the entire finalmovie.avi, plus the last 45 minutes repeated again at the end of what was the end of the finalmovie.avi. Not really an issue but the resulting files are extremely close to the capacatiy of my storage media.
March 28th, 2007 at 11:39 am
I tried this process on a fat32 partition - mkisofs and growisofs failed. This is because they need the filenames to all be uppercase. Ending up resorting to creating a big enough ext3 partition and doing it from there. Worked well, except for a lot of buffer underruns when using ffmpeg, which may have been the source of some skips on the final product.
Thanks for a really clear guide.
May 27th, 2007 at 5:21 am
[...] zna sporo odpowiedzi na to pytanie. Odfiltrowałem kilka z nich i przyjrzałem im się bliżej. Pierwsza jest przeznaczona do połączenia kilku plików avi i wypalenia ich formacie DVD - to drugie mnie [...]
June 4th, 2007 at 4:56 pm
Thanks for this tutorial, it helped me out and was great, i wrote this little script based on the tutorial i hope somebody can find some use for it, as i said it was written to learn so please dont comment on the quality of the code,
usage,
chmod +x scriptname
./scriptname [ [ -b outputfile ] input file(s) ]
function check_input {
if [ "$2" ];
then
echo “Concatenating selected files Please wait…”
cat “$@” > merged”$outputfilename”.avi
echo “Concatenation complete”
echo “Syncronizing concatenated file”
mencoder -o “$outputfilename”.avi -noidx -oac copy -ovc copy merged”$outputfilename”.avi
echo “Removing concatenated file to preserve disc space”
rm merged”$outputfilename”.avi
else
echo “Only one file for conversion, concatenation skipped”
echo “Preparing file for conversion. Please wait…”
cp “$1″ “$outputfilename”.avi
fi
}
if [ "$1" ]
then
if [ "$1" = "-b" ] && [ "$3" ]
then
for i in “${@:3:$#}”
do
echo “Checking” “$i” “exists…..”
if test -e “$i”
then
echo “….does”
else
echo “Cannot find” “$i” “Please re-check your input”
echo “Exiting….”
exit 1
fi
done
outputfilename=”$2″
inputfilename=”${@:3:$#}”
check_input ${@:3:$#}
else
for i in “$@”
do
echo “Checking” “$i” “exists…..”
if test -e “$i”
then
echo “….does”
else
echo “Cannot find” “$i” “Please re-check your input”
echo “Exiting….”
exit 1
fi
done
outputfilename=”finalmovie”
inputfilename=”$1″
check_input “$1″
fi
else
echo “ERROR: You must input at least one file for conversion!”
echo “Expected Syntax: ./mkdvd [ [ -b outputfile ] ‘file1′ ‘file2′ ‘etc..’ ]”
exit 1
fi
echo “Converting to mpg (This may take a long time…)”
ffmpeg -i “$outputfilename”.avi -y -target pal-dvd -sameq -aspect 16:9 “$outputfilename”.mpg
echo “Conversion Complete”
echo “Creating DVD files Please wait…”
dvdauthor –title -o “$outputfilename” -f “$outputfilename”.mpg
dvdauthor -o $outputfilename -T
echo “DVD file creation complete”
echo “Removing uneeded files”
rm “$outputfilename”.avi
rm “$outputfilename”.mpg
echo “Creating burnable ISO image”
mkisofs -dvd-video -o “$outputfilename”.iso $outputfilename/
echo “ISO image creation complete”
echo “Removing uneeded directory”
rm -r “$outputfilename”
read -n 1 -p “Do you wish to burn your project now? (y/n)” burn
echo “”
if [ $burn == "y" ]
then
read -n 1 -p “Have you insereted a blank disc? (y/n)” disc_inserted
echo “”
if [ $disc_inserted == "y" ]
then
growisofs -dvd-compat -dvd-video -speed=4 -Z /dev/dvd ./”$outputfilename”/*
else
echo “You may burn your project later using: ‘growisofs -dvd-compat -dvd-video -speed=4 -Z /dev/dvd ./”$outputfilename”/*’”
exit 0
fi
else
echo “You may burn your project at a later date using: ‘growisofs -dvd-compat -dvd-video -speed=4 -Z /dev/dvd ./”$outputfilename”/*’”
exit 0
fi
August 14th, 2007 at 9:30 pm
Good FAQ!
I would like to add one point regarding AVIs containing DV Type 1 format.
There is no proper tool in open source (as far as I know) for converting a DV Type 1 AVI to DV Type 2 AVI. The above given FAQ is the solution for this problem with one small modification.
Instead of
mencoder -o finalmovie.avi -noidx -oac copy -ovc copy concatenatedfile.aviuse
mencoder -o finalmovie.avi -noidx -oac pcm -ovc copy concatenatedfile.aviin which the Audio codec is specified to be other than ‘copy’. This is necessary because DV Type 1 AVI has just one stream which contains both audio and video interleaved (see http://www.microsoft.com/whdc/archive/dvavi.mspx for details).
October 8th, 2007 at 4:26 am
[...] to Movabletripe for helping me make [...]
November 1st, 2007 at 8:45 am
Note: dvgrab can convert from DV Type 1 to DV Type 2 and vice versa
December 11th, 2007 at 12:24 am
Worked great !!! Thank You