MPEGs and iMovie

I'm trying to save some deteriorating VHS tapes of music videos from oblivion by converting them to DVDs, using a borrowed computer and DV camera. So far it seems to be workable: the 90 minute test DVD-R we burned looks no worse than the original VHS tape (though I think the black level might be a little too high.)

I would like to end up with two things:

  • A stack of DVD-Rs with videos on them, one video per chapter;
  • A directory full of videos, one video per file, in some good resolution yet reasonably portable format (which I think means MPEG-2, not Quicktime/Sorensen.)

iMovie basically works, but it's got more bugs than the insect wing of the Smithsonian. Did they test it at all? It does stuff like: you have three icons, and icon 1 is selected. You drag icon 3 to the trash. Icon 1 gets thrown away. Really fundamental idiocy like that. But, once you figure out where the land mines are, it's not too hard to do simple things with it.

Here's where I use LJ as tech support, since I suspect that a bunch of you reading this list know about such things...

So, as far as I can tell, the process goes like this:

  • The camera digitizes the baseband NTSC input, and outputs DV, which is uncompressed digital video;
  • iMovie captures that DV to disk, inconveniently splitting it up into 10 minute chunks (due to Mac file size limits); this takes about 26G per 2 hour tape;

  • Then exporting from iMovie to iDVD does... something... that takes a very long time. Is it encoding lossless DV to lossy Quicktime?

  • Then, after setting up the iDVD project (editing menus, etc.) iDVD does... something else... that takes a long, long time. Converting Quicktime to MPEG-2? This results in a 4G disk image.

  • Then actually writing the disk takes 3 minutes per minute of video. At least that part I can understand.

I'm confused about where encoding is happening. From where the delays are, it really feels like video is being encoded twice. In this process, is video being decoded, modified, and then reencoded, losing quality along the way? Is there some way to have iMovie create the files in a way that is already what iDVD expects, so that iDVD won't re-encode it?

