The below commands will use FFMPEG to create a video suitable for playback within both iTunes and on a video iPod.
You will need a source file as input and a filename for the resulting output. My source file came from the rendered output of a Cinelerra project that I had just completed. The output was a DVD resolution MPEG program stream, created from directions in my Beginner's Guide to Exporting Video from Cinelerra.
A Two-Step Process
Below are two sets of FFMPEG commands. These two commands encapsulate a "two pass" encoding method. On the first pass, FFMPEG examines the file to be encoded and creates an optimization index. On the second pass, FFMPEG renders the output file based on the optimizations present in the index file.
In the below example, I am encoding a typical DVD resolution (720x480, 1.5 aspect ratio) to the following container format, using the following codecs:
- MPEG4 container
- H264 video codec
- AAC audio codec
For HDV fans, if you wish to reduce your videos to an iPod compatible size, you may use a resolution of 720x400 in order to keep the aspect ratio similar to that of 720P content (1.78 aspect ratio). Though the 720x400 resolution exceeds Apples' recommendations, I've found that iTunes and the iPod will still accept videos encoded to this size.
1) First pass (create index of optimizations)
ffmpeg -y -i sourceFileName.ext -an -v 1 -threads 8 -vcodec h264 -b 500k -bt 175k -refs 1 -loop 1 -deblockalpha 0 -deblockbeta 0 -parti4x4 1 -partp8x8 1 -me full -subq 1 -me_range 21 -chroma 1 -slice 2 -bf 0 -level 30 -g 300 -keyint_min 30 -sc_threshold 40 -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.7 -qmax 51 -qdiff 4 -i_qfactor 0.71428572 -maxrate 768k -bufsize 2M -cmp 1 -s 720x480 -f mp4 -pass 1 /dev/null
This first pass will create a file called x264_2pass.log that will be used as an implicit input to the second pass.
2) Second pass (render the output file)
ffmpeg -y -i sourceFileName.ext -v 1 -threads 8 -vcodec h264 -b 500k -bt 175k -refs 1 -loop 1 -deblockalpha 0 -deblockbeta 0 -parti4x4 1 -partp8x8 1 -me full -subq 6 -me_range 21 -chroma 1 -slice 2 -bf 0 -level 30 -g 300 -keyint_min 30 -sc_threshold 40 -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.7 -qmax 51 -qdiff 4 -i_qfactor 0.71428572 -maxrate 768k -bufsize 2M -cmp 1 -s 720x480 -acodec aac -ab 160k -ar 48000 -ac 2 -f mp4 -pass 2 -threads 8 outputFileName.ext
I found that the file resulting from the above commands was a bit large, so I lowered the bitrate (-b) from 500 to 250. Also, I lowered the maximum instantaneous bitrate spike (-maxrate) from 768 to 450. As this was a music video and I am a bit of an audiofile, I kept the audio bitrate (-ab) at 160k. Doing this, my file size dropped by 33%, from 450MB to 300MB. This is for a video with a duration of 1hr and 39min. Impressive! Replaying both files in mplayer and xine, I noticed that there was very little appreciable loss in video quality with the lowered bitrates. Go H264!!
Here are the final two commands I used to get that 300MB file:
ffmpeg -y -i sourceFileName.ext -an -v 1 -threads 8 -vcodec h264 -b 250k -bt 175k -refs 1 -loop 1 -deblockalpha 0 -deblockbeta 0 -parti4x4 1 -partp8x8 1 -me full -subq 1 -me_range 21 -chroma 1 -slice 2 -bf 0 -level 30 -g 300 -keyint_min 30 -sc_threshold 40 -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.7 -qmax 51 -qdiff 4 -i_qfactor 0.71428572 -maxrate 450k -bufsize 2M -cmp 1 -s 720x480 -f mp4 -pass 1 /dev/null
ffmpeg -y -i sourceFileName.ext -v 1 -threads 8 -vcodec h264 -b 250k -bt 175k -refs 1 -loop 1 -deblockalpha 0 -deblockbeta 0 -parti4x4 1 -partp8x8 1 -me full -subq 6 -me_range 21 -chroma 1 -slice 2 -bf 0 -level 30 -g 300 -keyint_min 30 -sc_threshold 40 -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.7 -qmax 51 -qdiff 4 -i_qfactor 0.71428572 -maxrate 450k -bufsize 2M -cmp 1 -s 720x480 -acodec aac -ab 160k -ar 48000 -ac 2 -f mp4 -pass 2 -threads 8 outputFileName.ext
Results
As this encoding work was completed on my Fedora editing box, I SCP'd the file over to my MacBook Pro. I dragged the file over onto the Movies section within iTunes and iTunes accepted it without error. In order to verify that the file played correctly, I double-clicked on it and Quicktime played the file back. Hooray!
The moment of truth came when I plugged in my iPod and sync'd it to my iTunes Library. Normally, iTunes will immediately display an error if it doesn't like the new file. Thankfully, iTunes didn't show any errors and uploaded the file to my iTouch. As the file was about 300MB, this took about two minutes. I then started playback and was very happy to see my video on the beautiful, but small iTouch screen.
If you'd like to see the end result, load up one of these videos and don't mind a bit of loud rock musicians doing their thing, you could try loading my band's video podcast:
http://www.stormpigs.com/vodcast.xml
One anomaly I noticed was that when you fast forward to a different section within the movie on the iPod, the video will speed up for a second until the timeline catches up to the requested moment. Not a big deal, just something I didn't expect.
Hope this helps intrepid open source folks looking for a way into the walled garden of Apple's iTunes.
The Mule
Reference
https://help.ubuntu.com/community/iPodVideoEncoding#H.264%20Encoding
Showing posts with label dvd. Show all posts
Showing posts with label dvd. Show all posts
Sunday, September 28, 2008
H264 encoding for video iPod
If this post was useful to you..consider buying me a beer via PayPal!
Even a $1 Draft will keep the Mule happily working..and help pay for equipment upgrades!
Friday, February 22, 2008
creating a bootable iso in Linux
OK. So call me stupid, but I rarely create bootable DVDs from iso images in Fedora. Here is how I created a bootable Ubuntu 7.10 disk using growisofs.
Burn the ISO image to a DVD
1) Put your DVD in your DVD drive
2) Make sure your drive is reading the disk properly by using dvd+rw-mediainfo. This program is part of the dvd+rw tools. The command should also give you a write speed estimate, which is handy.
3) Using growisofs, burn the ISO image to a DVD. Note that I used this command on a DVD RW:
[mule@ogre ~]# growisofs -dvd-compat -Z /dev/dvd=ubuntu-7.10-desktop-amd64.iso
Executing 'builtin_dd if=ubuntu-7.10-desktop-amd64.iso of=/dev/dvd obs=32k seek=0'
/dev/dvd: "Current Write Speed" is 2.0x1352KBps.
3407872/2005147648 ( 0.2%) @0.5x, remaining 39:09 RBU 100.0% UBU 6.5%
12288000/2005147648 ( 0.6%) @1.9x, remaining 18:55 RBU 100.0% UBU 100.0%
..
1992097792/2005147648 (99.3%) @2.0x, remaining 0:04 RBU 77.9% UBU 100.0%
2001076224/2005147648 (99.8%) @1.9x, remaining 0:01 RBU 24.4% UBU 100.0%
builtin_dd: 979088*2KB out @ average 1.9x1352KBps
/dev/dvd: flushing cache
/dev/dvd: writing lead-out
The disc..she boots!
The Mule
Burn the ISO image to a DVD
1) Put your DVD in your DVD drive
2) Make sure your drive is reading the disk properly by using dvd+rw-mediainfo. This program is part of the dvd+rw tools. The command should also give you a write speed estimate, which is handy.
[mule@ogre ~]# dvd+rw-mediainfo /dev/dvd
INQUIRY: [HP ][DVD Writer 940d ][3H23]
GET [CURRENT] CONFIGURATION:
Mounted Media: 11h, DVD-R Sequential
Media ID: ProdiscS03
Current Write Speed: 4.0x1385=5540KB/s
Write Speed #0: 4.0x1385=5540KB/s
Write Speed #1: 2.0x1385=2770KB/s
GET [CURRENT] PERFORMANCE:
Write Performance: 4.0x1385=5540KB/s@[0 -> 0]
Speed Descriptor#0: 00/0 R@6.4x1385=8864KB/s W@4.0x1385=5540KB/s
Speed Descriptor#1: 00/0 R@6.4x1385=8864KB/s W@2.0x1385=2770KB/s
READ DVD STRUCTURE[#10h]:
Media Book Type: 00h, DVD-ROM book [revision 0]
Legacy lead-out at: 2298496*2KB=4707319808
READ DVD STRUCTURE[#0h]:
Media Book Type: 25h, DVD-R book [revision 5]
Last border-out at: 2045*2KB=4188160
READ DISC INFORMATION:
Disc status: blank
Number of Sessions: 1
State of Last Session: empty
"Next" Track: 1
Number of Tracks: 1
READ TRACK INFORMATION[#1]:
Track State: invisible incremental
Track Start Address: 0*2KB
Next Writable Address: 0*2KB
Free Blocks: 2297888*2KB
Track Size: 2297888*2KB
READ CAPACITY: 0*2048=0
3) Using growisofs, burn the ISO image to a DVD. Note that I used this command on a DVD RW:
[mule@ogre ~]# growisofs -dvd-compat -Z /dev/dvd=ubuntu-7.10-desktop-amd64.iso
Executing 'builtin_dd if=ubuntu-7.10-desktop-amd64.iso of=/dev/dvd obs=32k seek=0'
/dev/dvd: "Current Write Speed" is 2.0x1352KBps.
3407872/2005147648 ( 0.2%) @0.5x, remaining 39:09 RBU 100.0% UBU 6.5%
12288000/2005147648 ( 0.6%) @1.9x, remaining 18:55 RBU 100.0% UBU 100.0%
..
1992097792/2005147648 (99.3%) @2.0x, remaining 0:04 RBU 77.9% UBU 100.0%
2001076224/2005147648 (99.8%) @1.9x, remaining 0:01 RBU 24.4% UBU 100.0%
builtin_dd: 979088*2KB out @ average 1.9x1352KBps
/dev/dvd: flushing cache
/dev/dvd: writing lead-out
The disc..she boots!
The Mule
If this post was useful to you..consider buying me a beer via PayPal!
Even a $1 Draft will keep the Mule happily working..and help pay for equipment upgrades!
Tuesday, January 15, 2008
dvd file for iTunes
Last night, I was putting together a presentation on my MacBook and wanted to incorporate a DVD resolution video from Cinelerra. Since the Mac world is so tightly controlled, getting the format correct for iTunes was a royal pain. I tried a number of different renders, but only one worked:
file format video audio result
QTforLinux MPEG4 MPEG4 no (crashed iTunes 7.1)
QTforLinux MPEG4 MP3 no
QTforLinux MPEG4 WAV yes
QTforLinux H.264 MPEG4 cinelerra hung
At this point, I'm not sure if its my Fedora 7, x86-64 libraries or just iTunes being very selective about what it likes and dislikes. Just for kicks, tonight I will render out the same file using Fedora 6, i386 and see if the results are the same. Once I finish my research, I'll update the Beginner's Guide.
the mule
file format video audio result
QTforLinux MPEG4 MPEG4 no (crashed iTunes 7.1)
QTforLinux MPEG4 MP3 no
QTforLinux MPEG4 WAV yes
QTforLinux H.264 MPEG4 cinelerra hung
At this point, I'm not sure if its my Fedora 7, x86-64 libraries or just iTunes being very selective about what it likes and dislikes. Just for kicks, tonight I will render out the same file using Fedora 6, i386 and see if the results are the same. Once I finish my research, I'll update the Beginner's Guide.
the mule
Labels:
cinelerra,
dvd,
itunes,
macbook pro,
quicktime for linux
If this post was useful to you..consider buying me a beer via PayPal!
Even a $1 Draft will keep the Mule happily working..and help pay for equipment upgrades!
Tuesday, January 01, 2008
method to create a menuless DVD
Happy 2008, everybody!
I keep forgetting the commands to create and burn DVD-ready files from Cinelerra. As the following commands worked well for me, I thought I'd write 'em down for folks. I won't concentrate on creating the DVD-ready file, but more on the latter steps using dvdauthor and burning an iso.
In order to get a working DVD, you're going to do the following:
1 - from Cinelerra, create a valid DVD-ready MPEG file
2 - with dvdauthor, create a DVD filesystem from that MPEG
3 - with dvdauthor, create a table of contents for the DVD filesystem
4 - with mkisofs, create a DVD-ready ISO image in prep for burning to DVD
5 - with growisofs, burn the DVD
PrerequisitesCinelerra
mplex
dvdauthor
dvd+rw-tools
References
http://gentoo-wiki.com/HOWTO_Create_a_DVD:Burn
http://gentoo-wiki.com/HOWTO_Mencoder_Introduction_Guide
1 - Create a valid DVD-ready MPEG file
In Cinelerra, create a project with the following specs:
Audio
Samplerate: 48000
Channels: 2
Video
Framerate: 29.97
Width: 720
Height: 480
W/H Ratios both 1
Color Model: YUVA-8bit
Aspect Ratio: 3:2 or check Auto
Interlace Mode: Not Interlaced
Render Options
Audio
File Format: MPEG Audio
Layer: II
Kbits per second: 384Kbps
Video
File Format: YUV4MPEG
Either mpeg2enc or ffmpeg presets should work. Just make sure the aspect ratio of the resultant video is 16:9, because dvdauthor will not create the DVD filesystem if this is not the case. The switch to ffmpeg is "-aspect 16:9" or "aspect 1.777" like so:
ffmpeg -f yuv4mpegpipe -i - -y -target dvd -aspect 1.777 -f mpeg2video %
Since multiplexing to DVD-ready file in ffmpeg doesn't work as expected, I combine the audio and video with MPLEX using this command:
mplex -f 8 -o test.mpg video.m2v audio.mp2
I will try to figure out the source of the ffmpeg issue later.
2 - Create a DVD filesystem from MPEG
Using dvdauthor, run this command to create a filesystem in a folder called "dvd" from your test mpeg:
[mule@ogre ~]# dvdauthor -o dvd/ -t test.mpg
DVDAuthor::dvdauthor, version 0.6.14.
Build options: gnugetopt iconv freetype fribidi
Send bugs to
INFO: dvdauthor creating VTS
STAT: Picking VTS 03
STAT: Processing test.mpg...
STAT: VOBU 1488 at 394MB, 1 PGCS
INFO: Video pts = 0.133 .. 598.564
INFO: Audio[8] pts = 0.133 .. 598.621
STAT: VOBU 1499 at 395MB, 1 PGCS
INFO: Generating VTS with the following video attributes:
INFO: MPEG version: mpeg2
INFO: TV standard: ntsc
INFO: Aspect ratio: 16:9
INFO: Resolution: 720x480
INFO: Audio ch 0 format: mp2/2ch, 48khz 20bps
STAT: fixed 1499 VOBUS
3 - Create a Table of Contents
Using dvdauthor, run this command to create a table of contents for the DVD filesystem:
[mule@ogre ~]# dvdauthor -o dvd/ -T
DVDAuthor::dvdauthor, version 0.6.14.
Build options: gnugetopt iconv freetype fribidi
Send bugs to
INFO: dvdauthor creating table of contents
INFO: Scanning dvd/VIDEO_TS/VTS_01_0.IFO
INFO: Scanning dvd/VIDEO_TS/VTS_02_0.IFO
INFO: Scanning dvd/VIDEO_TS/VTS_03_0.IFO
INFO: Scanning dvd/VIDEO_TS/VTS_04_0.IFO
4 - Create a DVD-ready ISO image for burning
Using mkisofs, create an ISO image:
[mule@ogre ~]# mkisofs -dvd-video -o dvd.iso dvd/
I: -input-charset not specified, using utf-8 (detected in locale settings)
Unknown file type (unallocated) dvd/.. - ignoring and continuing.
0.51% done, estimate finish Mon Dec 31 20:31:57 2007
1.02% done, estimate finish Mon Dec 31 20:31:57 2007
..
99.07% done, estimate finish Mon Dec 31 20:32:50 2007
99.58% done, estimate finish Mon Dec 31 20:32:50 2007
Total translation table size: 0
Total rockridge attributes bytes: 0
Total directory bytes: 4380
Path table size(bytes): 42
Max brk space used 0
979076 extents written (1912 MB)
Here's nice tip on testing your ISO by mouting it from your filesystem:
http://gentoo-wiki.com/TIP_Mounting_Iso_Files
5 - Burn the ISO image to a DVD
Using growisofs, burn the ISO image to a DVD. Note that I used this command on a DVD RW:
[mule@ogre ~]# growisofs -dvd-compat -Z /dev/dvd=dvd.iso
Executing 'builtin_dd if=dvd.iso of=/dev/dvd obs=32k seek=0'
/dev/dvd: "Current Write Speed" is 2.0x1352KBps.
3407872/2005147648 ( 0.2%) @0.5x, remaining 39:09 RBU 100.0% UBU 6.5%
12288000/2005147648 ( 0.6%) @1.9x, remaining 18:55 RBU 100.0% UBU 100.0%
..
1992097792/2005147648 (99.3%) @2.0x, remaining 0:04 RBU 77.9% UBU 100.0%
2001076224/2005147648 (99.8%) @1.9x, remaining 0:01 RBU 24.4% UBU 100.0%
builtin_dd: 979088*2KB out @ average 1.9x1352KBps
/dev/dvd: flushing cache
/dev/dvd: writing lead-out
Appendix
Formatting a DVD RW
Using dvd+rw-format, format your DVD RW media:
[mule@ogre Desktop]# dvd+rw-format -f /dev/dvd
* BD/DVD±RW/-RAM format utility by, version 7.0.
* 4.7GB DVD-RW media in Restricted Overwrite mode detected.
* formatting 29.2/
That's it. Happy New Year!
The Mule
I keep forgetting the commands to create and burn DVD-ready files from Cinelerra. As the following commands worked well for me, I thought I'd write 'em down for folks. I won't concentrate on creating the DVD-ready file, but more on the latter steps using dvdauthor and burning an iso.
In order to get a working DVD, you're going to do the following:
1 - from Cinelerra, create a valid DVD-ready MPEG file
2 - with dvdauthor, create a DVD filesystem from that MPEG
3 - with dvdauthor, create a table of contents for the DVD filesystem
4 - with mkisofs, create a DVD-ready ISO image in prep for burning to DVD
5 - with growisofs, burn the DVD
PrerequisitesCinelerra
mplex
dvdauthor
dvd+rw-tools
References
http://gentoo-wiki.com/HOWTO_Create_a_DVD:Burn
http://gentoo-wiki.com/HOWTO_Mencoder_Introduction_Guide
1 - Create a valid DVD-ready MPEG file
In Cinelerra, create a project with the following specs:
Audio
Samplerate: 48000
Channels: 2
Video
Framerate: 29.97
Width: 720
Height: 480
W/H Ratios both 1
Color Model: YUVA-8bit
Aspect Ratio: 3:2 or check Auto
Interlace Mode: Not Interlaced
Render Options
Audio
File Format: MPEG Audio
Layer: II
Kbits per second: 384Kbps
Video
File Format: YUV4MPEG
Either mpeg2enc or ffmpeg presets should work. Just make sure the aspect ratio of the resultant video is 16:9, because dvdauthor will not create the DVD filesystem if this is not the case. The switch to ffmpeg is "-aspect 16:9" or "aspect 1.777" like so:
ffmpeg -f yuv4mpegpipe -i - -y -target dvd -aspect 1.777 -f mpeg2video %
Since multiplexing to DVD-ready file in ffmpeg doesn't work as expected, I combine the audio and video with MPLEX using this command:
mplex -f 8 -o test.mpg video.m2v audio.mp2
I will try to figure out the source of the ffmpeg issue later.
2 - Create a DVD filesystem from MPEG
Using dvdauthor, run this command to create a filesystem in a folder called "dvd" from your test mpeg:
[mule@ogre ~]# dvdauthor -o dvd/ -t test.mpg
DVDAuthor::dvdauthor, version 0.6.14.
Build options: gnugetopt iconv freetype fribidi
Send bugs to
INFO: dvdauthor creating VTS
STAT: Picking VTS 03
STAT: Processing test.mpg...
STAT: VOBU 1488 at 394MB, 1 PGCS
INFO: Video pts = 0.133 .. 598.564
INFO: Audio[8] pts = 0.133 .. 598.621
STAT: VOBU 1499 at 395MB, 1 PGCS
INFO: Generating VTS with the following video attributes:
INFO: MPEG version: mpeg2
INFO: TV standard: ntsc
INFO: Aspect ratio: 16:9
INFO: Resolution: 720x480
INFO: Audio ch 0 format: mp2/2ch, 48khz 20bps
STAT: fixed 1499 VOBUS
3 - Create a Table of Contents
Using dvdauthor, run this command to create a table of contents for the DVD filesystem:
[mule@ogre ~]# dvdauthor -o dvd/ -T
DVDAuthor::dvdauthor, version 0.6.14.
Build options: gnugetopt iconv freetype fribidi
Send bugs to
INFO: dvdauthor creating table of contents
INFO: Scanning dvd/VIDEO_TS/VTS_01_0.IFO
INFO: Scanning dvd/VIDEO_TS/VTS_02_0.IFO
INFO: Scanning dvd/VIDEO_TS/VTS_03_0.IFO
INFO: Scanning dvd/VIDEO_TS/VTS_04_0.IFO
4 - Create a DVD-ready ISO image for burning
Using mkisofs, create an ISO image:
[mule@ogre ~]# mkisofs -dvd-video -o dvd.iso dvd/
I: -input-charset not specified, using utf-8 (detected in locale settings)
Unknown file type (unallocated) dvd/.. - ignoring and continuing.
0.51% done, estimate finish Mon Dec 31 20:31:57 2007
1.02% done, estimate finish Mon Dec 31 20:31:57 2007
..
99.07% done, estimate finish Mon Dec 31 20:32:50 2007
99.58% done, estimate finish Mon Dec 31 20:32:50 2007
Total translation table size: 0
Total rockridge attributes bytes: 0
Total directory bytes: 4380
Path table size(bytes): 42
Max brk space used 0
979076 extents written (1912 MB)
Here's nice tip on testing your ISO by mouting it from your filesystem:
http://gentoo-wiki.com/TIP_Mounting_Iso_Files
5 - Burn the ISO image to a DVD
Using growisofs, burn the ISO image to a DVD. Note that I used this command on a DVD RW:
[mule@ogre ~]# growisofs -dvd-compat -Z /dev/dvd=dvd.iso
Executing 'builtin_dd if=dvd.iso of=/dev/dvd obs=32k seek=0'
/dev/dvd: "Current Write Speed" is 2.0x1352KBps.
3407872/2005147648 ( 0.2%) @0.5x, remaining 39:09 RBU 100.0% UBU 6.5%
12288000/2005147648 ( 0.6%) @1.9x, remaining 18:55 RBU 100.0% UBU 100.0%
..
1992097792/2005147648 (99.3%) @2.0x, remaining 0:04 RBU 77.9% UBU 100.0%
2001076224/2005147648 (99.8%) @1.9x, remaining 0:01 RBU 24.4% UBU 100.0%
builtin_dd: 979088*2KB out @ average 1.9x1352KBps
/dev/dvd: flushing cache
/dev/dvd: writing lead-out
Appendix
Formatting a DVD RW
Using dvd+rw-format, format your DVD RW media:
[mule@ogre Desktop]# dvd+rw-format -f /dev/dvd
* BD/DVD±RW/-RAM format utility by
* 4.7GB DVD-RW media in Restricted Overwrite mode detected.
* formatting 29.2/
That's it. Happy New Year!
The Mule
If this post was useful to you..consider buying me a beer via PayPal!
Even a $1 Draft will keep the Mule happily working..and help pay for equipment upgrades!
Sunday, May 27, 2007
dar: a solution to archiving video
Like myself, you may have gigs and gigs of video sitting on your hard drive, taking up space that should be used for live projects or new media. And you've filled up your 500GB drive, so that you are constantly having to do piecemeal copies of older material to DVD+R. I have the same problem. But as I get older, I try to be a little wiser and actually solve my problems instead of living with them.
I will make the distinction that you should be using DVD+R for your archives. I have found +Rs to be more reliable for data archival that -Rs.
Here's the problem with doing a straight copy of media files to DVD+R. Look at the directory listing below:
[root@computer ~]# ll /mnt/videos/20050721/
total 20871112
-rwxr-xr-x 1 root root 1469679848 Oct 18 2006 1.m2t-rwxr-xr-x 1 root root 58916 Oct 21 2006 20050721b.xml-rwxr-xr-x 1 root root 3877924864 Oct 22 2006 20050721dvd.mpg-rwxr-xr-x 1 root root 1130843124 Oct 29 2006 20050721.m2t
-rwxr-xr-x 1 root root 45197 Oct 20 2006 20050721.xml
-rwxr-xr-x 1 root root 70478 Oct 21 2006 20060721c.xml
-rwxr-xr-x 1 root root 70431 Oct 24 2006 20060721d.xml
-rwxr-xr-x 1 root root 71543 Oct 24 2006 20060721e.xml
-rwxr-xr-x 1 root root 8549 Oct 25 2006 20060721small.xml
-rwxr-xr-x 1 root root 2065588524 Oct 18 2006 2.m2t
-rwxr-xr-x 1 root root 1755983168 Oct 18 2006 3.m2t
-rwxr-xr-x 1 root root 902360332 Oct 18 2006 4.m2t
-rwxr-xr-x 1 root root 1491412084 Oct 18 2006 5.m2t
-rwxr-xr-x 1 root root 2865367596 Oct 18 2006 6.m2t
-rwxr-xr-x 1 root root 5461152404 Oct 18 2006 7.m2t
Here we see the typical mess of Cinelerra project files, source material (HDV MPEGTS files), and final renders (MPEGs). Now, totaling up the space used for these file, you get about 21GB. Ugh. And given the odd file sizes, you'd end up using about 7 DVDs just to backup what you've got. This is because HDV files are huge, ranging from 1.5GB to 5GB and DVDs only hold about 4.38GB usable space on each. So you're forced to do a statistical combinations balancing act in order to fit as many files on a DVD in the most efficient manner possible. We who live in the land of video production are all living and breathing this headache. What a pain in the ass. But what is the alternative?
The alternative is to find a program that can compress and archive files over multiple DVDs, grouping these files of different sizes and compacting them together. Most importantly, the software should then evenly divide the compressed file archive across multiple DVDs in the most efficient and space conscious manner possible.
Well, lucky for us, the Linux Gods have brought down "dar" from the heavens. Dar (disk archive), available at http://dar.linux.free.fr/, is a command line backup and restore tool that can compress files using the bz2 algorithm, put files into a single archive and divide that archive into manageable chunks destined for backup media of one type or another. For the file listing you see above, dar was able to take it and turn it into this:
[root@computer ~]# ll /mnt/videos/2007-05-27_data.*
-rw-r--r-- 1 root root 4194304000 May 27 2007-05-27_data.1.dar
-rw-r--r-- 1 root root 4194304000 May 27 2007-05-27_data.2.dar
-rw-r--r-- 1 root root 4194304000 May 27 2007-05-27_data.3.dar
-rw-r--r-- 1 root root 4194304000 May 27 2007-05-27_data.4.dar
-rw-r--r-- 1 root root 3912021642 May 27 2007-05-27_data.5.dar
Nice! Easily digestible chunks for a single layer DVD to handle!
Now, the compression that dar acheived was not very much. Total file size went from 2.135GB to about 2.06GB. This is because the MPEGTS files are already compressed, so I'm not going to gain much from bz2. My 3.2Ghz, 2GB, PC3200, RAID0 (stripe set of two IDE drives), Dell 400SC took about three hours and twenty minutes to compress that 21GB. So it's not fast.
Before you get too excited, here are some known limitations of dar:
http://dar.linux.free.fr/doc/Limitations.html
I made sure to give dar a full system test using the steps below.
1) archive the above directory of files
TIME: about three hours and twenty minutes on the system described above.
dar -m 256 -v -y -s 4000M -D -R /mnt/videos/20050721/ -c `date -I`_data
Adding file to archive: /mnt/videos/20050721/20050721e.xml
Adding file to archive: /mnt/videos/20050721/addSecond.sh
..
Update 2008/12/22
If you have 120 minute, 4.7GB DVD+Rs, you can up the number of bytes in each dar to 4400MB or 4,613,734,400 or (4400 x 1024 x 1024):
dar -m 256 -v -y -s 4400M -D -R /mnt/videos/20050721/ -c `date -I`_data
Note: you made need the latest and greatest version of dvd+rw-tools for this large filesize burning to work! I tested this on Fedora 10 and I was able to store and retrieve a 25GB dar archive using this procedure.
Note that you will need to use the "-allow-limited-size" switch to growisofs when you burn these larger than normal files to dvd:
growisofs -Z /dev/dvd -R -J -allow-limited-size filename.dar
end update
In short, the switches I used mean:
Here's the output of that command:
--------------------------------------------
17 inode(s) saved
with 0 hard link(s) recorded
0 inode(s) changed at the moment of the backup
0 inode(s) not saved (no file change)
0 inode(s) failed to save (filesystem error)
0 files(s) ignored (excluded by filters)
0 files(s) recorded as deleted from reference backup
--------------------------------------------
Total number of file considered: 17
--------------------------------------------
The command line switches I used above are well summarized in this HowTo:
http://dar.linux.free.fr/doc/mini-howto/index.html
Also, for you man page readers, here's the nitty gritty:
http://www.die.net/doc/linux/man/man1/dar.1.html
2) validate that the archive is does not contain errors
TIME: about an hour and a half.
dar -t <archive name>
Here is the output of that command:
--------------------------------------------
17 file(s) treated
0 file(s) with error
0 file(s) ignored (excluded by filters)
--------------------------------------------
Total number of file considered: 17
--------------------------------------------
Also, it is helpful to list out the contents of the created dar in order to verify it matches the files you want archived. Here is sample output from another archive I created:
3) write each output file from dar to DVD
TIME: with a 18x burner running at 16x speed to DVD+R, this takes about an hour.
First, check your media:
dvd+rw-mediainfo /dev/dvd
Then burn your archive to disk:
growisofs -Z /dev/dvd -R -J /root/2007-05-27_data.1.dar
..
If you intend to do a lot of archiving, I suggest you purchase a recent model DVD+R recorder. When I first tested dar this past weekend, I had a mess of problems reading the archive files I had burned successfully to DVD. I figured my DVD was three years old and it was time for an upgrade, so I bought the internal version of this drive, the HP DVD940E External 18x Super Multi DVD Writer
for $60 with a $30 rebate from Office Depot. The thing performs like a champ!
4) copy the archive from the DVDs to disk
TIME: with an 18x burner, this takes about twenty minutes.
mount /dev/cdrom /mnt/cdrom
cp /mnt/cdrom/* /mnt/videos/
5) validate that the archive files off the DVD do not contain errors
TIME: about an hour and a half.
dar -t <archive name>
While validating my archives off DVD, I encountered one problem:
[root@computer ~]# dar -t /mnt/videos/2007-05-27_data
ERR/6.m2t : compressed data CRC error
--------------------------------------------
17 file(s) treated
1 file(s) with error
0 file(s) ignored (excluded by filters)
--------------------------------------------
Total number of file considered: 17
--------------------------------------------
Bad news. It looks like the data written to one of the DVDs is corrupt. Since I had the originals files and they tested out correct, I re-wrote the archive to new DVDs and did not encounter this problem again. By the way, the test of my 20GB archives took about an hour.
Here is what a successful validation looks like:
[root@computer ~]# dar -t 20081016_data
--------------------------------------------
17 inode(s) treated
0 inode(s) with error
0 inode(s) ignored (excluded by filters)
--------------------------------------------
Total number of inode considered: 17
--------------------------------------------
6) if no errors, restore original files and verify file sizes
TIME: about three hours.
This step is optional, if you've already run "dar -t" to verify the integrity of the archive coming off the DVD. Here is the output:
dar -x 2007-05-27_data
--------------------------------------------
17 file(s) restored
0 file(s) not restored (not saved in archive)
0 file(s) ignored (excluded by filters)
0 file(s) less recent than the one on filesystem
0 file(s) failed to restore (filesystem error)
0 file(s) deleted
--------------------------------------------
Total number of file considered: 17
--------------------------------------------
There was some slowness copying the archives back from DVD (which took about two hours at 4x speed), but that's just the speed of the DVD player. Aside from that 4GB limit, dar live up to its reputation! So I'm pretty happy.
Review
1) archive your files
TIME: about three hours and twenty minutes on the system described above.
dar -m 256 -v -y -s 4000M -D -R /mnt/videos/20050721/ -c `date -I`_data
2) validate that the archive is does not contain errors
TIME: about an hour and a half.
dar -t <archive name>
3) write each output file from dar to DVD
TIME: with a 18x burner running at 16x speed to DVD+R, this takes about an hour.
growisofs -Z /dev/dvd -R -J /root/2007-05-27_data.1.dar
4) copy the archive from the DVDs to disk
TIME: with an 18x burner, this takes about twenty minutes.
cp /mnt/cdrom/* /mnt/videos/
5) validate that the archive files off the DVD do not contain errors
TIME: about an hour and a half.
dar -t <archive name>
OPTIONAL:
6) if no errors, restore original files and verify file sizes
TIME: about three hours.
dar -x 2007-05-27_data
Summary
If you wish to use dar and want to keep your valuable video data in tact for years to come, I strongly suggest you run through steps 1-5 each time you make an archive! Of course, just the basic steps take a total of eight hours for 20GB of data. The optional step brings that total to eleven hours of your time spent.
Of course, you don't have to archive EVERYTHING. Only archive the source videos and maybe the primary intermediates. For example, I archive all my MPEG-TS files from my cam, plus the MPEG2 video and MP3 audio rendered from my project. I DON'T archive the finals: DVD format, iTunes format and MPEG program streams, as I can always reproduce those from the primary intermediates that are rendered from the project.
In the end, you have to ask yourself "How much do I value the work that I've done?"
Going through these steps everytime you make an archive may seem like a pain, but the pain will be worse if your data goes away! You could opt to store your media on a hard drive, but if that hard drive gets near a speaker or large magnet, your data could be lost. If you are going to archive this data for years, it makes more sense to do it on optical formats that are not susceptible to damage by magnetism.
If you do decide to go the dar route and follow these steps, you'll have the peace of mind that your archives are error free.
Hopefully, dar might fit into your backup and recovery schemes. There are a number of other softwares to do something similar. Partimage on the http://www.sysresccd.org comes to mind, though that is used for entire partitions. Also Duplicity is available, but that's strength is in encryption and network backups. To its strength, dar is a proven solution and is very well documented:
http://dar.linux.free.fr/doc/
As I have time, I will post a bit more technical information about the commands used, but the best idea is to research the documentation at the link above, as well as do a simple "dar -h" at the command line for a listing of all the available features.
Update 1/4/2014
The Extraction Process Redux
I've been restoring dar archives from DVDs. Today, I pulled out a couple five DVD dar archives that I originally created four years ago. Each DVD took about six minutes to copy over to my hard drive. I'm happy to say that dar restored the individual video files that I specified without any problems. Here's a sample command:
dar -x 20090430_data -g 20090430.m2v
However, dar did spit out this message:
File ownership will not be restored as dar is not run as root. to avoid this message use -O option [return = YES | Esc = NO]
Continuing...
Error met while opening the last slice: This is an old archive, it can only be opened starting by the first slice. Trying to open the archive using the first slice...
Even with this message, the archived files restored without error.
The commands above mean:
-x = extract
-g = subdirectory to include in the operation
Also, another good switch is -O, to avoid the "root ownership" message seen above. Be careful of the placement of -O..it has to be the first parameter. Like so:
dar -O -x 20090430_data -g 20090430.m2v
After giving the -O parameter in the above command, all you should see is the "Error met while opening the last slice" message.
Update 10/1/2008
The Extraction Process
I pulled out a 6 DVD dar archive that I originally created more than a year ago and I'm happy to say that dar restored the files without any problems. Specifically, I needed to pull one MPEG video from a dar archive of about 25 files. The dar command to extract one specific file was relatively simple:
dar -x -I *.mpg
-x = extract
-I = include following filespec in operation
So my command ended up looking like this:
dar -x /mule/20060831 -I *.mpg
One thing I noticed is that depending on the archive, wildcards (like *.mpg) may work, but not all the time. In which case, you should remove the wildcard from the include specification and just use the exact syntax; eg:
dar -x /mule/20060831 -I file.mpg
That's it!
Have a good day!
The Video Mule
5/30/07 update - After using dar for the past couple of days and releasing about 50GB, I have to say that I am really starting to like this new process. It is a consistent, repeatable and efficient approach to archiving my material that I can kick off before bedtime.
10/1/08 update - Dargui is a nice, simple graphical front end to dar. For some reason, though, the filter did not work properly, so I reverted to command line. Perhaps someone else will have better luck.
References
http://dargui.sourceforge.net/
http://dar.linux.free.fr/doc/mini-howto/dar-differential-backup-mini-howto.en.html
I will make the distinction that you should be using DVD+R for your archives. I have found +Rs to be more reliable for data archival that -Rs.
Here's the problem with doing a straight copy of media files to DVD+R. Look at the directory listing below:
[root@computer ~]# ll /mnt/videos/20050721/
total 20871112
-rwxr-xr-x 1 root root 1469679848 Oct 18 2006 1.m2t-rwxr-xr-x 1 root root 58916 Oct 21 2006 20050721b.xml-rwxr-xr-x 1 root root 3877924864 Oct 22 2006 20050721dvd.mpg-rwxr-xr-x 1 root root 1130843124 Oct 29 2006 20050721.m2t
-rwxr-xr-x 1 root root 45197 Oct 20 2006 20050721.xml
-rwxr-xr-x 1 root root 70478 Oct 21 2006 20060721c.xml
-rwxr-xr-x 1 root root 70431 Oct 24 2006 20060721d.xml
-rwxr-xr-x 1 root root 71543 Oct 24 2006 20060721e.xml
-rwxr-xr-x 1 root root 8549 Oct 25 2006 20060721small.xml
-rwxr-xr-x 1 root root 2065588524 Oct 18 2006 2.m2t
-rwxr-xr-x 1 root root 1755983168 Oct 18 2006 3.m2t
-rwxr-xr-x 1 root root 902360332 Oct 18 2006 4.m2t
-rwxr-xr-x 1 root root 1491412084 Oct 18 2006 5.m2t
-rwxr-xr-x 1 root root 2865367596 Oct 18 2006 6.m2t
-rwxr-xr-x 1 root root 5461152404 Oct 18 2006 7.m2t
Here we see the typical mess of Cinelerra project files, source material (HDV MPEGTS files), and final renders (MPEGs). Now, totaling up the space used for these file, you get about 21GB. Ugh. And given the odd file sizes, you'd end up using about 7 DVDs just to backup what you've got. This is because HDV files are huge, ranging from 1.5GB to 5GB and DVDs only hold about 4.38GB usable space on each. So you're forced to do a statistical combinations balancing act in order to fit as many files on a DVD in the most efficient manner possible. We who live in the land of video production are all living and breathing this headache. What a pain in the ass. But what is the alternative?
The alternative is to find a program that can compress and archive files over multiple DVDs, grouping these files of different sizes and compacting them together. Most importantly, the software should then evenly divide the compressed file archive across multiple DVDs in the most efficient and space conscious manner possible.
Well, lucky for us, the Linux Gods have brought down "dar" from the heavens. Dar (disk archive), available at http://dar.linux.free.fr/, is a command line backup and restore tool that can compress files using the bz2 algorithm, put files into a single archive and divide that archive into manageable chunks destined for backup media of one type or another. For the file listing you see above, dar was able to take it and turn it into this:
[root@computer ~]# ll /mnt/videos/2007-05-27_data.*
-rw-r--r-- 1 root root 4194304000 May 27 2007-05-27_data.1.dar
-rw-r--r-- 1 root root 4194304000 May 27 2007-05-27_data.2.dar
-rw-r--r-- 1 root root 4194304000 May 27 2007-05-27_data.3.dar
-rw-r--r-- 1 root root 4194304000 May 27 2007-05-27_data.4.dar
-rw-r--r-- 1 root root 3912021642 May 27 2007-05-27_data.5.dar
Nice! Easily digestible chunks for a single layer DVD to handle!
Now, the compression that dar acheived was not very much. Total file size went from 2.135GB to about 2.06GB. This is because the MPEGTS files are already compressed, so I'm not going to gain much from bz2. My 3.2Ghz, 2GB, PC3200, RAID0 (stripe set of two IDE drives), Dell 400SC took about three hours and twenty minutes to compress that 21GB. So it's not fast.
Before you get too excited, here are some known limitations of dar:
http://dar.linux.free.fr/doc/Limitations.html
I made sure to give dar a full system test using the steps below.
1) archive the above directory of files
TIME: about three hours and twenty minutes on the system described above.
dar -m 256 -v -y -s 4000M -D -R /mnt/videos/20050721/ -c `date -I`_data
Adding file to archive: /mnt/videos/20050721/20050721e.xml
Adding file to archive: /mnt/videos/20050721/addSecond.sh
..
Update 2008/12/22
If you have 120 minute, 4.7GB DVD+Rs, you can up the number of bytes in each dar to 4400MB or 4,613,734,400 or (4400 x 1024 x 1024):
dar -m 256 -v -y -s 4400M -D -R /mnt/videos/20050721/ -c `date -I`_data
Note: you made need the latest and greatest version of dvd+rw-tools for this large filesize burning to work! I tested this on Fedora 10 and I was able to store and retrieve a 25GB dar archive using this procedure.
Note that you will need to use the "-allow-limited-size" switch to growisofs when you burn these larger than normal files to dvd:
growisofs -Z /dev/dvd -R -J -allow-limited-size filename.dar
end update
In short, the switches I used mean:
-m 256 = don't compress files less than 256 bytes
-v = verbose output showing what is being archived
-y = activate bz2 compression
-s 4000M = create archives 4000MB in size. 4000MB is 1024x1024x4000 bytes or 4,194,304,000 bytes.
By the way, 4GB is actually 2 to the 32 power or 4,294,967,296 bytes.
-D = store directories excluded by the -P option or absent from the command line path list as empty directories
-R = specify the root directory for saving or restoring files
-c = create the archive with the following name, using the current date
Here's the output of that command:
--------------------------------------------
17 inode(s) saved
with 0 hard link(s) recorded
0 inode(s) changed at the moment of the backup
0 inode(s) not saved (no file change)
0 inode(s) failed to save (filesystem error)
0 files(s) ignored (excluded by filters)
0 files(s) recorded as deleted from reference backup
--------------------------------------------
Total number of file considered: 17
--------------------------------------------
The command line switches I used above are well summarized in this HowTo:
http://dar.linux.free.fr/doc/mini-howto/index.html
Also, for you man page readers, here's the nitty gritty:
http://www.die.net/doc/linux/man/man1/dar.1.html
2) validate that the archive is does not contain errors
TIME: about an hour and a half.
dar -t <archive name>
Here is the output of that command:
--------------------------------------------
17 file(s) treated
0 file(s) with error
0 file(s) ignored (excluded by filters)
--------------------------------------------
Total number of file considered: 17
--------------------------------------------
Also, it is helpful to list out the contents of the created dar in order to verify it matches the files you want archived. Here is sample output from another archive I created:
[root@computer ~]# dar -l 20081016_data
[data ][ EA ][compr] | permission | user | group | size | date | filename
----------------------+------------+-------+-------+-------+-------------------------------+------------
[Saved] [ 90%] -rw-r--r-- root root 46335 Tue Oct 21 22:09:02 2008 20081016e.xml
[Saved] [ 46%] -rwxr-xr-x root root 990 Sat Oct 18 16:56:45 2008 addSecond.sh
[Saved] [ 8%] -rw-r--r-- root root 5663820164 Sat Oct 18 09:25:36 2008 20081016_6.m2t
[Saved] [ 2%] -rw-r--r-- root root 26411454 Sun Oct 26 16:29:52 2008 test.mov
[Saved] [ 91%] -rw-r--r-- root root 55587 Mon Oct 27 08:23:02 2008 20081016i.xml
[Saved] [ 79%] -rw-r--r-- root root 13680 Sat Oct 18 15:41:23 2008 20081016a.xml
[Saved] [ 47%] -rwxr-xr-x root root 1408 Sat Oct 18 17:50:51 2008 2songlist.sh
[Saved] [ 51%] -rw-r--r-- root root 1688 Wed Oct 22 08:19:37 2008 vodcastNew.xml
[Saved] [ 47%] -rwxr-xr-x root root 2411 Sat Oct 18 19:13:01 2008 1encode.sh.bak
[Saved] [ 8%] -rw-r--r-- root root 1143234956 Sat Oct 18 09:11:36 2008 20081016_4.m2t
[Saved] [ 5%] -rw-r--r-- root root 3805975877 Mon Oct 27 04:49:50 2008 StormPigs20081016.m2v
[Saved] [ ] -rwxr-xr-x root root 146 Sat Oct 18 17:56:25 2008 5ftp.sh
[Saved] [ 10%] -rw-r--r-- root root 804122436 Sat Oct 18 09:02:08 2008 20081016_1.m2t
[Saved] [ 8%] -rw-r--r-- root root 2091780308 Sat Oct 18 09:05:45 2008 20081016_2.m2t
[Saved] [ 88%] -rw-r--r-- root root 30648 Tue Oct 21 21:07:01 2008 20081016c.xml
[Saved] [ 89%] -rw-r--r-- root root 40105 Tue Oct 21 21:32:46 2008 20081016d.xml
[Saved] [ 79%] -rw-r--r-- root root 12197 Sat Oct 18 15:13:20 2008 20081016.xml
..
3) write each output file from dar to DVD
TIME: with a 18x burner running at 16x speed to DVD+R, this takes about an hour.
First, check your media:
dvd+rw-mediainfo /dev/dvd
Then burn your archive to disk:
growisofs -Z /dev/dvd -R -J /root/2007-05-27_data.1.dar
..
If you intend to do a lot of archiving, I suggest you purchase a recent model DVD+R recorder. When I first tested dar this past weekend, I had a mess of problems reading the archive files I had burned successfully to DVD. I figured my DVD was three years old and it was time for an upgrade, so I bought the internal version of this drive, the HP DVD940E External 18x Super Multi DVD Writer
4) copy the archive from the DVDs to disk
TIME: with an 18x burner, this takes about twenty minutes.
mount /dev/cdrom /mnt/cdrom
cp /mnt/cdrom/* /mnt/videos/
5) validate that the archive files off the DVD do not contain errors
TIME: about an hour and a half.
dar -t <archive name>
While validating my archives off DVD, I encountered one problem:
[root@computer ~]# dar -t /mnt/videos/2007-05-27_data
ERR
--------------------------------------------
17 file(s) treated
1 file(s) with error
0 file(s) ignored (excluded by filters)
--------------------------------------------
Total number of file considered: 17
--------------------------------------------
Bad news. It looks like the data written to one of the DVDs is corrupt. Since I had the originals files and they tested out correct, I re-wrote the archive to new DVDs and did not encounter this problem again. By the way, the test of my 20GB archives took about an hour.
Here is what a successful validation looks like:
[root@computer ~]# dar -t 20081016_data
--------------------------------------------
17 inode(s) treated
0 inode(s) with error
0 inode(s) ignored (excluded by filters)
--------------------------------------------
Total number of inode considered: 17
--------------------------------------------
6) if no errors, restore original files and verify file sizes
TIME: about three hours.
This step is optional, if you've already run "dar -t" to verify the integrity of the archive coming off the DVD. Here is the output:
dar -x 2007-05-27_data
--------------------------------------------
17 file(s) restored
0 file(s) not restored (not saved in archive)
0 file(s) ignored (excluded by filters)
0 file(s) less recent than the one on filesystem
0 file(s) failed to restore (filesystem error)
0 file(s) deleted
--------------------------------------------
Total number of file considered: 17
--------------------------------------------
There was some slowness copying the archives back from DVD (which took about two hours at 4x speed), but that's just the speed of the DVD player. Aside from that 4GB limit, dar live up to its reputation! So I'm pretty happy.
Review
1) archive your files
TIME: about three hours and twenty minutes on the system described above.
dar -m 256 -v -y -s 4000M -D -R /mnt/videos/20050721/ -c `date -I`_data
2) validate that the archive is does not contain errors
TIME: about an hour and a half.
dar -t <archive name>
3) write each output file from dar to DVD
TIME: with a 18x burner running at 16x speed to DVD+R, this takes about an hour.
growisofs -Z /dev/dvd -R -J /root/2007-05-27_data.1.dar
4) copy the archive from the DVDs to disk
TIME: with an 18x burner, this takes about twenty minutes.
cp /mnt/cdrom/* /mnt/videos/
5) validate that the archive files off the DVD do not contain errors
TIME: about an hour and a half.
dar -t <archive name>
OPTIONAL:
6) if no errors, restore original files and verify file sizes
TIME: about three hours.
dar -x 2007-05-27_data
Summary
If you wish to use dar and want to keep your valuable video data in tact for years to come, I strongly suggest you run through steps 1-5 each time you make an archive! Of course, just the basic steps take a total of eight hours for 20GB of data. The optional step brings that total to eleven hours of your time spent.
Of course, you don't have to archive EVERYTHING. Only archive the source videos and maybe the primary intermediates. For example, I archive all my MPEG-TS files from my cam, plus the MPEG2 video and MP3 audio rendered from my project. I DON'T archive the finals: DVD format, iTunes format and MPEG program streams, as I can always reproduce those from the primary intermediates that are rendered from the project.
In the end, you have to ask yourself "How much do I value the work that I've done?"
Going through these steps everytime you make an archive may seem like a pain, but the pain will be worse if your data goes away! You could opt to store your media on a hard drive, but if that hard drive gets near a speaker or large magnet, your data could be lost. If you are going to archive this data for years, it makes more sense to do it on optical formats that are not susceptible to damage by magnetism.
If you do decide to go the dar route and follow these steps, you'll have the peace of mind that your archives are error free.
Hopefully, dar might fit into your backup and recovery schemes. There are a number of other softwares to do something similar. Partimage on the http://www.sysresccd.org comes to mind, though that is used for entire partitions. Also Duplicity is available, but that's strength is in encryption and network backups. To its strength, dar is a proven solution and is very well documented:
http://dar.linux.free.fr/doc/
As I have time, I will post a bit more technical information about the commands used, but the best idea is to research the documentation at the link above, as well as do a simple "dar -h" at the command line for a listing of all the available features.
Update 1/4/2014
The Extraction Process Redux
I've been restoring dar archives from DVDs. Today, I pulled out a couple five DVD dar archives that I originally created four years ago. Each DVD took about six minutes to copy over to my hard drive. I'm happy to say that dar restored the individual video files that I specified without any problems. Here's a sample command:
dar -x 20090430_data -g 20090430.m2v
However, dar did spit out this message:
File ownership will not be restored as dar is not run as root. to avoid this message use -O option [return = YES | Esc = NO]
Continuing...
Error met while opening the last slice: This is an old archive, it can only be opened starting by the first slice. Trying to open the archive using the first slice...
Even with this message, the archived files restored without error.
The commands above mean:
-x = extract
-g = subdirectory to include in the operation
Also, another good switch is -O, to avoid the "root ownership" message seen above. Be careful of the placement of -O..it has to be the first parameter. Like so:
dar -O -x 20090430_data -g 20090430.m2v
After giving the -O parameter in the above command, all you should see is the "Error met while opening the last slice" message.
Update 10/1/2008
The Extraction Process
I pulled out a 6 DVD dar archive that I originally created more than a year ago and I'm happy to say that dar restored the files without any problems. Specifically, I needed to pull one MPEG video from a dar archive of about 25 files. The dar command to extract one specific file was relatively simple:
dar -x
-x = extract
-I = include following filespec in operation
So my command ended up looking like this:
dar -x /mule/20060831 -I *.mpg
One thing I noticed is that depending on the archive, wildcards (like *.mpg) may work, but not all the time. In which case, you should remove the wildcard from the include specification and just use the exact syntax; eg:
dar -x /mule/20060831 -I file.mpg
That's it!
Have a good day!
The Video Mule
5/30/07 update - After using dar for the past couple of days and releasing about 50GB, I have to say that I am really starting to like this new process. It is a consistent, repeatable and efficient approach to archiving my material that I can kick off before bedtime.
10/1/08 update - Dargui is a nice, simple graphical front end to dar. For some reason, though, the filter did not work properly, so I reverted to command line. Perhaps someone else will have better luck.
References
http://dargui.sourceforge.net/
http://dar.linux.free.fr/doc/mini-howto/dar-differential-backup-mini-howto.en.html
If this post was useful to you..consider buying me a beer via PayPal!
Even a $1 Draft will keep the Mule happily working..and help pay for equipment upgrades!
Sunday, May 20, 2007
using labels to split rendered video into multiple files
Now that I have my YouTube account, I can go ahead and load it up with a bunch of music videos from the band of miscreants I occasionally play music with. Now, 2006 was a fairly good year for jamming and we had a few stellar sessions at Smash Studios in NYC. The output of these jams usually results in a big video file distributed to my friends. Using Cinelerra, I edit down these three hour sessions into about an hour long video and then distribute that video to my friends via iTunes.
The distributed videos are lower resolution, usually 320x180 MOV files (MPEG4 audio/MPEG4 video) and get pretty big, around 320MB. If you're interested and you have iTunes, you can see some of these monster downloads at itpc://www.stormpigs.com/vodcast.xml.That's really too much to download for any sane person, so my task today was to break up those large videos into small, individual chunks of only the best material from 2006 that I can then upload to YouTube. And hopefully by the end of this post, I'll have some individual songs worth listening to that I can direct you to. With the caveat that the songs were created live, then and there, no rehearsal.
To get back on track, the task is to break up a Cinelerra project into bite size chunks that can then be uploaded to YouTube. This should be fairly simple.
I start with the project that I used to create the one large video. This project has all the audio and video fades and effects that I originally used to create the hour long iTunes video. The good thing about it is that the project has the breaks between video clips delineated clearly. In between the breaks are the actual songs that I'd like to divide up and render out to individual files:

The insertion point will select these breaks very easily, allowing me to set my labels for the render:

This source project is in HDV format. As I've discussed in previous posts, I edit the high resolution source and then output one final as a DVD resolution file, and then convert that DVD to an iTunes-ready format. This does impose some generational loss in quality, but the source material is not that visually stimulating (a bunch of guys in a dark room), so we're not missing much in the two steps down from HDV to iTunes. So now, I have an HDV source project and an output file rendered to DVD. In my previous post (/2007/05/how-to-upload-video-to-youtube.html, I discuss that YouTube allows me to upload up to 100MB or 10 minutes of video. In that post, I also discovered that YouTube recommends this format file:
- MPEG container
- 320x240 resolution
- MP3 audio
- MPEG I/II video
But can also accept files of this format that I can output directly from Cinelerra:
- MOV container (Quicktime for Linux)
- 720x480 resolution
- MPEG4 audio compression (256,000 constant bitrate, stereo)
- MPEG4 video compression (500,000 constant bitrate)
If I break up my project (the recording session) into videos that are less than 100MB each, I will be able to upload the best parts to YouTube. Now, I'm a pretty lazy person in general, so if I don't have to perform an extra step to convert the files from DVD resolution to the preferred 320x240 resolution, I sure as hell won't bother. The test video that I outputted in the last post (specs above) ended up being about a minute and took up about 6.6MB of space at DVD resolution. Theoretically then, I should be OK as long as my songs are less than 10 minutes long (the YouTube limit). Most are, so we should be good to go.
With the constraints understood, I should now have rougly four steps to perform:
1) append my rendered video to a new track in the original source project
2) create labels at the break points between the songs
3) delete the project's original tracks
4) reduce the project size to 720x480
5) render using labels to indicate the start of a new output file
Let's go through these steps.
1) append my rendered video to a new track in the original source project
First, I make sure to move the Insertion Point to the beginning of the timeline. This is where I want my video to be placed. I then select "o" to load my DVD resolution video. This was the original output I rendered from this HDV resolution project. I make sure to select "Append in New Tracks" as my insertion strategy:

2) create labels at the break points between the songs
Now that I have the source video showing the breaks between songs and the outputting video in another track, I can then move the insertion point to each break between songs and set a label by pressing the "l" key:

3) delete the project's original tracks
In order to avoid confusion, I go ahead and delete the original project tracks by scrolling over the tracks in the timeline and pressing the "d" key or right-clicking on a particular track and select "Delete Track." Deleting the older HDV tracks makes sure that I don't accidentally end up re-rendering the HDV video and wasting hours of CPU cycles.
4) reduce the project size to 720x480
To restate, since my original project was in high definition but my newly appended track is at DVD resolution (720x480), I will need to reduce the size of the output video. So I select Shift-F for the formatting menu and change the project format to 720x480:

5) render using labels to indicate the start of a new output file
To render a project into separate files with different names, all I need to do is go into the rendering menu (Shift-R) and check the little box that says "Create new file at each label:"

What this useful little option does is given the output file name that you choose, Cinelerra will create a new file at each label with the format <filename>.<extension>##
where the hash marks indicate a sequence of numbers incremented from 01 to NN, the number of your last label. In other words, if you have 40 labels in your project and the file you're creating is called test.mov, Cinelerra will output the following files:
test.mov01
test.mov02
test.mov03
..
all the way to..
..
test.mov40
Pretty neat, huh?
Of course, you'd probably want to rename those files to something more explanatory. But you get the idea.
To make sure I output a small enough file to upload to YouTube, I augment the video compression bitrate to 500,000 and the audio compression to 256,000 as shown below:


And because I didn't want the first few minutes of introduction to be output, I selected "Selection" for the rendering scope and clicked OK:

The render process is off and running!
To give you an idea how long this particular video took to render, here are some specs:
Video Length: 1hr 4min
Number of Lables: 7
Resolution: DVD (720x480)
Time to Render: 2hr 10min
Computer: Dell 400SC, 3.2Ghz, 800Mhz FSB, 2GB PC3200RAM, Fedora Core 4 SMP kernel
Post Mortem
Here's a link to a few more I've uploaded since my original post yesterday:
http://www.youtube.com/results?search_query=snufflerstormpig
I hope you enjoyed this discussion of multiple file creation using labels. It is one of the many features of Cinelerra and can be very useful in your editing life.
Be good.
The Crazed Video Mule
The distributed videos are lower resolution, usually 320x180 MOV files (MPEG4 audio/MPEG4 video) and get pretty big, around 320MB. If you're interested and you have iTunes, you can see some of these monster downloads at itpc://www.stormpigs.com/vodcast.xml.That's really too much to download for any sane person, so my task today was to break up those large videos into small, individual chunks of only the best material from 2006 that I can then upload to YouTube. And hopefully by the end of this post, I'll have some individual songs worth listening to that I can direct you to. With the caveat that the songs were created live, then and there, no rehearsal.
To get back on track, the task is to break up a Cinelerra project into bite size chunks that can then be uploaded to YouTube. This should be fairly simple.
I start with the project that I used to create the one large video. This project has all the audio and video fades and effects that I originally used to create the hour long iTunes video. The good thing about it is that the project has the breaks between video clips delineated clearly. In between the breaks are the actual songs that I'd like to divide up and render out to individual files:

The insertion point will select these breaks very easily, allowing me to set my labels for the render:

This source project is in HDV format. As I've discussed in previous posts, I edit the high resolution source and then output one final as a DVD resolution file, and then convert that DVD to an iTunes-ready format. This does impose some generational loss in quality, but the source material is not that visually stimulating (a bunch of guys in a dark room), so we're not missing much in the two steps down from HDV to iTunes. So now, I have an HDV source project and an output file rendered to DVD. In my previous post (/2007/05/how-to-upload-video-to-youtube.html, I discuss that YouTube allows me to upload up to 100MB or 10 minutes of video. In that post, I also discovered that YouTube recommends this format file:
- MPEG container
- 320x240 resolution
- MP3 audio
- MPEG I/II video
But can also accept files of this format that I can output directly from Cinelerra:
- MOV container (Quicktime for Linux)
- 720x480 resolution
- MPEG4 audio compression (256,000 constant bitrate, stereo)
- MPEG4 video compression (500,000 constant bitrate)
If I break up my project (the recording session) into videos that are less than 100MB each, I will be able to upload the best parts to YouTube. Now, I'm a pretty lazy person in general, so if I don't have to perform an extra step to convert the files from DVD resolution to the preferred 320x240 resolution, I sure as hell won't bother. The test video that I outputted in the last post (specs above) ended up being about a minute and took up about 6.6MB of space at DVD resolution. Theoretically then, I should be OK as long as my songs are less than 10 minutes long (the YouTube limit). Most are, so we should be good to go.
With the constraints understood, I should now have rougly four steps to perform:
1) append my rendered video to a new track in the original source project
2) create labels at the break points between the songs
3) delete the project's original tracks
4) reduce the project size to 720x480
5) render using labels to indicate the start of a new output file
Let's go through these steps.
1) append my rendered video to a new track in the original source project
First, I make sure to move the Insertion Point to the beginning of the timeline. This is where I want my video to be placed. I then select "o" to load my DVD resolution video. This was the original output I rendered from this HDV resolution project. I make sure to select "Append in New Tracks" as my insertion strategy:

2) create labels at the break points between the songs
Now that I have the source video showing the breaks between songs and the outputting video in another track, I can then move the insertion point to each break between songs and set a label by pressing the "l" key:

3) delete the project's original tracks
In order to avoid confusion, I go ahead and delete the original project tracks by scrolling over the tracks in the timeline and pressing the "d" key or right-clicking on a particular track and select "Delete Track." Deleting the older HDV tracks makes sure that I don't accidentally end up re-rendering the HDV video and wasting hours of CPU cycles.
4) reduce the project size to 720x480
To restate, since my original project was in high definition but my newly appended track is at DVD resolution (720x480), I will need to reduce the size of the output video. So I select Shift-F for the formatting menu and change the project format to 720x480:

5) render using labels to indicate the start of a new output file
To render a project into separate files with different names, all I need to do is go into the rendering menu (Shift-R) and check the little box that says "Create new file at each label:"

What this useful little option does is given the output file name that you choose, Cinelerra will create a new file at each label with the format <filename>.<extension>##
where the hash marks indicate a sequence of numbers incremented from 01 to NN, the number of your last label. In other words, if you have 40 labels in your project and the file you're creating is called test.mov, Cinelerra will output the following files:
test.mov01
test.mov02
test.mov03
..
all the way to..
..
test.mov40
Pretty neat, huh?
Of course, you'd probably want to rename those files to something more explanatory. But you get the idea.
To make sure I output a small enough file to upload to YouTube, I augment the video compression bitrate to 500,000 and the audio compression to 256,000 as shown below:


And because I didn't want the first few minutes of introduction to be output, I selected "Selection" for the rendering scope and clicked OK:

The render process is off and running!
To give you an idea how long this particular video took to render, here are some specs:
Video Length: 1hr 4min
Number of Lables: 7
Resolution: DVD (720x480)
Time to Render: 2hr 10min
Computer: Dell 400SC, 3.2Ghz, 800Mhz FSB, 2GB PC3200RAM, Fedora Core 4 SMP kernel
Post Mortem
Here's a link to a few more I've uploaded since my original post yesterday:
http://www.youtube.com/results?search_query=snufflerstormpig
I hope you enjoyed this discussion of multiple file creation using labels. It is one of the many features of Cinelerra and can be very useful in your editing life.
Be good.
The Crazed Video Mule
If this post was useful to you..consider buying me a beer via PayPal!
Even a $1 Draft will keep the Mule happily working..and help pay for equipment upgrades!
Sunday, April 29, 2007
Beginner's Guide to Exporting Video from Cinelerra
In past versions of Cinelerra (pre-2.0), the process of creating content readable by media players across all platforms was cumbersome at best and maddeningly frustrating at worst. Cinelerra 2.0 seems to be much better in this regard, and can produce high-quality video in a variety of formats. However, the newcomer to Cinelerra may still find it difficult to output a simple DVD or web-ready video. This guide addresses this audience by explaining how to get usable content out of Cinelerra quickly and easily.
Disclaimer
This guide doesn't intend to support one particular format or compression method over another, but serves to give the reader a methodology to produce video content that displays properly in as many media players for as many viewers as possible.
Assumptions
The steps described below assume a properly installed version of Cinelerra 2.0. Also, the steps below were tested successfully with NTSC formatted video (thanks to Graham Evans for the clarification).
Test System
The procedures below were tested and certified by a non-independent, first party on the following machine:
Dell SC400, 3.2Ghz Pentium IV, 800Mhz FSB,
1GB PC3200 RAM, 80GB (x2) working drives
Fedora Core 4
FreshRPMs Cinelerra build 2.0-0.3.20051210.2.fc4.i386
http://rpmfind.net/linux/RPM/freshrpms/fedora/4/cinelerra/cinelerra-2.0-0.3.20051210.2.fc4.i386.html
Who is your Audience?
So! You've edited your masterpiece in Cinelerra and now it is time to export or "render" it to a final format. Congratulations! However, you first must consider your audience before you decide how you want to distribute the video. Who is going to watch your video and how are they going to watch it? Are you going to give them a DVD, submit a video feed to iTunes, send them a link to a website or just load the video into your iPod? Given that you have a destination for your video, this document will show you how to produce content ready for all of those options:
* HDV 720P
* a DVD
* a vodcast
* a webpage or web download
* Video iPod
Here is a chart comparing the different distribution methods and file formats:
Once you've rendered your video, don't forget to verify that your video is correctly formatted! And there are sections on advanced techniques for those people who would like to learn more and troubleshooting for folks who may be having problems.
What Operating System Does Your Audience Use?
As in all things Linux, there are a hundred different ways of accomplishing a single task. After much trial and error with file format and compression settings in Cinelerra, I've have had some success using the above formats across operating systems and players. Surprisingly, the QuickTime 7 player on XP is the most consistent media player. As well, MPEG2 is the most compatible format across players of different operating systems.
Here is a chart describing the compatibility of the above test files in major Linux and XP players:

Update 2008/12/24
I've put together a new compatibility chart of Cinelerra export container formats and codecs for Fedora 10, x86-64:
http://crazedmuleproductions.blogspot.com/2008/12/fedora-10-x86-64-compability-chart.html
The chart was created using a 720P resolution Cinelerra project. It is not yet complete.
In a perfect world, this chart should represent the compatibility for all distributions. In reality, your mileage may vary.
end update
Now that we've put some thought into who our audience is and what operating systems and players they use, let's export some video!
Exporting HDV Video
No example yet
For a HDV720P formatted file, we will save the audio and video streams separately. The audio will be saved as MPEG Layer II (384Kbps) and the video will be encoded using mpeg2enc. Once we are done saving the audio and video streams separately, we will then combine (or "mux") the streams together using mplex into a program stream. Finally, we will use VLC to convert the program stream into a MP@HL compliant MPEG transport stream (MPEG-TS).
The general specifications of the combined file are:
File Format: MPEG
Compression Type: MPEG-2
Audio: MPEG Layer II, 384Kbps
Here are the steps. First, render the audio:
* in Cinelerra, press Shift-R for the Render menu.
* under Select a file to render to, choose a destination directory and filename
* under File Format, choose "MPEG Audio"
* under Audio, check the "Render audio tracks" checkbox

* click the wrench icon next to Audio
* select "II" from the Layer dropdown
* select "384" from the Kbits per second dropdown

* accept the changes by clicking the checkbox in the lower left hand corner of the dialog box
* under Video, uncheck the "Render video tracks" checkbox
* accept the changes by clicking the checkbox in the lower left hand corner of the dialog box
* make sure that "Create new file at each label" is not checked
* make sure that "Insertion strategy" is set to "Create new resources only"
* To start rendering, click the checkbox in the lower left hand of the dialog.
Audio does not take very long to render. On my machine, a 3.2Ghz Pentium IV with 1GB of PC3200 memory, a 5 minute stream of MPEG Layer II audio takes about a minute to render.
Secondly, render the video:
* in Cinelerra, press Shift-R for the Render menu.
* under Select a file to render to, choose a destination directory and filename for the video (ending in .m2v). This file should go in the same directory as the audio file. This is not a necessity, but will make it easier when we mux (combine) the audio and video in the next and final step.
* under File Format, select "YUV4MPEG Stream"
* under Audio, uncheck the "Render audio tracks" checkbox
* under Video, check the "Render video tracks" checkbox

* click the wrench icon next to Video. Choose the following options:
* "Output Path" should have the filename and location you selected in the previous steps with a new extension, .m2v
* "Use Pipe" should be selected. If not, select "Use Pipe"
* enter or cut and paste the following render information into the Use Pipe textbox:
mpeg2enc --verbose 0 --aspect 3 --format 3 --frame-rate 4 --video-bitrate 18300 --nonvideo-bitrate 384 --interlace-mode 0 --force-b-b-p --video-buffer 448 --video-norm n --keep-hf --no-constraints --sequence-header-every-gop --min-gop-size 6 --max-gop-size 6 -o %
* under "Stream Header, Interlacing" will be left as "Unknown"

* accept the changes by clicking the checkbox in the lower left hand corner of the dialog box
* make sure that "Create new file at each label" is not checked
* make sure that the "Insertion strategy" is set to "Create new resources only"
* To start rendering, click the checkbox in the lower left hand of the dialog. MPEG2 video at HDV resolution takes a long time to render. If you have a dual, dual core machine, HDV video at 720P resolution takes about two minutes to render per minute of video.
After rendering the audio and video streams, mux (combine) them together into an MPEG program stream (PS) file using mplex. This step should not take that long, perhaps one minute for every 10 minutes of HDV video:
* Go to a terminal/shell prompt
* Navigate to the directory where you put both the separate audio and video files
Use this command:
mplex -f 3 -b 2000 video.m2v audio.m2a -o output.ps
The final step in creating an HDV 720P file is to convert it to a transport stream. Do this using VLC.
(screen shots to come)
Once the MPEG-TS file is output, you should have a proper HDV 720P that matches the MP@HL spec. This file can then be copied to a media player that accepts HDV content or output to an HDV camera that accepts 720P (MP@HL) formatted video.
Exporting Video for a DVD
See example: test.mpg (11.5MB)
For a DVD formatted file, we will save the audio and video streams separately. The audio will be saved as a Microsoft WAV file and the video will be encoded using YUV4MPEG compression. Luckily, as of Cinelerra version 1.2.2, Heroine Warrior replaced the much slower mpeg2enc encoding with fast YUV4MPEG. Hooray! Once we are done saving the audio and video, we will then combine (or "mux") the streams together for the final product using ffmpeg.
The general specifications of the combined file are:
File Format: MPEG
Compression Type: MPEG-2
Audio: Twos complement
Here are the steps. First, render the audio:
* in Cinelerra, press Shift-R for the Render menu.
* under Select a file to render to, choose a destination directory and filename (ending in .wav)
* under File Format, choose "Microsoft WAV"
* under Audio, check the "Render audio tracks" checkbox

* click the wrench icon next to Audio
* Accept the Compression default of "16 Bit Linear"
* Leave "Dither" unselected
* Accept the changes by clicking the checkbox in the lower left hand corner of the dialog box
* under Video, uncheck the "Render video tracks" checkbox
* accept the changes by clicking the checkbox in the lower left hand corner of the dialog box

* make sure that "Create new file at each label" is not checked
* make sure that "Insertion strategy" is set to "Create new resources only"
* To start rendering, click the checkbox in the lower left hand of the dialog.
Audio does not take very long to render. On my machine, a 3.2Ghz Pentium IV with 1GB of PC3200 memory, a 5 minute stream of audio takes about thirty seconds to render.
Secondly, render the video:
* in Cinelerra, press Shift-R for the Render menu.
* under Select a file to render to, choose a destination directory and filename for the video (ending in .m2v). This file should go in the same directory as the audio file. This is not a necessity, but will make it easier when we mux (combine) the audio and video in the next and final step.
* under File Format, select "YUV4MPEG Stream"
* under Audio, uncheck the "Render audio tracks" checkbox
* under Video, check the "Render video tracks" checkbox

* click the wrench icon next to Video. Choose the following options:
* "Output Path" should have the filename and location you selected in the previous steps
* skip "Use Pipe" for now
* go down to the "Pipe Presets" section and click ffmpeg. There will be two choices here. Select the DVD format. Depending on the version of Cinelerra that you've downloaded or compiled, you may see one of two versions of the ffmpeg DVD pipe:
1) The first should be used for progressive content
ffmpeg -f yuv4mpegpipe -i - -y -target ntsc-dvd %
2) The second should be used for interlaced content:
ffmpeg -f yuv4mpegpipe -i - -y -target ntsc-dvd -ilme -ildct -hq -f mpeg2video %
Note that if you have problems rendering, the -ilme -ildct -hq arguments or just the -hq argument alone should be removed. In addition, some versions of FFMPEG do not support the -hq option and you will get the below error if you try to render video using this pipe:
ffmpeg: unrecognized option '-hq'
Received sigpipe
write_frame() failed: system error (failed read/write)
Unfortunately, FFMPEG is a moving target, as the tool is in a state of continuous development. That is good, as new features and functionality are being implemented, but distressing when the new features or command line switches change and break scripts that previously worked.
* At this point, the "Use Pipe" checkbox above should be checked and the ffmpeg command pipe should populate the text input field. You should not need to edit this command, as the default pipes' output settings yield high quality video.
* under "Stream Header, Interlacing" will be left as "Unknown"
* accept the changes by clicking the checkbox in the lower left hand corner of the dialog box

* You will notice that underneath "Select a file to render to", the ffmpeg command is represented as a pipe command.
* make sure that "Create new file at each label" is not checked
* make sure that the "Insertion strategy" is set to "Create new resources only"
* To start rendering, click the checkbox in the lower left hand of the dialog. Heroine Warrior has done an excellent job of enhancing the performance of the MPEG streamer, but it still takes quite a while if you've got more than 10 minutes of video. Again, on my machine (described above), it should take about 10 minutes to render 10 minutes of video as an MPEG stream.
Finally, we will mux (combine) the audio and video streams together into a DVD-ready product. Here's what you do:
* Go to a terminal/shell prompt
* Navigate to the directory where you put both the separate audio and video files
Use this command:
ffmpeg -i filename.wav -i filename.m2v -target dvd destinationFilename.mpg
Here is a description of what the switches I chose for ffmpeg mean:
-i = input (either sound or video file)
-target dvd = specifies standard DVD dimensions for the video (720x480) and default bitrate quality levels of ~7Mbps (other targets: "vcd", "svcd", "dvd", "dv", "pal-vcd", "ntsc-svcd" (see -formats switch below))
When not using -target switch, other useful arguments apply:
-aspect = aspect ratio: choose 4:3, 16:9, 1.3333, 1.7777
-b = bitrate in kbps (default = 200 kbps)
-r = frame rate (default = 25)
-s = size (default 160x128)
-ab = audio bitrate (default = 64 kbps)
-ac = audio channels (default = 1)
-formats = file formats, codecs and protocols that ffmpeg supports
Of course, running "man ffmpeg" in a terminal will tell you more than you ever wanted to know about ffmpeg, but here's a nice tutorial on getting started with ffmpeg:
http://howto-pages.org/ffmpeg/
References:
FFMPEG documentation: http://ffmpeg.org/documentation.html
FFMPEG command line options: http://ffmpeg.mplayerhq.hu/ffmpeg-doc.html
In general, using ffmpeg may take quite a while based upon the resolution and length of your video. And if you haven't guessed it already, we are rendering the file for a second time. Video purists would frown upon such a transgression, but for the sake of simplicity, please excuse. By the way, ffmpeg is a very powerful program and there are many more switches you can use to slice and dice your video in any way possible before or after you get it into Cinelerra. Let it be known that the procedure just described will give you a file that will work well with any DVD authoring software.
Don't forget to verify that your video is correctly formatted!
Exporting Video for a Vodcast
See example: test.h264.mov (5.5MB)
To put your video up as a video podcast or vodcast, we will format the video using H.264 compression, as Heroine Warrior terms "one of the highest quality video codecs around, making HDTV distribution over the Internet almost practical." That may be, but users of lowered powered PCs may have difficulty viewing files of this format. Stuttered playback may occur on Intel P4 systems less than 1.8Ghz. I have not yet tested on Apples.
The general specifications of the file are:
File Format: Quicktime for Linux
Compression Type: H.264
Audio: MPEG-4 Audio
Once you've prepared your video in Cinelerra, follow these instructions to prepare it as a podcast:
* in Cinelerra, press Shift-R for the Render menu.
* under Select a file to render to, choose a destination directory and filename (ending in .mov)
* under File Format, select "Quicktime for Linux"
* under Audio, check the "Render audio tracks" checkbox
* click the wrench icon next to Audio

* change the default Compression default from "Twos complement" to MPEG-4 Audio.
* If you want your video to have very high quality sound, accept the default Bitrate of 256000. Otherwise, change this value to something lower to save space. 128000 is sufficient for stereo music. 64000 or lower for voice.
* leave the Quantization Quality at 100%.
* accept the changes by clicking the checkbox in the lower left hand corner of the dialog box.
* under Video, check the "Render video tracks" checkbox
* click the wrench icon next to Video. Choose the following options:
* use H.264 compression. This is Apple's preferred format for iTunes, so let's all bow down to Mr.Jobs. Kidding aside, this format does do an excellent job of saving space with limited reduction in quality.
* keep the default bitrate of 1000000. I've noticed that changing the default bitrate does not change the file size or quality of the output file.
* change the quantization from 5 to 20. This level of quantization will reduce the size of the file by a factor of 66%!
* leave "Fix quantization" checked
* accept the changes by clicking the checkbox in the lower left hand corner of the dialog box

* make sure that Create new file at each label is not checked
* make sure that the Insertion strategy is set to "Create new resources only"
* To start rendering, click the checkbox in the lower left hand of the dialog. If you're video is less than 15 minutes long, read your mail or do some research on that new iPod you're lusting after. If your video is longer than a half hour, go out and paint the town red, because it's gonna take a long time.
Don't forget to verify that your video is correctly formatted!
Exporting Video for a Web Page or a Web Download
See example: test.mpeg4.mov (7.8MB)
Lastly, to prep your video for a web audience, we will format the video using MPEG-4 compression. Using this format results in the smallest file of the three options chosen.
The general specifications of this file are:
File Format: Quicktime for Linux
Compression Type: MPEG-4 Video
Audio: Twos complement
Once your video is set to be put on a webpage, follow these instructions:
* in Cinelerra, press Shift-R for the Render menu.
* under Select a file to render to, choose a destination directory and filename (ending in .mov)
* under File Format, select "Quicktime for Linux"
* under Audio, check the "Render audio tracks" checkbox
* click the wrench icon next to Audio

* accept the Compression default of "Twos complement" and Bits per channel of "16 Bit Linear".
* leave "Dither" unselected
* accept the changes by clicking the checkbox in the lower left hand corner of the dialog box
* under Video, check the "Render video tracks" checkbox
* click the wrench icon next to Video. Choose the following options:
* use MPEG-4 Video compression. This saves quite a bit of space, with limited reduction in quality
* keep the default bitrate of 1000000, bitrate tolerance of 500000, quantization of 10 and interlaced keyframe interval of 45.
* leave "Fix bitrate" checked
* accept the changes by clicking the checkbox in the lower left hand corner of the dialog box

* make sure that "Create new file at each label" is not checked
* make sure that the "Insertion strategy" is set to "Create new resources only"
* To start rendering, click the checkbox in the lower left hand of the dialog. Go get a cup of coffee if you're video is less than 15 minutes long or take a nice long nap if the video is longer than 30 minutes.
Rendering takes mucho processing power, but Cinelerra can handle it! Now if I only had that Dual Opteron box..
:)
Don't forget to verify that your video is correctly formatted!
Exporting Video for a Video iPod
See example: test.mpeg4.ipod.mov (1.4MB)
Update 09/29/2008
Due to updates in FFMPEG and iTunes, the directions herein will only allow you to encode a video that can be replayed in iTunes. However, the file will NOT play in your iPod. I have found a workaround:
http://crazedmuleproductions.blogspot.com/2008/09/h264-encoding-for-video-ipod.html
end update
Update 10/16/2008
Making a Podcast, by Apple
The test file from the above Web Download portion of this document (test.mpeg4.mov) loads and plays in iTunes. However, when I went to upload it, iTunes gave me the message:
"Some of the songs in the iTunes music library, including the song "(Video name)", were not copied to your iPod because they cannot be played on this iPod."
Luckily, Apple provides a feature called "Convert Selection for iPod" when you right-click on the file. But geez! I already rendered this thing. I've have to re-render it? Ugh. OK then. But, oh no, the conversion utility takes too much time! Even on a very fast machine like mine, a 3.2Ghz P4 with 1GB of PC3200 memory, the conversion speed is roughly 1.5 minutes per minute of video. That is way TOO slow. But I went ahead and did the conversion with my short test video. On the bright side, once the video was converted, I could then update my iPod and the video was on my iPod. Yes!
I continued playing around and loading many different videos into iTunes. In my travels, I stumbled upon one that did not require a conversion. I was shocked! I then reasoned that I'd save much time if I just produced the videos in the format that iTunes expects in the first place. But how to do that? So, my next course of action was to research why that one file worked in iTunes without a conversion and why mine needed the conversion.
To do this, I analyzed the output of MPlayer to determine the differences between files. I learned quite a bit about audio and video formats by reviewing the output of MPlayer. It helps to have the text of both files displayed in two windows next to each other in order to more easily compare the files line by line. I've done this for you in the image below. On the left appears the file that is in the correct format; on the right, my file not in the correct iTunes format:

Reviewing the diffences, I noticed the following:
* iTunes compatible file had the audio track as the first track in the MOV container; my file had the video as the first track
* iTunes compatible file was 44.1Khz audio; my file was 48000Khz
* iTunes compatible file included an extra audio header; my file did not have the extra header
* iTunes compatible file audio compression method was MPEG-4; my file was twos complement
* iTunes compatible file FPS rate was 15; my file was 59.97
After way too many hours of trial and error, I found that it was the audio sampling rate and compression type that broke my file in iTunes. Here are the settings in Cinelerra that will make an MPEG-4 video totally compatible with iTunes so that iTunes does not need to re-render (the "Convert Selection for iPod" feature) the video! These settings are a slight variation on the Web Download procedures (MPEG-4 format).
Here are the specs I used:
H.264 video:
* up to 768 Kbps, 320 x 240, 30 frames per sec., Baseline Profile up to Level 1.3 with AAC-LC up to 160 Kbps, 48 Khz, stereo audio in .m4v, .mp4 and .mov file formats
MPEG-4 video:
* up to 2.5 mbps, 480 x 480, 30 frames per sec., Simple Profile with AAC-LC up to 160 Kbps, 48 Khz, stereo audio in .m4v, .mp4 and .mov file formats
If you expect to upload into iTunes without needing a re-render, DO NOT deviate from ANY of these settings.
iTunes Specific Information
When you drag and drop a video into the iTunes Library, the software will first evaluate the video to see if it can read the video file. If you drag and drop your newly created video onto iTunes, right-click and select "Convert Selection for iPod". If you have followed my directions, you should receive the following message:
"One or more videos were not converted because they are already in the correct format."
Once you see this message, you know you've been successful in creating a video file in compliance with the iTunes format specifications. Wonderful!!
Don't forget to verify that your video is correctly formatted!
References:
http://www.apple.com/ipod/specs.html
http://www.ipodwizard.net/showthread.php?t=4413
http://members.shaw.ca/Kyle-Rogers/
Verifying Your Settings Are Correct
Once your render is complete for any of the formats above, use your favorite media player to view your masterpiece. After doing this though, you probably want to double-check that the bitrates and compression settings you've chosen for your rendered file are indeed correct. Below, I've listed the following switches of popular players that will display the audio and video settings of your video:
mplayer -identify
ffplay -stats
xine: ALT-i for detailed info, CTRL-i for a brief summary of video stats
qtinfo: displays the settings of any QuickTime video
Advanced Techniques
Reducing the resolution of your source video
I own a high definition video cam, the JVC HD10U. This camera outputs some beautiful HDV footage in MPEG2-TS (transport stream) format; however, the native 720P format is overkill for most applications, especially the three listed at the top of this document. Often then, I will need to decrease the resolution of my videos from 720P to a more manageable dimension. Normally, you'd need to reduce your videos' resolution outside of Cinelerra. This advanced technique will show you that you can save time by doing the resize within Cinelerra!
For example, I will reduce my source video to 480P in order to produce a good looking DVD. Therefore, this advanced technique begins from where we left off earlier in the document, Exporting Video for a DVD, so please refresh your memory before we start.
To reduce the resolution of your source video, you can remove the "-target dvd" switch from the YUV4MPEG Stream settings and replace it with the following switches to FFMPEG:
-aspect = aspect ratio: choose 4:3, 16:9, 1.3333, 1.7777
-b = bitrate in kbps (default = 200 kbps)
-r = frame rate (default = 25)
-s = size (default 160x128)
For example, when I reduced the resolution of the original video used earlier in this tutorial from 720x480 to 320x180, I used these FFMPEG switches when exporting the YUV4MPEG Stream:
-aspect 16:9 -b 7000 -r 29.97 -s 320x180
Here's what the YUV4MPEG Stream dialog looked like while I made these changes:

Here's what the Render dialog looked like after I made my changes:

Notice the absence of the "-target dvd" switch after the "-y". Now you've resized your video all within Cinelerra. Awesome!
Combining a pre-existing audio file with a new video stream
In the previous example, I wanted to reduce the resolution of my video. In like fashion, I want to reduce the resolution, but I also want to keep the same audio stream. To do this, you'd normally have to combine the audio and video streams outside of Cinelerra. But again, we can save time by doing the mux within Cinelerra using this advanced technique!
In my case, I have a pre-existing audio file that I will combine with a newly rendered video stream. Because the duration of the audio matched the larger resolution version, the audio file will be the same length as my video track. In practice, this does not necessarily have to be so, but if your goal is to reduce the resolution of a specific video, most likely you will have an audio file that is the same length as the video. So, just like the previous advanced technique, I edited the commands after the pipe symbol to include the full path of the audio file. I added the following directly before the last character, a "%", in the FFMPEG pipe command:
-ab 320 -ac 2 -i "audio file path/audio file name"
Here's what the YUV4MPEG Stream dialog looked like while I made these changes:

It bears repeating that the full path MUST be specified in the -i switch. If you see errors such as these:
test2.wav: I/O error occured
Usually that means that input file is truncated and/or corrupted.
Received sigpipe
write_frame() failed: system error (failed read/write)
This usually means that your path to the file is incorrect and you'll need to fix it.
Finally, you'll notice two other switches in the pipe command I gave you. Recall these switches to FFMPEG:
-aspect = aspect ratio: choose 4:3, 16:9, 1.3333, 1.7777
-b = bitrate in kbps (default = 200 kbps)
-r = frame rate (default = 25)
-s = size (default 160x128)
-ab = audio bitrate (default = 64 kbps)
-ac = audio channels (default = 1)
As the audio was a high quality stereo mix, I opted for an audio bitrate of 320kbps and a two channel mix. The very nice thing about this advanced technique is that you don't have to mux the video outside of Cinelerra. You can do it within the program itself!
A word about bitrates
A detailed discussion on selecting an appropriate bitrate for your video is out of the scope of this article. So, in the spirit of my guide, I just let Cinelerra's bitrate defaults stand for the beginner who would rather not worry about the details just yet and render something that works the first time out of the box. That being said, I do use a quick-and-dirty method of determining bitrates for my videos.
To determine the bitrate for a video with high quality output, I use the following calculation:
bitrate in kbps = FPS * WIDTH * HEIGHT * QUALITY FACTOR
So, if I have a 320x240 video at 30FPS ready for iTunes, I would substitute in the following values:
= 30 * 320 * 240 * .255
= 587kbps
The final "Quality Factor" varies, but a value of .255 would yield good quality output. The higher the factor, the higher the bitrate and thus, better quality. Experiment with this quality factor to see if it works for you.
Here are some reference links to help you get an idea of what is involved in order to calculate the right bitrate for your video:
Understanding Bit Rates
DVD bitrate calculator
http://www.videohelp.com/calc
http://www.signvideo.com/bt-rts.htm
http://dvd-hq.info/Calculator.html
http://neuron2.net/LVG/ratesandsizes.html
http://www.cs.unc.edu/~hensley/zaurus/encode.html
Troubleshooting
Improper Audio Synchronization
I've had trouble with audio synchronization in a case where I rendered a file from a video track that did not start at zero on the timeline, but started a couple hundred frames after the audio. When I combined the rendered video and audio outside of Cinelerra in FFMPEG, the audio synchronization was off. To make your life easier, keep the start and end of your video and audio tracks perfectly aligned. Make sure to zoom in to less than five frames to verify this.
Truncated Video Track
Also, another difficulty I've had is when I open a just-rendered YUV4MPEG stream (.M2V video file) back into a project, the video is truncated and is shorter than the companion audio track. You can read about my troubles here: https://init.linpro.no/pipermail/skolelinux.no/cinelerra/2006-March/005760.html.
I resolved this using two methods:
Don't re-import a YUV4MPEG video after rendering it. In other words, do all of your editing within Cinelerra and then render ONE TIME ONLY when you are done with all of your edits. This may not be feasible on large projects, though.
Use QuickTime for Linux container format to render to and re-import back into Cinelerra. This container does not have the same strange behavior as YUV4MPEG. In other words, when bringing a recently rendered video back into Cinelerra, the audio and video tracks are of the same length and perfectly in sync.
--------------------------------------------------------------------------------
I hope you enjoyed this evolving document. The developers of Cinelerra were kind enough to provide us with a very powerful product that would normally cost thousands of dollars. So I'd like to thank the folks at Heroine Warrior for doing such a fine job programming and all the people at http://cvs.cinelerra.org/ who commit countless hours of their free time and energy on the software. As such, I felt it necessary to give back something to this community who has given us such a gift.
Please let me know of any new topics or improvements you'd like to see in this doc or maybe a new doc! Thanks!
Disclaimer
This guide doesn't intend to support one particular format or compression method over another, but serves to give the reader a methodology to produce video content that displays properly in as many media players for as many viewers as possible.
Assumptions
The steps described below assume a properly installed version of Cinelerra 2.0. Also, the steps below were tested successfully with NTSC formatted video (thanks to Graham Evans for the clarification).
Test System
The procedures below were tested and certified by a non-independent, first party on the following machine:
Dell SC400, 3.2Ghz Pentium IV, 800Mhz FSB,
1GB PC3200 RAM, 80GB (x2) working drives
Fedora Core 4
FreshRPMs Cinelerra build 2.0-0.3.20051210.2.fc4.i386
http://rpmfind.net/linux/RPM/freshrpms/fedora/4/cinelerra/cinelerra-2.0-0.3.20051210.2.fc4.i386.html
Who is your Audience?
So! You've edited your masterpiece in Cinelerra and now it is time to export or "render" it to a final format. Congratulations! However, you first must consider your audience before you decide how you want to distribute the video. Who is going to watch your video and how are they going to watch it? Are you going to give them a DVD, submit a video feed to iTunes, send them a link to a website or just load the video into your iPod? Given that you have a destination for your video, this document will show you how to produce content ready for all of those options:
* HDV 720P
* a DVD
* a vodcast
* a webpage or web download
* Video iPod
Here is a chart comparing the different distribution methods and file formats:
Distribution File Format Video Compression Audio Format HDV720P MPEG2 YUV4MPEG MPEG, Layer II (384Kbps) DVD MPEG2 YUV4MPEG Twos Comp'mnt Vodcast Quicktime for Linux H.264 MPEG-4 Audio Web Download Quicktime for Linux MPEG-4 Video Twos Comp'mnt Video iPod Quicktime for Linux MPEG-4 Video MPEG-4 Audio Distribution Test Video Size Render Time HDV720P no example yet DVD test.mpg 11.5MB 15 sec Vodcast test.h264.mov 5.5MB 50 sec Web Download test.mpeg4.mov 7.8MB 30 sec Video iPod test.mpeg4.ipod.mov 1.4MB 30 secNote: the dimensions of the test videos were reduced from DVD resolution (720x480) to a lower resolution (320x180) in order to make it easier for readers to download. Also, the only way to reduce the resolution of your video is to render it to a different resolution (described in advanced techniques below). You can resize or crop your video, but in doing so, you would lose some part of the viewable picture.
Once you've rendered your video, don't forget to verify that your video is correctly formatted! And there are sections on advanced techniques for those people who would like to learn more and troubleshooting for folks who may be having problems.
What Operating System Does Your Audience Use?
As in all things Linux, there are a hundred different ways of accomplishing a single task. After much trial and error with file format and compression settings in Cinelerra, I've have had some success using the above formats across operating systems and players. Surprisingly, the QuickTime 7 player on XP is the most consistent media player. As well, MPEG2 is the most compatible format across players of different operating systems.
Here is a chart describing the compatibility of the above test files in major Linux and XP players:

Update 2008/12/24
I've put together a new compatibility chart of Cinelerra export container formats and codecs for Fedora 10, x86-64:
http://crazedmuleproductions.blogspot.com/2008/12/fedora-10-x86-64-compability-chart.html
The chart was created using a 720P resolution Cinelerra project. It is not yet complete.
In a perfect world, this chart should represent the compatibility for all distributions. In reality, your mileage may vary.
end update
Now that we've put some thought into who our audience is and what operating systems and players they use, let's export some video!
Exporting HDV Video
No example yet
For a HDV720P formatted file, we will save the audio and video streams separately. The audio will be saved as MPEG Layer II (384Kbps) and the video will be encoded using mpeg2enc. Once we are done saving the audio and video streams separately, we will then combine (or "mux") the streams together using mplex into a program stream. Finally, we will use VLC to convert the program stream into a MP@HL compliant MPEG transport stream (MPEG-TS).
The general specifications of the combined file are:
File Format: MPEG
Compression Type: MPEG-2
Audio: MPEG Layer II, 384Kbps
Here are the steps. First, render the audio:
* in Cinelerra, press Shift-R for the Render menu.
* under Select a file to render to, choose a destination directory and filename
* under File Format, choose "MPEG Audio"
* under Audio, check the "Render audio tracks" checkbox

* click the wrench icon next to Audio
* select "II" from the Layer dropdown
* select "384" from the Kbits per second dropdown

* accept the changes by clicking the checkbox in the lower left hand corner of the dialog box
* under Video, uncheck the "Render video tracks" checkbox
* accept the changes by clicking the checkbox in the lower left hand corner of the dialog box
* make sure that "Create new file at each label" is not checked
* make sure that "Insertion strategy" is set to "Create new resources only"
* To start rendering, click the checkbox in the lower left hand of the dialog.
Audio does not take very long to render. On my machine, a 3.2Ghz Pentium IV with 1GB of PC3200 memory, a 5 minute stream of MPEG Layer II audio takes about a minute to render.
Secondly, render the video:
* in Cinelerra, press Shift-R for the Render menu.
* under Select a file to render to, choose a destination directory and filename for the video (ending in .m2v). This file should go in the same directory as the audio file. This is not a necessity, but will make it easier when we mux (combine) the audio and video in the next and final step.
* under File Format, select "YUV4MPEG Stream"
* under Audio, uncheck the "Render audio tracks" checkbox
* under Video, check the "Render video tracks" checkbox

* click the wrench icon next to Video. Choose the following options:
* "Output Path" should have the filename and location you selected in the previous steps with a new extension, .m2v
* "Use Pipe" should be selected. If not, select "Use Pipe"
* enter or cut and paste the following render information into the Use Pipe textbox:
mpeg2enc --verbose 0 --aspect 3 --format 3 --frame-rate 4 --video-bitrate 18300 --nonvideo-bitrate 384 --interlace-mode 0 --force-b-b-p --video-buffer 448 --video-norm n --keep-hf --no-constraints --sequence-header-every-gop --min-gop-size 6 --max-gop-size 6 -o %
* under "Stream Header, Interlacing" will be left as "Unknown"

* accept the changes by clicking the checkbox in the lower left hand corner of the dialog box
* make sure that "Create new file at each label" is not checked
* make sure that the "Insertion strategy" is set to "Create new resources only"
* To start rendering, click the checkbox in the lower left hand of the dialog. MPEG2 video at HDV resolution takes a long time to render. If you have a dual, dual core machine, HDV video at 720P resolution takes about two minutes to render per minute of video.
After rendering the audio and video streams, mux (combine) them together into an MPEG program stream (PS) file using mplex. This step should not take that long, perhaps one minute for every 10 minutes of HDV video:
* Go to a terminal/shell prompt
* Navigate to the directory where you put both the separate audio and video files
Use this command:
mplex -f 3 -b 2000 video.m2v audio.m2a -o output.ps
The final step in creating an HDV 720P file is to convert it to a transport stream. Do this using VLC.
(screen shots to come)
Once the MPEG-TS file is output, you should have a proper HDV 720P that matches the MP@HL spec. This file can then be copied to a media player that accepts HDV content or output to an HDV camera that accepts 720P (MP@HL) formatted video.
Exporting Video for a DVD
See example: test.mpg (11.5MB)
For a DVD formatted file, we will save the audio and video streams separately. The audio will be saved as a Microsoft WAV file and the video will be encoded using YUV4MPEG compression. Luckily, as of Cinelerra version 1.2.2, Heroine Warrior replaced the much slower mpeg2enc encoding with fast YUV4MPEG. Hooray! Once we are done saving the audio and video, we will then combine (or "mux") the streams together for the final product using ffmpeg.
The general specifications of the combined file are:
File Format: MPEG
Compression Type: MPEG-2
Audio: Twos complement
Here are the steps. First, render the audio:
* in Cinelerra, press Shift-R for the Render menu.
* under Select a file to render to, choose a destination directory and filename (ending in .wav)
* under File Format, choose "Microsoft WAV"
* under Audio, check the "Render audio tracks" checkbox

* click the wrench icon next to Audio
* Accept the Compression default of "16 Bit Linear"
* Leave "Dither" unselected
* Accept the changes by clicking the checkbox in the lower left hand corner of the dialog box
* under Video, uncheck the "Render video tracks" checkbox
* accept the changes by clicking the checkbox in the lower left hand corner of the dialog box

* make sure that "Create new file at each label" is not checked
* make sure that "Insertion strategy" is set to "Create new resources only"
* To start rendering, click the checkbox in the lower left hand of the dialog.
Audio does not take very long to render. On my machine, a 3.2Ghz Pentium IV with 1GB of PC3200 memory, a 5 minute stream of audio takes about thirty seconds to render.
Secondly, render the video:
* in Cinelerra, press Shift-R for the Render menu.
* under Select a file to render to, choose a destination directory and filename for the video (ending in .m2v). This file should go in the same directory as the audio file. This is not a necessity, but will make it easier when we mux (combine) the audio and video in the next and final step.
* under File Format, select "YUV4MPEG Stream"
* under Audio, uncheck the "Render audio tracks" checkbox
* under Video, check the "Render video tracks" checkbox

* click the wrench icon next to Video. Choose the following options:
* "Output Path" should have the filename and location you selected in the previous steps
* skip "Use Pipe" for now
* go down to the "Pipe Presets" section and click ffmpeg. There will be two choices here. Select the DVD format. Depending on the version of Cinelerra that you've downloaded or compiled, you may see one of two versions of the ffmpeg DVD pipe:
1) The first should be used for progressive content
ffmpeg -f yuv4mpegpipe -i - -y -target ntsc-dvd %
2) The second should be used for interlaced content:
ffmpeg -f yuv4mpegpipe -i - -y -target ntsc-dvd -ilme -ildct -hq -f mpeg2video %
Note that if you have problems rendering, the -ilme -ildct -hq arguments or just the -hq argument alone should be removed. In addition, some versions of FFMPEG do not support the -hq option and you will get the below error if you try to render video using this pipe:
ffmpeg: unrecognized option '-hq'
Received sigpipe
write_frame() failed: system error (failed read/write)
Unfortunately, FFMPEG is a moving target, as the tool is in a state of continuous development. That is good, as new features and functionality are being implemented, but distressing when the new features or command line switches change and break scripts that previously worked.
* At this point, the "Use Pipe" checkbox above should be checked and the ffmpeg command pipe should populate the text input field. You should not need to edit this command, as the default pipes' output settings yield high quality video.
* under "Stream Header, Interlacing" will be left as "Unknown"
* accept the changes by clicking the checkbox in the lower left hand corner of the dialog box

* You will notice that underneath "Select a file to render to", the ffmpeg command is represented as a pipe command.
* make sure that "Create new file at each label" is not checked
* make sure that the "Insertion strategy" is set to "Create new resources only"
* To start rendering, click the checkbox in the lower left hand of the dialog. Heroine Warrior has done an excellent job of enhancing the performance of the MPEG streamer, but it still takes quite a while if you've got more than 10 minutes of video. Again, on my machine (described above), it should take about 10 minutes to render 10 minutes of video as an MPEG stream.
Finally, we will mux (combine) the audio and video streams together into a DVD-ready product. Here's what you do:
* Go to a terminal/shell prompt
* Navigate to the directory where you put both the separate audio and video files
Use this command:
ffmpeg -i filename.wav -i filename.m2v -target dvd destinationFilename.mpg
Here is a description of what the switches I chose for ffmpeg mean:
-i = input (either sound or video file)
-target dvd = specifies standard DVD dimensions for the video (720x480) and default bitrate quality levels of ~7Mbps (other targets: "vcd", "svcd", "dvd", "dv", "pal-vcd", "ntsc-svcd" (see -formats switch below))
When not using -target switch, other useful arguments apply:
-aspect = aspect ratio: choose 4:3, 16:9, 1.3333, 1.7777
-b = bitrate in kbps (default = 200 kbps)
-r = frame rate (default = 25)
-s = size (default 160x128)
-ab = audio bitrate (default = 64 kbps)
-ac = audio channels (default = 1)
-formats = file formats, codecs and protocols that ffmpeg supports
Of course, running "man ffmpeg" in a terminal will tell you more than you ever wanted to know about ffmpeg, but here's a nice tutorial on getting started with ffmpeg:
http://howto-pages.org/ffmpeg/
References:
FFMPEG documentation: http://ffmpeg.org/documentation.html
FFMPEG command line options: http://ffmpeg.mplayerhq.hu/ffmpeg-doc.html
In general, using ffmpeg may take quite a while based upon the resolution and length of your video. And if you haven't guessed it already, we are rendering the file for a second time. Video purists would frown upon such a transgression, but for the sake of simplicity, please excuse. By the way, ffmpeg is a very powerful program and there are many more switches you can use to slice and dice your video in any way possible before or after you get it into Cinelerra. Let it be known that the procedure just described will give you a file that will work well with any DVD authoring software.
Don't forget to verify that your video is correctly formatted!
Exporting Video for a Vodcast
See example: test.h264.mov (5.5MB)
To put your video up as a video podcast or vodcast, we will format the video using H.264 compression, as Heroine Warrior terms "one of the highest quality video codecs around, making HDTV distribution over the Internet almost practical." That may be, but users of lowered powered PCs may have difficulty viewing files of this format. Stuttered playback may occur on Intel P4 systems less than 1.8Ghz. I have not yet tested on Apples.
The general specifications of the file are:
File Format: Quicktime for Linux
Compression Type: H.264
Audio: MPEG-4 Audio
Once you've prepared your video in Cinelerra, follow these instructions to prepare it as a podcast:
* in Cinelerra, press Shift-R for the Render menu.
* under Select a file to render to, choose a destination directory and filename (ending in .mov)
* under File Format, select "Quicktime for Linux"
* under Audio, check the "Render audio tracks" checkbox
* click the wrench icon next to Audio

* change the default Compression default from "Twos complement" to MPEG-4 Audio.
* If you want your video to have very high quality sound, accept the default Bitrate of 256000. Otherwise, change this value to something lower to save space. 128000 is sufficient for stereo music. 64000 or lower for voice.
* leave the Quantization Quality at 100%.
* accept the changes by clicking the checkbox in the lower left hand corner of the dialog box.
* under Video, check the "Render video tracks" checkbox
* click the wrench icon next to Video. Choose the following options:
* use H.264 compression. This is Apple's preferred format for iTunes, so let's all bow down to Mr.Jobs. Kidding aside, this format does do an excellent job of saving space with limited reduction in quality.
* keep the default bitrate of 1000000. I've noticed that changing the default bitrate does not change the file size or quality of the output file.
* change the quantization from 5 to 20. This level of quantization will reduce the size of the file by a factor of 66%!
* leave "Fix quantization" checked
* accept the changes by clicking the checkbox in the lower left hand corner of the dialog box

* make sure that Create new file at each label is not checked
* make sure that the Insertion strategy is set to "Create new resources only"
* To start rendering, click the checkbox in the lower left hand of the dialog. If you're video is less than 15 minutes long, read your mail or do some research on that new iPod you're lusting after. If your video is longer than a half hour, go out and paint the town red, because it's gonna take a long time.
Don't forget to verify that your video is correctly formatted!
Exporting Video for a Web Page or a Web Download
See example: test.mpeg4.mov (7.8MB)
Lastly, to prep your video for a web audience, we will format the video using MPEG-4 compression. Using this format results in the smallest file of the three options chosen.
The general specifications of this file are:
File Format: Quicktime for Linux
Compression Type: MPEG-4 Video
Audio: Twos complement
Once your video is set to be put on a webpage, follow these instructions:
* in Cinelerra, press Shift-R for the Render menu.
* under Select a file to render to, choose a destination directory and filename (ending in .mov)
* under File Format, select "Quicktime for Linux"
* under Audio, check the "Render audio tracks" checkbox
* click the wrench icon next to Audio

* accept the Compression default of "Twos complement" and Bits per channel of "16 Bit Linear".
* leave "Dither" unselected
* accept the changes by clicking the checkbox in the lower left hand corner of the dialog box
* under Video, check the "Render video tracks" checkbox
* click the wrench icon next to Video. Choose the following options:
* use MPEG-4 Video compression. This saves quite a bit of space, with limited reduction in quality
* keep the default bitrate of 1000000, bitrate tolerance of 500000, quantization of 10 and interlaced keyframe interval of 45.
* leave "Fix bitrate" checked
* accept the changes by clicking the checkbox in the lower left hand corner of the dialog box

* make sure that "Create new file at each label" is not checked
* make sure that the "Insertion strategy" is set to "Create new resources only"
* To start rendering, click the checkbox in the lower left hand of the dialog. Go get a cup of coffee if you're video is less than 15 minutes long or take a nice long nap if the video is longer than 30 minutes.
Rendering takes mucho processing power, but Cinelerra can handle it! Now if I only had that Dual Opteron box..
:)
Don't forget to verify that your video is correctly formatted!
Exporting Video for a Video iPod
See example: test.mpeg4.ipod.mov (1.4MB)
Update 09/29/2008
Due to updates in FFMPEG and iTunes, the directions herein will only allow you to encode a video that can be replayed in iTunes. However, the file will NOT play in your iPod. I have found a workaround:
http://crazedmuleproductions.blogspot.com/2008/09/h264-encoding-for-video-ipod.html
end update
Update 10/16/2008
Making a Podcast, by Apple
The test file from the above Web Download portion of this document (test.mpeg4.mov) loads and plays in iTunes. However, when I went to upload it, iTunes gave me the message:
"Some of the songs in the iTunes music library, including the song "(Video name)", were not copied to your iPod because they cannot be played on this iPod."
Luckily, Apple provides a feature called "Convert Selection for iPod" when you right-click on the file. But geez! I already rendered this thing. I've have to re-render it? Ugh. OK then. But, oh no, the conversion utility takes too much time! Even on a very fast machine like mine, a 3.2Ghz P4 with 1GB of PC3200 memory, the conversion speed is roughly 1.5 minutes per minute of video. That is way TOO slow. But I went ahead and did the conversion with my short test video. On the bright side, once the video was converted, I could then update my iPod and the video was on my iPod. Yes!
I continued playing around and loading many different videos into iTunes. In my travels, I stumbled upon one that did not require a conversion. I was shocked! I then reasoned that I'd save much time if I just produced the videos in the format that iTunes expects in the first place. But how to do that? So, my next course of action was to research why that one file worked in iTunes without a conversion and why mine needed the conversion.
To do this, I analyzed the output of MPlayer to determine the differences between files. I learned quite a bit about audio and video formats by reviewing the output of MPlayer. It helps to have the text of both files displayed in two windows next to each other in order to more easily compare the files line by line. I've done this for you in the image below. On the left appears the file that is in the correct format; on the right, my file not in the correct iTunes format:

Reviewing the diffences, I noticed the following:
* iTunes compatible file had the audio track as the first track in the MOV container; my file had the video as the first track
* iTunes compatible file was 44.1Khz audio; my file was 48000Khz
* iTunes compatible file included an extra audio header; my file did not have the extra header
* iTunes compatible file audio compression method was MPEG-4; my file was twos complement
* iTunes compatible file FPS rate was 15; my file was 59.97
After way too many hours of trial and error, I found that it was the audio sampling rate and compression type that broke my file in iTunes. Here are the settings in Cinelerra that will make an MPEG-4 video totally compatible with iTunes so that iTunes does not need to re-render (the "Convert Selection for iPod" feature) the video! These settings are a slight variation on the Web Download procedures (MPEG-4 format).
Here are the specs I used:
For the project: Set Format Sample Rate to 44100khz Number of Channels to two FPS can be the FPS of your source video Width 320 Height 240My video happened to be 320x180 because my source video was 16x9 hidef, which worked fine as well. For the render: Audio MPEG-4 Audio Bitrate 128000 Quantization of 100 Video MPEG-4 Video The rest of the parameters are Cinelerra's defaults, but I will reiterate here: Bitrate 7000000 Tolerance 500000 Fixed Quantization selected Quantization 10 Keyframe Interval 45You need to abide by this format because iTunes is VERY STRICT when it comes to these settings! Also, the value for bitrate should be calculated based on the height, width, frames per second and quality requirements of your video product. More on this later. Here are Apple's specifications for iPod compliant videos (from http://www.apple.com/ipod/specs.html):
H.264 video:
* up to 768 Kbps, 320 x 240, 30 frames per sec., Baseline Profile up to Level 1.3 with AAC-LC up to 160 Kbps, 48 Khz, stereo audio in .m4v, .mp4 and .mov file formats
MPEG-4 video:
* up to 2.5 mbps, 480 x 480, 30 frames per sec., Simple Profile with AAC-LC up to 160 Kbps, 48 Khz, stereo audio in .m4v, .mp4 and .mov file formats
If you expect to upload into iTunes without needing a re-render, DO NOT deviate from ANY of these settings.
iTunes Specific Information
When you drag and drop a video into the iTunes Library, the software will first evaluate the video to see if it can read the video file. If you drag and drop your newly created video onto iTunes, right-click and select "Convert Selection for iPod". If you have followed my directions, you should receive the following message:
"One or more videos were not converted because they are already in the correct format."
Once you see this message, you know you've been successful in creating a video file in compliance with the iTunes format specifications. Wonderful!!
Don't forget to verify that your video is correctly formatted!
References:
http://www.apple.com/ipod/specs.html
http://www.ipodwizard.net/showthread.php?t=4413
http://members.shaw.ca/Kyle-Rogers/
Verifying Your Settings Are Correct
Once your render is complete for any of the formats above, use your favorite media player to view your masterpiece. After doing this though, you probably want to double-check that the bitrates and compression settings you've chosen for your rendered file are indeed correct. Below, I've listed the following switches of popular players that will display the audio and video settings of your video:
mplayer -identify
ffplay -stats
xine: ALT-i for detailed info, CTRL-i for a brief summary of video stats
qtinfo: displays the settings of any QuickTime video
Advanced Techniques
Reducing the resolution of your source video
I own a high definition video cam, the JVC HD10U. This camera outputs some beautiful HDV footage in MPEG2-TS (transport stream) format; however, the native 720P format is overkill for most applications, especially the three listed at the top of this document. Often then, I will need to decrease the resolution of my videos from 720P to a more manageable dimension. Normally, you'd need to reduce your videos' resolution outside of Cinelerra. This advanced technique will show you that you can save time by doing the resize within Cinelerra!
For example, I will reduce my source video to 480P in order to produce a good looking DVD. Therefore, this advanced technique begins from where we left off earlier in the document, Exporting Video for a DVD, so please refresh your memory before we start.
To reduce the resolution of your source video, you can remove the "-target dvd" switch from the YUV4MPEG Stream settings and replace it with the following switches to FFMPEG:
-aspect = aspect ratio: choose 4:3, 16:9, 1.3333, 1.7777
-b = bitrate in kbps (default = 200 kbps)
-r = frame rate (default = 25)
-s = size (default 160x128)
For example, when I reduced the resolution of the original video used earlier in this tutorial from 720x480 to 320x180, I used these FFMPEG switches when exporting the YUV4MPEG Stream:
-aspect 16:9 -b 7000 -r 29.97 -s 320x180
Here's what the YUV4MPEG Stream dialog looked like while I made these changes:

Here's what the Render dialog looked like after I made my changes:

Notice the absence of the "-target dvd" switch after the "-y". Now you've resized your video all within Cinelerra. Awesome!
Combining a pre-existing audio file with a new video stream
In the previous example, I wanted to reduce the resolution of my video. In like fashion, I want to reduce the resolution, but I also want to keep the same audio stream. To do this, you'd normally have to combine the audio and video streams outside of Cinelerra. But again, we can save time by doing the mux within Cinelerra using this advanced technique!
In my case, I have a pre-existing audio file that I will combine with a newly rendered video stream. Because the duration of the audio matched the larger resolution version, the audio file will be the same length as my video track. In practice, this does not necessarily have to be so, but if your goal is to reduce the resolution of a specific video, most likely you will have an audio file that is the same length as the video. So, just like the previous advanced technique, I edited the commands after the pipe symbol to include the full path of the audio file. I added the following directly before the last character, a "%", in the FFMPEG pipe command:
-ab 320 -ac 2 -i "audio file path/audio file name"
Here's what the YUV4MPEG Stream dialog looked like while I made these changes:

It bears repeating that the full path MUST be specified in the -i switch. If you see errors such as these:
test2.wav: I/O error occured
Usually that means that input file is truncated and/or corrupted.
Received sigpipe
write_frame() failed: system error (failed read/write)
This usually means that your path to the file is incorrect and you'll need to fix it.
Finally, you'll notice two other switches in the pipe command I gave you. Recall these switches to FFMPEG:
-aspect = aspect ratio: choose 4:3, 16:9, 1.3333, 1.7777
-b = bitrate in kbps (default = 200 kbps)
-r = frame rate (default = 25)
-s = size (default 160x128)
-ab = audio bitrate (default = 64 kbps)
-ac = audio channels (default = 1)
As the audio was a high quality stereo mix, I opted for an audio bitrate of 320kbps and a two channel mix. The very nice thing about this advanced technique is that you don't have to mux the video outside of Cinelerra. You can do it within the program itself!
A word about bitrates
A detailed discussion on selecting an appropriate bitrate for your video is out of the scope of this article. So, in the spirit of my guide, I just let Cinelerra's bitrate defaults stand for the beginner who would rather not worry about the details just yet and render something that works the first time out of the box. That being said, I do use a quick-and-dirty method of determining bitrates for my videos.
To determine the bitrate for a video with high quality output, I use the following calculation:
bitrate in kbps = FPS * WIDTH * HEIGHT * QUALITY FACTOR
So, if I have a 320x240 video at 30FPS ready for iTunes, I would substitute in the following values:
= 30 * 320 * 240 * .255
= 587kbps
The final "Quality Factor" varies, but a value of .255 would yield good quality output. The higher the factor, the higher the bitrate and thus, better quality. Experiment with this quality factor to see if it works for you.
Here are some reference links to help you get an idea of what is involved in order to calculate the right bitrate for your video:
Understanding Bit Rates
DVD bitrate calculator
http://www.videohelp.com/calc
http://www.signvideo.com/bt-rts.htm
http://dvd-hq.info/Calculator.html
http://neuron2.net/LVG/ratesandsizes.html
http://www.cs.unc.edu/~hensley/zaurus/encode.html
Troubleshooting
Improper Audio Synchronization
I've had trouble with audio synchronization in a case where I rendered a file from a video track that did not start at zero on the timeline, but started a couple hundred frames after the audio. When I combined the rendered video and audio outside of Cinelerra in FFMPEG, the audio synchronization was off. To make your life easier, keep the start and end of your video and audio tracks perfectly aligned. Make sure to zoom in to less than five frames to verify this.
Types of Rendering Problems
First, confirm if the crash is a result of a problem in the timeline or your rendering parameters.
Crashes Due to Timeline Problems
I've had crashes due to problems in the timeline when rendering hour plus video out of Cinelerra for the following reasons:
-a bug while stacking video effects (specifically, when the Sharpen effect was at the bottom of a stack of six other effects on a video track)
-there were frames of no video between clips on a video track that was being rendered out (if you zoom in all the way on a track, make sure the clips are aligned next to each other)
- I've gotten crashes if I have a transition that overlaps a very short bit of empty space between two adjacent segments of audio or video. To stop this, I will go to the end of a segment, zoom in all the way, and make sure that the video and audio tracks end at the exact same time. If they don't end at the exact same time, I clip off a bit of whatever track is dangling by using the mark in/mark out indicators and doing a "cut". I can then be assured that when I paste a new segment to the end of this recently snipped one that the segments will align perfectly. Once the segments are aligned, I then apply the transition.
Crashes Due to Bad Rendering Parameters
As well, renders sometime bomb out due to parameters I've selected for the render. For instance, when I added the -ilme -ildct -hq arguments to the DVD render in the above example.
Troubleshooting Render Problems
Try to find the exact moment in the timeline where the render breaks. I found the Sharpen effect problem by rendering the first half of the video in the timeline and then successively rendering smaller sections of the timeline until I found the exact place in the timeline where the render is breaking. At which point, it is a matter of either finding a hole in the video or turning off effects/transitions until your render tests work without crashing.
This time consuming; however, if you've spend a lot of time editing, it is the only way to salvage all your hard editing work.
Truncated Video Track
Also, another difficulty I've had is when I open a just-rendered YUV4MPEG stream (.M2V video file) back into a project, the video is truncated and is shorter than the companion audio track. You can read about my troubles here: https://init.linpro.no/pipermail/skolelinux.no/cinelerra/2006-March/005760.html.
I resolved this using two methods:
Don't re-import a YUV4MPEG video after rendering it. In other words, do all of your editing within Cinelerra and then render ONE TIME ONLY when you are done with all of your edits. This may not be feasible on large projects, though.
Use QuickTime for Linux container format to render to and re-import back into Cinelerra. This container does not have the same strange behavior as YUV4MPEG. In other words, when bringing a recently rendered video back into Cinelerra, the audio and video tracks are of the same length and perfectly in sync.
--------------------------------------------------------------------------------
I hope you enjoyed this evolving document. The developers of Cinelerra were kind enough to provide us with a very powerful product that would normally cost thousands of dollars. So I'd like to thank the folks at Heroine Warrior for doing such a fine job programming and all the people at http://cvs.cinelerra.org/ who commit countless hours of their free time and energy on the software. As such, I felt it necessary to give back something to this community who has given us such a gift.
Please let me know of any new topics or improvements you'd like to see in this doc or maybe a new doc! Thanks!
***the mule***
If this post was useful to you..consider buying me a beer via PayPal!
Even a $1 Draft will keep the Mule happily working..and help pay for equipment upgrades!
Subscribe to:
Posts (Atom)