So, the obvious way to do all this is:

  • Use iMovie to divide the clips between videos, and also put a chapter marker at each such division. (About 1/3rd of the videos will span two clips, since iMovie divided them every 10 minutes, and there's no way to re-join two clips.)
  • Save each video to a file using "Export" from iMovie;

  • Write the disk using iDVD.

This is insanely tedious, of course, especially since every one of these steps involves a lot of waiting for the computer. But it occurs to me that maybe things could be sped up by combining steps -- for example, if I write out a bunch of files from iMovie in the format that DVDs want (which is MPEG-2, right?) then can I just import those files into iDVD without it wanting to re-encode them again?

Seems to me that once I've got a directory full of MPEG-2 files, I ought to be able to do something analagous to "cdrecord *.mpg" and have it spit out a DVD-R with one chapter per file. Or is that just hopelessly naïve?

Tags: , , , , ,

33 Responses:

  1. hafnir says:

    I admit I know nothing, but I thought DV was a compressed format. Consider that no better than rumor coming from me, but that's what I thought I heard somewhere in the grapevine.

    I've thought of doing what you're doing too. One concern I had was apparently there are big differences across DVD-burning technologies, and DVD's burned one place won't play in other places. Is that a concern, or are those legacy issues, etc?

    • jwz says:

      Well damn, it would be a good trick for DV to be both lossy and produce these gargantuan files!

      My DVD player (Marantz 930) won't play DVD-R or CD-R, but it's about five years old. The Playstation 2 will play the DVD-Rs that the Superdrive (in recent Macs) writes. That's good enough for me, since the PS-2 is what I actually use as a DVD player now (the Playstation controllers are far, far better remote controls than the remote that came with the DVD player, and since they're wired, I can't lose them under the couch.)

      Of course, now iMovie crashed hard and seems to have taken the 128G Firewire disk I was using with it (haven't even been able to mount it again), so I may have just lost two days of work. "Yay."

      • hafnir says:

        > Well damn, it would be a good trick for DV to
        > be both lossy and produce these gargantuan
        > files!

        I have faith in my fellow man. :) 'Sides, the guy who posted after me agreed - majority rules! ;)

        > Playstation 2 will play the DVD-Rs that the
        > Superdrive (in recent Macs) writes. That's good
        > enough for me, since the PS-2 is what I
        > actually use as a DVD player now (the
        > Playstation controllers are far, far better
        > remote controls than the remote that came with
        > the DVD player, and since they're wired, I
        > can't lose them under the couch.)

        I'd probably be amazed if I didn't do equally silly but efficient things all the time myself. :)

        > Of course, now iMovie crashed hard and seems to
        > have taken the 128G Firewire disk I was using
        > with it (haven't even been able to mount it

        Ouch! I've done some seriously bad things on OS X while coding up my stuff, but never hit anything like that. I guess you really do have that reality distortion field that makes electronics love to hate you! I'm sorry.

  2. iberianbear says:

    Quick facts:
    - DV is lossy. It uses intra coding for all pictures (kind of like the I frames of MPEG). In english that means that all pictures are encoded without depending on others, that is, there is no use of motion in the DV codec.
    - Yes, MPEG-2 is quite a portable format.
    - Quicktime is a container that can handle different formats in it, from DV, through MPEG-2 to Sorenson.
    - DVDs are much more than a bunch of MPEG files. You have to create an IFO file, with all the navigation information.

    What's happening there:
    - Yes video is being reencoded twice, uncompressed capture => DV => MPEG2. Assuming the whole process is doing without leaving YUV space, you are still losing quality. If they do some YUV->RGB the problem is even worse. You have to wait a long time for the video to be converted to MPEG2 as this is an inherently lenghty process.
    - iDVD probably compiles a whole image of the DVD before doing anything else. It has to scan all the video files to see where everything is, seems logical that it takes that long.

    I will just add that there is software on the Market that do all this stuff on the fly. I know they exist for Windows, not sure for the Mac.

  3. grahams says:

    The latest version of iDVD and iMovie (both 3.0, i believe) remove the "export iMovie to iDVD" step. Unfortunately you have to buy iLife to get the latest version of iDVD.

  4. dsgnrdrg says:

    im a pretty big DV geek and i've been working on projects similar to this for the past two years. You've basically got everything down pat. One thing: Once the video is saved to your disk in DV Format theres only ONE conversion process from 720x480DV to 720x480 MPEG-2; also the audio stream needs to be converted to a DVD compatible format. Certain programs can do both audio and video conversion in one step.

    1. get Adobe Premiere v6.5 or Final Cut Pro. infinitely faster then iMovie at capturing or editting video.
    2. Equally important, Discreet Cleaner 6 is a great video conversion program. It has great settings and batch menus for converting video in out up and over. I have several million video apps and I can never replicate the presets Cleaner uses to encode video. One step conversion from DV A/V to DVD suitable A/V

    • jwz says:

      Ok, so if I understand this right:

      • MPEG-2 is reasonably portable;
      • When anyone non-pedantic says "Quicktime" they really mean "Quicktime + Sorensen";
      • That's also what the menus in iMovie mean when they say "Quicktime";
      • MPEG-4 is not particularly portable, and should be avoided similarly to Sorensen.

      Right so far?

      So... apparently MPEG-2 is not something that iMovie's "Export" menu will let me pick. It's got a bunch of Quicktime variants, and MPEG-4.

      I guess this means "I have no real choice but to save as Quicktime, meaning Sorensen"?

      • baconmonkey says:

        mpeg 4 is an emerging standard. DivX Video codec uses an mpeg-4 variant. mpeg 4 creates higher quality video than mpeg 2 with smaller file sizes.

        DV is a lossy codec.
        720 x 480 x 4(bytes) = 1,382,400 bytes
        that's one frame of uncompressed video.
        one second (30 frames) would be 42,854,400 bytes
        a minute would be 2,571,264,000 bytes

        storing straight-up RGB data is stupid, and wasteful, especially considering the way our eyes work. we notice differences in Luminance (brightness) way more so than differences in chromanance (color variations). Many video codecs cut the resolution of the chroma channels in half. plus there are more efficient ways of storing imagery. for example, open a still image in photoshop, Convert it to Lab Color. then go look at the individual channels. you'll notice the luminance channel has massive dynamic range, while the two chroma channels are mostly grey. and we know that low frequency images compress better, not to mention that there are fewer values used.

        Try finding a stand-alone mpeg 2 encoder. maybe

        for PC, I use when doing VCDs. It also handles mpeg-2 with several templates for DVD spec.

        on a DVD, there are a few big .vob files, which contain the mpeg data. Typically chapters in a DVD are individual points in an mpeg stream. meaning that one mpeg2 file will have multiple chapter points in it. one of the steps iDVD is doing, is assembling the vob files - the 4G disk image. writing or copying 4.7G to disk will take some time, even if it's not having to convert from QT to mpeg2.

        • baconmonkey says:

          Also, I'm pretty sure Quicktime has a DV codec, meaning you can create a quicktime file that is straight-up DV guts with a QT wrapper. I'm 99% certain of this, I'd check on my PC, but my video card is not working right (years of heat damage thanks to a broken heatsink fan on it that I never noticed) so I can't load up a video app. you should be able to specify the codec when saving the QT file.

        • jcurious says:

          are there any crossplatform mpeg4 players that will play quicktime's version of mpeg4 (other then quicktime)? I've tried VLC under windows with no luck

          • baconmonkey says:

            no idea. mepg4 is a stream format, not a file format. to QT is basically going to slap a header on an mpeg4 stream, and call it a .mov file. the the DivX Playa might handle those.

            • jcurious says:

              mpeg4 is a full "media workflow" that covers capture, authoring, editing, encoding, distribution, playback and archiving.. when imovie outputs to mpeg4 it doesn't "wrap" it in quicktime.. it's pure mpeg4 using the ability to use ISMA Profile 0 which means that it will play on the "widest range of mpeg-4 compatible devices"...

              the mpeg4 used by apple isn't "apple's mpeg4" it's full spec mpeg4... doesn't even add .mov at the end (it puts .mp4)

              • baconmonkey says:

                that's weird then. I can't see why anything would have problems with that on a windows. Microsoft started distributing mpeg4 codecs with windows quite a while ago.

                • knowbuddy says:

                  I, too, have had no luck playing "standard" MP4 files under Windows. My understanding is that MS's MP4 codecs are tied to WMA formats only. (No really, they have checks in them to make sure that you are in a WMA file played through their OCX/DLL.) Supposedly, DivX is an MP4 implementation, but even with all the latest DivX stuff I still can't play straight MP4 files. (I can only play AVIs created with the DivX codec.) Given that you still can't play straight MP2 files in Windows without downloading hacked codecs, I'm not crossing my fingers for straight MP4 codecs any time soon.

                  • baconmonkey says:

                    that's really strange. with the latest Divx, you can create straight up mp4 files. presumably you should be able to play them back too. But I just tested that, and no luck. that makes no sense at all.

                    but the MS MPEG4 mess is the inverse. the codecs detect if you're using them to create ASF/MWV files and will fail if you're making AVI. Some older apps lied to the codecs, but then MS started threatening lawsuits, and that "feature" got pulled. I've played avi files that were mpeg4 encoded just fine.
                    Though I just used Virtual dub 1.4.7 and made an avi with mpeg4 v1 codec, and it plays back fine.

                  • jcurious says:

                    divx isn't mp4 either it's a hack of microsoft's "version" of mp4

                  • baconmonkey says:

                    That's what is was back in version 3.
                    My understanding is that as of version 4, they wrote their own code. Considering they sell a "professional" version, were it merely hacked MS codec, there's be a nation of lawyers after them. Also, they now have several types of DivX certification as they are trying to wrangle Divx into comsumer electronics. Also, they have divx for Mac and Linux.

                  • baconmonkey says:

                    oh yeah, and the straight-up mp4 file output is buried in the config menus for the divx codec, and will create a .mp4 file from a divx file, resulting in a slightly smaller file that nothing seems to know what to do with.

                • jcurious says:

                  Microsoft has no intrest in having "standard" mpeg4 working on it's player.. they are out trying to get people to jump onto WMP9

          • omni_ferret says:

            I haven't tried it, but you might try "Platform4 PC Player" (warning, flash, screwed up urls).

  5. jerronimo says:

    This is for iMovie 2. I've not worked with iMovie 3 much...

    iMovie's "export for iDVD" takes the .dv clips and saves them out as a single .dv clip, wrapped in a quicktime .mov wrapper

    iDVD then takes in the .mov and converts it to MPEG2, creating the .vob or whatever files for the DVD

    I imagine that iMovie3's export just creates a .mov wrapper pointing to all of the .dv clips... since quicktime files can either contain the movie/audio/picture files, or contain references to them. I've not experimented enough with iMovie 3 to determine if this is in fact the case... I've not even used it enough to see the time audio-video slip bug that everyone has found already...

  6. baconmonkey says:

    re: black level...
    I assume you mean that things are darker.
    if that's the case, it's because TV has concepts of Superblack and Superwhite, and thus the normal operating range of TV video is 16/16/16 to 235/235/235

    many computer video codecs will try and compensate for that, and scale the brightness levels from 16-335 to 0-255, which causes darks to get a lot darker, and might cause permanent loss of luma information when transferred back to video if the codec simply truncates illegal values.

    • jwz says:

      "black level too high" => "blacks are too bright."
      "white level too low" => "whites are too dark."

      This was when playing back on a TV -- switching back and forth between the VHS source and the DVD-R source, the same video clip seemed a little more washed out coming from the DVD-R. Not a lot, but you could see it in the A/B comparison.

      (I seem to recall that it's traditional for the knobs on TVs to mislabel "black level" as "brightness", and "white level" as "contrast", or something equally weird like that.)

      • baconmonkey says:

        see, I come at "black level" from a different angle. in any graphics/video app, there's usually a "levels" filter, which allows control over where you set the black point. so when I think of black level being too high, I tend to think of the point that is considered black as having been moved up too high. i.e. setting 16 to be black makes everything from 0-16 all set to black (0), and everything else gets scaled to fit into 0-255 (or whatever settings you give for black and white).

        so maybe iDVD makes the assumption that the source video is 0-255 instead of 16-235, and brightens it accordingly, without regard to the actual values.