Video Encoding (original) (raw)
Choosing a Audio or Video Internet Distribution Format
There is a depressingly small intersection of supported audio and video formats between the players that are bundled by Microsoft(Microsoft on Mac) andby Apple .
For video, the overlap consists solely of MPEG-1 and AVI (WMP support for QuickTime is only for version 2.0 and earlier, which effectively means none). The MPEG-* formats are standards. AVI is a proprietary Microsoft format, and support is dependent on the codec used inside the format (whereas with MPEG-* formats, the codec is fixed). This constraint means that AVI is not generally that well supported on Apple operating systems, in practice (because of the need for an overlapping codec).
The overlapping formats for audio are: AIFF (Apple), AU (Unix), MP3 (= MPEG-1, Layer 3), WAV (Windows). Of these, only MP3 is an official standard.
Unfortunately the overlapping standard formats (MPEG-1 and MPEG-2) are quite old (MPEG-1 standardized in 1992 and MPEG-2 in 1998). Here are the bitrates, dimensions, and physical media they are used on:
Dims FPS V kbps A kbps
VCD NTSC CD MPEG-1 320x240 29.97 1152 224 VCD PAL CD MPEG-1 352x288 25 1152 224 SVCD NTSC CD MPEG-2 480x480 29.97 2500 192 SVCD PAL CD MPEG-2 480x576 25 2500 192 DVD NTSC DVD MPEG-2 720x480 29.97 6000 224 DVD PAL DVD MPEG-2 720x576 25 6000 224
MPEG-1 is roughly VHS in quality (once expanded to the same number of pixels -- it looks ok at the specified dimensions). The MPEG-1 bitrate is variable, but there is a sweetspot around 1.2 - 1.5 Mbit/sec. In fact, compliant MPEG-1 files are quality limited because they are not allowed to exceed around 1.5 Mbit/sec (at least, if producing a standard "Constrained Parameters Bitstream"). MPEG-1 can actually go up to around 5000kbps. MPEG-1 does not support interlaced video, but MPEG-2 does. MPEG-2 is used in SVCD and DVD. MPEG-2 is used between 3mbps and 15mbps; below 3mbps it is allegedly worse in quality than MPEG-1. Above 6mbps, it is good quality. MPEG-2 is backward-compatible with MPEG-1. Both use a DCT-based codec with motion compensation, but MPEG-2 has higher precision values, so there are fewer rounding problems than in MPEG-1 (MPEG-1 always uses 8-bit; MPEG-2 can go to 11 bits). MPEG-2 supports a non-linear macroblock quantization. (For details, see
http://www.faqs.org/faqs/mpeg-faq/ http://www.bbc.co.uk/rd/pubs/papers/paper_14/paper_14.shtml
). Note that as with all codecs, while the playback is deterministic, the encoding is not. It is possible for one encoder to do a better job than another by choosing better quantization tables, for example. Also, some encoders implement more of the optional features (VBR, etc.). There are serveral comparisons on the net; see:
http://www.tecoltd.com/enctest/enctest.htm http://www.videohelp.com/comparison.htm http://www.archive.org/iathreads/post-view.php?id=2217 suggests Pinnacle DC2000 among hardware encoders
Among software encoders, tmpgenc is reputed best for MPEG-1. For MPEG-2, Cinema Craft Encoder (CCE) and tmpgenc have good reputations; both are Windows only. For configuration of tmpgenc, see http://www.dvdhelp.us/templates.html There is also a new free MPEG-2 encoder called HC: http://forum.doom9.org/showthread.php?s=&threadid=88888 and http://forum.doom9.org/showthread.php?t=100133 )
The latest standard, MPEG-4 (particularly "H.264", which is MPEG-4 Part 10), is competitive with vendor-specific ones. MPEG4 Part 2 is about twice as space-efficient as MPEG-2; MPEG4 Part 10 is about three times as space-efficient as MPEG-2. The space efficiency comes at an extra computational cost at encoding time: a H.264 encoding takes substantially more time than a MPEG4 Part 2 encoding, which in turns takes more work than MPEG-2 encoding.
QuickTime Player 6 supports MPEG-4 part 2; QT 7 supports both Part 2 and Part 10.
Windows Media Player does not support any kind of MPEG-4. Note that "Microsoft MPEG-4" is not ISO MPEG-4. Although Microsoft offers an "ISO MPEG-4" codec at http://www.microsoft.com/windows/windowsmedia/format/codecdownload.aspx it is only for a subset of the standard -- and not in an MP4 container.
By the way, the new video iPod supports two formats which QuickTime confusingly calls "H.264" and "MPEG-4". This is confusing, because H.264 is part of MPEG-4. What they mean is MPEG-4 Part 10 ("H.264" or "MPEG4 AVC" or "MPEG4-10") and MPEG-4 Part 2.
One alternative to either of the bundled players is Flash multimedia, because Flash has very wide deployment (see http://www.macromedia.com/software/player\_census/flashplayer/version\_penetration.html which indicates > 95% penetration of Flash versions that support Flash video). In Flash, video is distributed as a .FLV file; video was supported starting with Flash v6 (2002). The codec used in v6 is a Sorenson codec. In v7 Flash added a "Screen Video Bitstream" codec, and starting with Flash v8, the On2 VPx (VP6 and VP7) codecs are also supported. The easiest way to produce FLV files requires that you buy the Macromedia tools, such as "Flash MX Professional 2004". You also have to pay even more if you want to use the "Sorenson Video Professional Edition" codec instead of the worse "Sorenson Video Standard Edition" codec. Also, the references to these FLV files have to be embedded in a SWF file, for interoperation with standard browsers. There are free third-party tools for producing SWF files: in particular, the Ming project; for a list see http://osflash.org/open\_source\_flash\_projects Starting with Flash v8, the encoding situation is better; you can buy On2 Flash movie encoders relatively cheaply: http://flix.on2.com/cart/store.php The ffmpeg tool can be used to produce flv files using a Sorenson codec ("Sorenson H.263" is apparently the same as Sorenson v3). The open source libflv can encode using the "Screen Video Bitstream" codec.
Java is no longer shipped by Microsoft with Internet Explorer. In any event, JMF (Java Media Framework) http://java.sun.com/products/java-media/jmf/index.jsp does not widen the set of formats much; it does include support for MPEG-1 and H.263 video.
So at this point the choices for video are:
- use standard MPEG-1.
- use standard MPEG-4 and force some of your Windows users to download a new player (or a plugin for their existing player).
- use AVI or WMV and force some of your Apple users to download a new player (or a plugin for their existing player). (http://movies.yahoo.com/ takes this approach for example; for clients not running Internet Explorer, it uses an object specifying an mime type of "application/x-mplayer2" to force a matching plugin; this is how Microsoft recommends it is done: http://www.microsoft.com/windows/windowsmedia/howto/articles/macicp.aspx . Note that "mplayer2" here corresponds to the mplayer2.exe provided by WMP6.4; nothing to do with the MPlayer project except that MPlayer can also provide a plugin that services this mime type.)
- use Flash movies. We favor the first two choices. MPEG-1 has about 95% coverage of all desktops. If it is acceptable to force users to perform a one-time install step, there are plenty of free plugins (and free players) for either platform that allow a wide variety of formats to be played.
Note that most of the best-known video formats are patent encumbered, whether they are industry standards or not. An "open standard" is not necessarily zero cost, and often is not. WMV, MPEG-2, and MPEG-4 all fall into this category. In several important cases, no royalties for MPEG-4 are required:
Nonprofit organizations whose primary purpose is not multimedia do not have to pay licensing fees for distributing MPEG-4 encoded content (whether over the internet or not).
Subscription services with fewer than 100,000 users do not have to pay royalties.
Non-subscription sites providing free content over the internet do not have to pay royalties. See these for more information:
http://www.mpegla.com http://www.streamcrest.com/mp4.shtml http://www.videsignline.com/howto/marketresearch/159902209
Microsoft has managed to get WM9 to be part of both competing standards for next generation DVD (Blu-Ray and HD-DVD), under the name VC-1, along with H.264. It is unclear whether in practice media publishers will actually use VC-1.
There are some truly free video codecs and formats, such as the Theora codec (http://www.theora.org/) or Dirac (http://dirac.sourceforge.net/) which can be in Ogg or Matroska containers. All users will require a one-time download of a new player or plugin in order to play such content.
MPEG-2
Microsoft does not ship an MPEG-2 decoder with its operating systems, or with Windows Media Player. However, makers of hardware DVD drives ship with DVD playing software, which includes an MPEG-2 decoder. Most PC manufacturers (Dell, HP, etc.) pre-install this software. In many cases, this DVD software (PowerDVD, WinDVD, etc.) is actually a time-limited evaluation. After it expires, it may still allow for MPEG-2 decoding in WMP, even if physical DVDs can no longer be played.
Apple also does not ship with a general purchase MPEG-2 decoder, either with OSX or QuickTime. It does ship with the "DVD Player" application, which can only be used to play physical DVDs. It also sells a $20 QuickTime upgrade to be able to play arbitrary MPEG-2 content.
The reason for all of this is that MPEG-2 is patent encumbered, and the licensing rules are actually more onerous than for MPEG-4 (even though it is an older and more inferior technology). In particular, MPEG-2 requires a $2.50/unit fee for any software decoder or encoder, in addition to there being a small fee per each packaged media unit placed into distribution (such as a physical DVD), and a charge per "channel" for streaming products: http://www.mpegla.com/m2/m2-agreement.cfm
Most desktop machines run Windows, and these days, most have DVD players. However, because of software installation problems caused by this situation (the OS vendor not supplying the technology), a significant fraction of all desktops are unable to successfully play MPEG-2 content.
There are free solutions, in particular the VLC Player (www.videolan.org) is available for all major operating systems for free, and plays both DVDs and MPEG-2 files. Some discussion of its legality is here: http://www.videolan.org/doc/faq/en/index.html#id289389
MPEG-2 has other issues too; in particular it requires more space than is desirable for web distribution.
H.263
H.263 is primarily considered a videoconferencing standard. It is inferior to H.264 at all bit rates, but better than MPEG-1. Apple QuickTime supports H.263. On Windows, the situation is less clear; the Windows Media Player supports a number of FourCC codecs for H.263:
D263 H.263 DEC Presumably now owned by Intel. H260- H269 ITU H.26n Intel VDOW VDOLive VDONet H.263 internet streaming video format. Allegedly to be used (being used ?) by Microsoft in it's NetShow offering. M263 H.263 Microsoft Redmond's codec implementing the H.263 compression standard.
(From http://www.fourcc.org/codecs.php )
AVI
Windows Media Player and QuickTime Player do share some codecs, such as H.263 and MPEG-4 Part 2 video. They also share one container besides MPEG-1: AVI. In principle, it should be possible to use one of these common codecs in an AVI file, and playback on both Windows and Mac without additional downloads. This is TBD; it is quite likely this is impossible due to differing FourCC codes or contradictory implementations. For example, Microsoft's MPEG-4 Part 2 codec uses FourCC "M4S2".
Summary of Recommended Encoding Parameters
[NOTE: the recommendations below are from mid-2005. In 2006, with QuickTime 7 being prevalent, MPEG-4 Part 10 is generally fine and preferable.]
We currently recommend the following for publishing video on the internet:
- Our target player is QuickTime 6.5.2, Windows or Mac.
All media must be playable on this player, without any additional codec downloads. Always be sure to save files as "self-contained" (otherwise you end up with an unusually small file that just has references to files on your local disk, useless to internet users). - The preferred file (container) format is MP4 (suffix .mp4, or .m4a for audio only). QuickTime format (suffix .mov) is also acceptable.
Files should have the appropriate header for progressive download ("Fast Start" and "Compressed Header" in QuickTime Pro export -- "Fast Start" means that the movie header "moov" is stored in the first atom of a single fork file, this header is followed by the "mdat" interleaved video and audio data as temporal order chunks; this is necessary for progressive download but "Compressed Header" is not, though it reduces the size of the download).
We are not implementing true streaming (RTP/RTSP) at this time, so do not create a hint track ("Prepare for Internet Streaming"). - The preferred video codec is MPEG-4 part 2 (Simple Profile). Sorenson Video 3 (Basic or Pro) is also acceptable. Recommended settings are:
- size 320x240
(assuming 4:3 aspect ratio source material; though keep in mind that video aspect ratio is black magick in part because digital computer displays have differently shaped pixels than analog televisions) - 15 fps
(assuming 30fps source material such as NTSC; for PAL 25fps, use 12.5fps; for cinema 24fps use 12fps. For slowly changing NTSC, you can go down to 10fps.) - key frame every 10 seconds (150 frames)
(You can set this even higher in codecs such as Sorensen Video 3, such as once a minute, since those codecs will automatically insert key frames anyway when the amount of motion indicates it. The reason for every 10 seconds is that it makes it easer for player scanning.) - average bit rate at most 50kbytes/sec (400kbit/sec)
(The overall file data rate will be higher because of the audio track(s). You may not need this much to achieve the quality you want. Note that you should generally not set an explicit maximum bit rate but instead code by quality. For example in QuickTime Pro, setting "Limit data rate" seems to determine a mandatory (not maximum) data rate, which may result in a constant or unnecessarily high data rate. Instead you should uncheck this setting and code by Quality -- start with "Medium" or "60"; other encoders may offer a total target file size. Use two-pass VBR if your encoder is capable of it. A maximum bit rate applied at each frame, vs. for the whole file, is more relevant for streaming.)
- size 320x240
- The preferred audio codec is AAC Low Complexity ("MPEG-4 audio"). Recommended settings are:
- 64kbit/sec mono for speech
- 128kbit/sec stereo for music (assuming stereo source).
These guidelines result in files intermediate in size and quality between dialup downloads and broadcast-quality or archival-quality material. For dialup downloads, we would instead use a lower frame size (160x120, 176x132, 192x144, or 240x180).
New in 2007:
Just to put a stake in the ground, here is what i'd suggest for video format for uhurutv.
The following should produce a file ready for the iPod. It is between the quality for DVD and cell phone 3GP.
MPEG-4 Part 10 (H.264) "Baseline" profile (not "Main").
Use multi-pass encoding ("Encoding mode: Best")
size 320x240 (assuming 4:3 aspect ratio source material; use 320x176 for 16:9 source material)
"Current" (If the file is too big, set to half the current frame rate: 15fps for 30fps source material such as NTSC; for 24fps film use 12fps)
key frame "automatic" (the claim is that for H.264 you needn't force a key frame as with some other codecs. If the fast-forward/rewind doesn't work, set to every 10 seconds).
If to be used as streaming (we are): average bit rate for video 500kbit/sec do create a hint track ("Prepare for Internet Streaming") "optimize for" = "Streaming"
Alternatively, If to be used as progressive download only: average bit rate for video 400kbit/sec do not create a hint track "optimize for" = "Download" (You could also uncheck "limit data rate" and and do "code by Quality", with a level of "Medium" or "60".)
audio target bit rate at 56kbit/sec MPEG-4 audio (AAC) (mono or stereo as appropriate, "Recommended" for sample rate, and "Best" for quality)
Instead of Quicktime Pro, Final Cut Pro has its own export wizard builtin. Also, there are standalone utilities that are reputedly faster: ffmpegX http://homepage.mac.com/major4/ (free) VisualHub http://www.techspansion.com/visualhub/ ($24) VideoToGo http://www.onlymac.de/html/video2go_en.html ($10)
Windows Media Player codecs
A selection of FourCC codes registered to Microsoft (See: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwmt/html/registeredfourcccodesandwaveformats.asp http://www.fourcc.org/codecs.php http://www.microsoft.com/windows/windowsmedia/software/Macintosh/osx/default.aspx http://www.faqs.org/rfcs/rfc2361.html )
FourCC Reg Date Microsoft Description Comment
MPG4 02-Apr-01 Reserved. "Microsoft MPEG-4 video codec V1"? also DIV1?
MP41 - - Microsoft MPEG-4 v.4.1.0.3927
MP42 28-Oct-97 Microsoft MPEG-4 video codec V2. Also DIV2?
MP43 30-Apr-98 Microsoft MPEG-4 video codec V3. Also MPG3?
AP41 02-Apr-01 Reserved.
DIV3 02-Apr-01 Reserved.
DIV4 02-Apr-01 Reserved.
MP4S 02-Apr-01 Microsoft ISO MPEG-4 video V1.0. Sharp digital camera, first attempt at ISO compliance. M4S2 02-Apr-01 Microsoft ISO MPEG-4 video V1.1. Compliant with MPEG-4 Part 2.
WMV1 02-Apr-01 Windows Media Video V7.
WMV2 02-Apr-01 Windows Media Video V8.
WMV3 02-Apr-01 Windows Media Video 9 Series.
WMVP - Windows Media Video Image
The first set (3 versions of "Microsoft MPEG-4") are basically enhanced versions of H.263. They have been reverse-engineered by the DivX project, but note that the correct FourCC string has to be included for WMP to play it: http://ffmpeg.sourceforge.net/compat.php QuickTime Player on OSX can play these with a plugin:
http://homepage.mac.com/hmason/mac-ms-mpeg4v1 http://homepage.mac.com/hmason/mac-ms-mpeg4v2
The next set are (almost) compliant ISO MPEG-4 Part 2. They are downloadable from Microsoft:
http://www.microsoft.com/windows/windowsmedia/format/codecdownload.aspx
Only MP4S (not M4S2) ships with WMP9 for OSX:
http://www.microsoft.com/windows/windowsmedia/software/Macintosh/osx/default.aspx
Also, note that WMP won't work with a MPEG-4 container; the Microsoft ISO MPEG-4 codec can only be used in an AVI, ASF, or WMV container when using WMP. M4S2 is apparently used in a few cameras; there is an open source implementation of M4S2 for OSX:
http://www.oreillynet.com/pub/wlg/7231 http://emonkid.hp.infoseek.co.jp/EX_M4S2/index_e.html
The last set are the proprietary "Windows Media" codec, named either after the version of the player (7, 8, 9), or after the FourCC code (WMV1, WMV2, WMV3). These are a proprietary non-compatible variant of the ISO MPEG-4 techniques. Actually "Windows Media" includes a container format (a variant of ASF) and a codec. WMV1 and WMV2 have been reverse-engineered (see libavcodec); WMV3 not yet.
The "VCM" (Video Compression Manager) codec is released by Microsoft for backward compatibility:
"The Windows Media Video 9 VCM codec enables users of Windows Media Player 6.4 to play Windows Media Video 9-based content, in both ASF and AVI file containers."
http://www.microsoft.com/windows/windowsmedia/9series/codecs/vcm/faq.aspx
Without it, you can't use WMV* codecs in an AVI, just the older codecs.
For WMP release history, see:
http://en.wikipedia.org/wiki/Windows_Media_Player http://www.updatexp.com/windowsxpmediaplayer.html
WMP 6 Windows 98 SE, 1998 WMP 7 Windows ME, 2000 WMP 8 Windows XP, 2001 WMP 9 available, 2003 WMP 9 Windows XP SP, 2004 WMP 10 available, 2004
DRM and Copy Protection
CGMS/A (Copy Generation Management System / Analog) flags. on line 21 analog NTSC. http://en.wikipedia.org/wiki/CGMS-A 2 bits. CopyFreely, CopyOnce, CopyNoMore, CopyNever used by HBO, Cinemax, and Pay-Per-View http://www.eff.org/deeplinks/archives/003807.php PAL CP = WSS Wide Screen Signalling bit 13 (ETSI EN 300 294) Macrovision
Audio/Video Capture
You may have digital source material already, such as from a DV camera connected by firewire, or from a DVD or CD. In that case, you can skip this section.
If you have analog source material, it must be captured. Most PCs and Macs have a built-in ability to capture audio (analog to digital). For video, it is necessary to have one of these hardware solutions:
- A DV camera (these usually can take analog in and produce digital out).
- a "capture card" installed (such as Canopus ADVC 50, ATI All-in-Wonder 9800 Pro, Hauppauge WinTV PVR-250, nVidia 6600 GT).
- a "DVD Recorder", with either external or internal tapge player. You then have to rip the DVD to get out the digital video, because they typically have no digital out. They also will typically not dub any copy-protected tapes (the JVC DR-MV5S will?). And they may not have TBC.
- an external device (such as the Canopus ADVC-110 or Plextor ConvertX) which takes analog video in, and produces DV (or other format) out over firewire or USB2. The ADVC-100 and ADVC-110 are capable of defeating Macrovision copy protection (hold down Input select for 15+ seconds). The last choice (external device) is generally reputed to give the best results, and has the benefit over a card that it can be easily shared among computers, and used with both PC and Mac. For some consumer ratings of these choices, see VideoHelp.com - Capture Card ListNote that some features can be in multiple layers. For example, see http://www.canopus.us/US/products/ADVC\_selection\_guide/pm\_advc\_selection.asp ; the ADVC-300 has TBC and color correction and noise reduction while the ADVC-110 does not; the high-end VHS players like the JVC HR-S9911U do all those things too.
Some of these devices include a television tuner, and some do not. Some handle Macrovision-protected VHS, and some do not. Some of them come with firewire, and some with USB2. Some have builtin encoders to produce MPEG-2 directly, and some do not.
Once you have the capture hardware, you will also need software that recognizes the card or the external device. On the PC, VirtualDub and VirtualVCR are free. On the Mac, you can use iMovie, or QuickTime Player Pro 7, or HackTVCarbon (for OSX < 10.4 and/or QT < 7).
The quality and condition of your tape player can make a big difference in the quality of what you capture. The tape heads should of course be clean. Ideally you should have TBC (Time Base Corrector) hardware to adjust for any timing problems due to tape stretch -- some players have this integrated; it can also be done externally. Turn down any "sharpness" control on the player; in general you want to disable all filters, as you can usually do it better in software (on many players this is done by putting it in "edit" mode). The JVC Super-VHS players with TBC seem to have a good reputation (such as the now retired models JVC HR-S7600U (year ~2000) and JVC HR-S9800U you might find used, or the current JVC HR-S9911U or pro-line SR-MV40US; see http://www.digitalfaq.com/dvdguides/capture/playback.htm for discussion). Use the best analog output the player has: S-Video is better than composite (RCA) video, and component and RGB video are better than both -- although the connector is much less important than the player quality. There are video transfer services that do exactly this kind of work (VHS to DVD), for around 25−25 - 25−75 per hour of VHS, depending on various factors; they'll likely have better equipment than you do.
Now, about capture resolutions. Here are some numbers to consider.
NTSC 525 lines, 59.94 Hz vert
lines number 248 to 263 and 511 to 525 are blanked; at most 485 and often 484 lines are complete
525 * 29.967 = 15732.675 Hz
PAL-M matches NTSC except for color. Strictly speaking, PAL and NTSC specify color, not timings, and PAL-60 exists.
VHS NTSC 352x240 @ 29.967 fps ("official" resolution. ~240 lines resolution; much less than broadcast)
S-VHS NTSC 352X480 @ 29.967 fps ("official resolution. ~400 lines resolution)
SVCD NTSC 480x480 @ 29.967 fps (remainder of 525 in vertical blanking area)
DVD NTSC 720x480 @ 29.967 fps
PAL 625 lines, 15.625 kHz horiz, 50 Hz vert.
VHS PAL 352x288 @ 25 fps (240 lines horizontally, 576 vertically)
S-VHS PAL 352X576 @ 25 fps ("official" resolution. effectively, 400 lines horizontal)
SVCD PAL and SECAM 480x576 @ 25 fps (623 lines, but only 576 are used, the rest in the vertical blanking area)
DVD PAL 720x576 @ 25 fps (equivalent to 480x576 using a pixel ratio of 54/59)
When looking at frame rate, remember that NTSC and PAL are interlaced, so that each frame in the frame rate has only half the lines (59.94 Hz NTSC is 29.967 full frames per second). Discounting the horizontal lines that are part of the blanking interval, the the height of the capture should be 480 (NTSC) or 576 (PAL). (Though the "Kell Factor" adjusts for the fact that there is some redundancy, so that in fact there are only about 0.7 times this number of independent values vertically.)
In broadcast media, the vertical resolution can be related to individual horizontal scan lines. The horizontal resolution corresponds to how often the analog signal is sampled (and how much of the analog signal is active). The minimum sampling rate is determined by the bandwidth of the signal. Some video bandwidths:
VHS 2.2Mhz S-VHS 3.2Mhz NTSC Broadcast 4.2Mhz (sound is modulated at 4.5 MHz; video BW is maximum 4.2Mhz)
For NTSC, the total horizontal scan time is 1 / (29.976*525) = 63.56 microseconds, and a nominal horizontal blanking interval is 10.7 microseconds, leaving 52.86 microseconds.
active vertical lines * Kell factor * aspect ratio * 0.5 / active duration = bandwidth 484 * 0.7 * 4/3 * 0.5 / 52.86 microseconds = 4.27 Mhz
Some capture cards are only capable of 720x480 capture, so this is a non-issue. (This is still an oversimplification and resizing of aspect ratio may be required; see the Capture Guide linked below.)
If you capture at 640x480 (a 4:3) ratio, you will have digital data that can be displayed on a square-pixel monitor that will match the intended broadcast aspect ratio. The necessary minimum width is determined by frequency, but 720x480 (NTSC) and 720x576 (PAL) is how they are stored on DVD (and CCIR 601 standard), and should be equivalent to the original in quality. Capturing at a higher horizontal rate (such as 720x480) will require non-unit DAR (digital aspect ratio: 1:1, 4:3, 16:9 or 2.11:1) to be indicated in the file, so that when played back it is scaled appropriately. The DAR is a flag in the MPEG-2 file format. Most commercial DVDs have a DAR declared on the disc for 4:3 or 16:9 ratio, which your player compensates for -- this has to be done appropriately for your TV or projection system, which in the U.S. is usually 4:3, but in Europe 16:9 TVs are more common. SVCD is 480x480; it is horizintally "squeezed" when stored digitally, and then a 4:3 scaling is done on playback. Note that not all software players recognize the DAR declared in digital video files. Movies are usually shot in 16:9 ("widescreen"). If you have a 16:9 TV and a 16:9 DVD, then the player calculates that horizontal samples should be 480 x 16/9 = 853.3 rather than the stored 720, for a stretch of 1.85. If you have a 4:3 TV and a 4:3 DVD ("fullscreen"), then it is squeezed to 480 x 4/3 = 640 for a squeeze of .888. If you have a 4:3 TV and a 16:9 DVD then player has to "letterbox" -- the problem then is a fundamental discrepency between how it was shot and what is to be displayed ("pan and scan" by the studio is another unfortunate solution).
Then there is the "pixel aspect ratio" (PAR). PAR expresses the aspect ratio of an individual pixel; DAR expresses the aspect ratio of the entire image. The DAR is just one of a few choices (4:3, 16:9, etc.) while the PAR is more variable. For 720x480 DVD NTSC (4:3), the PAR is 0.9.
[For digital video to be displayed on a digital device, the DAR field can still be used, although it is often simplest to just use a 1:1 display aspect ratio. Camcorders vary as to whether they product 16:9 or 4:3 aspect ratio in raw digital; some can be switched to either mode. Cinema films are often shot and shown even wider such as 2.35:1 or 1.85:1, which is close to the 1.78:1 from 16:9.]
With a VHS source, which is visually poor to begin with, you will be interested in ways to try to improve upon the original. Capture software such as VirtualDub have filters that can help with this (e.g. static noise reduction=6, dynamic noise reduction=10). Digital audio editors also offer filters for audio cleanup; some are particularly oriented around removing LP pops, or tape hiss.
If the video was originally shot at 24fps non-interlace (which is typical for film), and then converted to NTSC or PAL frame rates, interlaced, for your VHS source, then you may want to attempt to reverse that (called "inverse telecine", or IVTC).
Note that for high-quality audio capture, a dedicated external A/D device (such as those from M-Audio) is also ideal, or at least a dedicated audio card, rather than the capture abilities of a video capture system, or builtin to a PC or Mac. But this is not necessary except for higher quality source material.
There is a "Capture Guide" at doom9.org (direct link not possible -- click "Guides" then "TV Capture" then "Analog TV capture guide"). It is quite detailed, though only discusses Windows capture software. Other good capture guides can be found at digitalfaq.com .
Archival
The encoding guidelines outlined at the top of this document are suitable for broadband download over the internet. Such files are too big to be used for download over dialup. They are also too small for it to be possible to retain the full quality of good source material.
It is almost certain that it will be desirable at a later point to produce different versions of the same content -- better quality, or in smaller size, or with a newer/better encoder, etc. For this reason, it is important to retain a good high-quality digital original.
It may be tempting to capture video directly into the final distribution (downloadable) encoding. For example, some capture cards can encode directly to various MPEG and AVI formats in hardware; HackTV can capture directly into any format that QuickTime Pro supports. While you may still want to use those encoding features, you should still capture into a high-quality digital version, and then, as a second step, convert it for distribution.
Note that even the various "DV" formats are in fact compressed, at a 5:1 ratio. The "DV" compression is also lossy. However, unless you have very high quality source material, you needn't archive in a lossless format.
All "DV25" data (as is produced by many digital video cameras) is stored at 25Mbit/sec (hence the name). This equals 3.5Mbyte/sec = 215Mbyte/minute = 13.2Gbyte/hour. The "DV50" format is twice as large, and retains more chrominance information ("4:2:2" vs. DV25's "4:1:1").
There are quite a few formats which may be used for high quality storage (DV25, DV50, M-JPEG, HuffyYUV, MPEG-2, Animation, RGB24, ...) . They vary in how much space they require, whether they have adjustable frame sizes, whether they are lossy or not (and what they sacrifice if they are), and how well they work with different editing systems. Many professional-level video editing systems work in the YUV color space, because that matches analog broadcast systems (NTSC, PAL, etc.) better. Other systems work in the RGB color space. Some codecs such as HuffYUV may not work well with editing at all, and are primarily for archival.
These trade-offs are not as relevant for poorer quality analog sources such as VHS.
For a substantial digital video project where you are going to spend a lot time editing, the cost in gigabytes of storage is not a big deal. If you have a large number of videos to process, and will not be doing much editing on them, you may want the bother and expense of saving DV originals. An hour of good quality MPEG-2 at 720x480 requires 2 to 3GB (better than 13GB for an hour of DV). Above 6000kbit/sec (2.7GB/hour = 750kbyte/sec), using a good MPEG-2 encoding implementation, MPEG-2 is very good quality. Using a good video codec such as XviD, WM9, or H.264 with a high quality VBR implementation it is possible to achieve even better space consumption -- an hour of high quality 720x480 video can be saved in as little as 750MB (200kbyte/sec = 1600kbit/sec). Keep in mind, these codecs will require substantial cpu resources to perform the encoding.
Note that if you use even a high-quality lossy archival version, recompression to a distribution size can introduce some artifacts.
For audio, it takes so much less space than video that you can capture in PCM or other lossless format, 16bit at 44.1khz (in stereo if the original is stereo). However, a high bit rate (say 192kbit/sec) AAC compression will result in less space consumption with indistinguishable quality.
Identifying a video file
Here is a selection of tools for identifying the type of a video file, as well as extracting encoding parameters and "tag" values.
software: MP4::Info language=perl license=perl description:: A pure perl basic parser of mp4 format files, to print tags and summary header field values. If you modify $debug = 1 in the source code, it will dump out header structure.
use MP4::Info; use Data::Dumper; my <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>f</mi><msup><mo>=</mo><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mi>f</mi><mi>o</mi><mi>o</mi><mi mathvariant="normal">.</mi><mi>m</mi><mi>p</mi><msup><mn>4</mn><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo separator="true">;</mo><mi>p</mi><mi>r</mi><mi>i</mi><mi>n</mi><mi>t</mi><mi>D</mi><mi>u</mi><mi>m</mi><mi>p</mi><mi>e</mi><mi>r</mi><mo stretchy="false">(</mo><mi>g</mi><mi>e</mi><msub><mi>t</mi><mi>m</mi></msub><mi>p</mi><mn>4</mn><mi>i</mi><mi>n</mi><mi>f</mi><mi>o</mi><mo stretchy="false">(</mo></mrow><annotation encoding="application/x-tex">f = 'foo.mp4'; print Dumper(get_mp4info(</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9463em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel"><span class="mrel">=</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7519em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0019em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="mord mathnormal">oo</span><span class="mord">.</span><span class="mord mathnormal">m</span><span class="mord mathnormal">p</span><span class="mord"><span class="mord">4</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7519em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mpunct">;</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">p</span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="mord mathnormal">in</span><span class="mord mathnormal">t</span><span class="mord mathnormal" style="margin-right:0.02778em;">D</span><span class="mord mathnormal">u</span><span class="mord mathnormal">m</span><span class="mord mathnormal">p</span><span class="mord mathnormal" style="margin-right:0.02778em;">er</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mord mathnormal">e</span><span class="mord"><span class="mord mathnormal">t</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">m</span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathnormal">p</span><span class="mord">4</span><span class="mord mathnormal">in</span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="mord mathnormal">o</span><span class="mopen">(</span></span></span></span>f));
software: Video::Info language=perl description:: A collection of pure perl parsers, under the Alladin Free Public License. Supports ASF, MPEG-{1,2,2.5}, Quicktime, and RIFF. The module Video::Info::Magic has a hardcoded list of magics to identify the file type.
software: File::Headerinfo language=perl description=Wrapper around other modules. Chooses a module based on file suffix.
software: DumpQuicktime language=java home=http://www.enete.com/noel/nuggets_quicktime/
software: mmpython language=python,c home=http://sourceforge.net/projects/mmpython license=LGPL description=Several formats, not all video: mp3, ogg, avi, jpg, tiff
software: YAAI language=delphi home=http://yaai.sourceforge.net/ home=http://sourceforge.net/projects/yaai license=GPL description=win32 only, specific to AVI files.
software: AVICodec language=C++ home=http://avicodec.duby.info/ home=http://sourceforge.net/projects/mediainfo home=http://mediainfo.sourceforge.net/ license=GPL/LGPL description=win32 commandline and GUI. Supports many formats.
software: MovieID home=http://www.geocities.com/cplarosa/movieid/ description=Win32 command line or GUI. Recognizes ASF, AVI, MPEG-{1,2}, QuickTime, Real license="Use it as you wish", but no source code.
software: GSpot home=http://www.headbands.com/gspot/ license=no-charge, no-source description=windows-only GUI.
software: unix file(1) and /etc/magic description<
Creating Streaming Video
Streaming video is for the most part useful only for live events -- otherwise you should just as well use progressive download.
Capturing Streaming Video
If you would like to capture the streaming video from some other site into a local file, there are a variety of approaches. The biggest challenge are the ASF format streams ( http://www.microsoft.com/technet/prodtechnol/netshow/plan/wmtbest.mspx ), because Microsoft has never documented the protocol, and has challenged people who have attempted to reverse engineer it (such as ASFRecorder). Nevertheless, there are several solutions.
On any platform, there are video capture tools, that intercept what is sent to your video card. These will not produce as good a quality as capturing the digital original as it arrives. Some commercial tools that do this are eovideo on Windows ( http://www.eo-video.com/ ) and SnapZ Pro on OSX ( http://www.ambrosiasw.com/utilities/snapzprox/ ).
To capture the actual streamed digital video, it is necessary to have tools that understand the ASF format. There are some free tools such as SDP (http://sdp.ppona.com/) that don't work reliably. There are also some commercial ones such as WM Recorder (http://www.wmrecorder.com/). There is a shareware product Net Transport ( http://sdp.ppona.com/ ), which has an uncrippled free trial. I have found that it works well. It runs only on Windows, however. (Another Windows-only ShareWare product that reputedly does this is FlashGet from http://www.amazesoft.com/ ) The procedure on Windows is:
- Find the url to an "ASX" file (or sometimes "WMV" file -- even though it ends in this suffix, sometimes they are really streamed).
This is not the video itself, but a small text file which describes it.
Sometimes (if the site is injecting extra advertising videos before and after) you'll need to copy a url into a text editor, and
extract just the URL to the one video you are interested in. - Load this into Net Transport. It will download the text file, parse it, and download the stream (using the mms or http protocol as required).
- Then use the "Make Index" menu option, which will will create a WMV file that will support seeking. It will prompt you where to save it.
- If you want to convert it to another format, use eovideo (a little hard to use, but it can be done).
The VLC player will capture ASF streams to disk ( http://www.videolan.org/doc/streaming-howto/en/ch06.html ). It can do this from either the GUI or the command line, on multiple platforms. It does require you to extract the underlying "mms:" or "http:" stream url from inside the ASX file. Xine and MPlayer also have similar abilities:
mplayer -dumpfile somefile.wmv -dumpstream mms://somehost.com/somedirectory/somefile.wmv
or
mplayer -dumpfile somefile.wmv [-dumpstream] -playlist http://somehost.com/somedirectory/somefile.asx
See http://gentoo-wiki.com/HOWTO_Rip_Streams_With_MPlayer
There is also a command line capture tool called MiMMS: http://savannah.nongnu.org/projects/mimms/
Once you have a WMV file, you may want to convert or otherwise process it. At this time, there are no free open source tools that can handle WMV3 files (from Windows Media 9 and 10), only WMV1 (Windows Media 7) and some WMV2 (Windows Media 8). On Windows (or Intel platforms like Linux that can run Windows dlls), there are free tools that can handle WMV3 encoded files, by relying on the codec dll's from Microsoft (wmv9.dll). Even in that case, DRM-encumbered files are not handled. Note that on Mac OSX, Microsoft's own Windows Media Player 9 will play WMV3 files, but only in a wmv file, not for example in an AVI file. The OSX WMP 9 apparently also has some DRM-related limitations (http://www.microsoft.com/windows/windowsmedia/software/Macintosh/osx/readme.aspx). There is a plugin (http://www.flip4mac.com/wmv.htm) to make QuickTime on the Mac deal with WMV files -- though not DRM [and WMV3 only in WMV container?]. Perioan (http://perian.org/) also adds support for AVI and FLV in QuickTime.
If it is a WMV1 or WMV2 file, you can convert it using free command line tools. AsfTools (http://www.geocities.com/myasftools/) contains some wmv-specific utilities, but mencoder and ffmpeg also perform conversion from WMV. For example:
mencoder movie.wmv -o movie.mpg -ovc lavc -oac mp3lame -of mpeg
If done on Windows (or Linux Intel), mencoder may be able to handle WMV3 as well. But such a re-encoding is likely to result in a poorer result.
Microsoft has now defined the WMV3 format so that the codec could be accepted as part of two competing new high-definition dvd standards: the HD DVD ("VC-9") and Blu-Ray BD-ROM ("VC-1"). See:
http://news.com.com/2102-1041_3-5330786.html?tag=st.util.print
http://www.eetimes.com/article/showArticle.jhtml?articleId=50500181
http://linux.slashdot.org/linux/04/11/26/0042252.shtml?tid=97&tid=106
Based on this, soon free tools will be able to deal with WMV3 files on platforms other than Windows. Note that VC-1 does not include the DRM capabilities in WMV3.
Audio/Video Editing
This document does not discuss editing at all, though we do provide some links below to audio and video editing tools, with comments.
Do not forget that you can do some basic video editing directly in QuickTime Pro. Many conversion utilities are capable of very simple editing such as extracting time segments, or cropping frames; you do not need a full video or audio editing program for such operations.
Audio/Video Conversion
setting encoding quality
In general, there are three ways to specify the quality of your encoding:
- one-pass, constant bit rate (CBR).
The same number of bits is used for every frame, regardless of whether
it is not enough or too little for the amount of change in time or
space. This is generally the worst choice. - one-pass, constant quantization.
The same spatial sampling size is used in each frame, regardless of how much change there is. This is the best way to do one-pass encoding. - two-pass, variable bit rate (VBR).
One pass is done to analyze the content, and the second pass actually
does the encoding. The specified bitrate is the average for the whole
file, not what is used for each frame.
MPEG-2 On OSX
For unknown reasons, QT does not support MPEG-2 encoding, unless you have DVD Studio Pro. It can be done with a little work: http://www.macosxhints.com/article.php?story=20030703092459312
There are some solutions on OSX:
mpeg2enc http://mjpeg.sourceforge.net/MacOS/ open source. apparently not as high quality as commercial . MJPEG tools has a complete set of tools for ready-to-burn: vcdxbuild, etc. ffmpeg the other major open source MPEG-2 encoder. apparently faster but less quality than mpeg2enc. https://init.linpro.no/pipermail/skolelinux.no/cinelerra/2005-September/004179.html http://www.transcoding.org/cgi-bin/transcode?FFmpeg_Vs._Mpeg2enc TMPGEnc http://www.tmpgenc.net/ closed source, but free. Windows only. tutorial at http://dvd-hq.info/Compression.html BitVice http://www.innobits.se/index.php $297. OSX.
Converting with QuickTime Pro 6.5.2
As an encoder, QuickTime Pro 6.5 has the benefit of being certain of producing something that QuickTime can play. It is cheap ($30), and relatively easy to use.
However, it is not capable of two-pass VBR, and in general is considered second-rate as an MPEG-4 encoder (see for example drunkenblog and extremetech). It is also slow (much slower than Handbrake, for example).
As a player, QuickTime 6.5 cannot play MPEG-4 Advanced Simple Profile (ASP) video.
There are better MPEG-4 encoders available, even free ones -- even when restricted to encoding MPEG-4 video that QuickTime is capable of playing. We describe some of these alternatives in the next section.
QuickTime Pro for inexplicable reasons has a different set of dialogs for the export options for "Movie to MPEG-4" (.mp4 file) and for "Movie to QuickTime Movie" (.mov file). When producing an mp4 file, QT Pro does not offer the ability to encode by quality (only by data rate). Also, by nature of the standard, a .mp4 file does not allow for as many video codec choices as a .mov file -- for example, no Sorenson. So because the MPEG-4 video codec in QuickTime Pro 6.5 is so poor, when using QuickTime Pro we recommend against using the .mp4 file, or the MPEG-4 video codec. Instead, use a .mov file ("QuickTime Movie") and the "Sorenson Video 3" video codec.
QuickTime 7 (to be released in 2005) will support MPEG-4 part 10 (H.264), which should be substantially better. It is unknown whether QuickTime 7 will support MPEG-4 ASP.
The "Sorenson Video 3 Pro" codec is quite good; probably better than MPEG-4 part 2 and competitive with MPEG-part 10 (H.264) and with WM9. However, this is not the same as the "Sorenson Video 3" ("Basic") codec that is bundled with QuickTime Pro; the "Pro" version is only available as part of multi-$100 products directly from Sorenson (or commercial products that license it).
Nevertheless, we still suggest using the SV3 Basic that is bundled with QT Pro instead of the MPEG-4 codec it provides. This is true despite the fact that MPEG-4 automatically performs color gamma correction across platforms (PC and Mac), and SV3 does not support this.
If you purchase a better MPEG-4 codec for QuickTime Pro to use (such as from MainConcept or Sorenson), then that should be fine.
Here is a good tutorial on using QuickTime Pro (although we are suggesting a different audio codec):
QuickTime Pro - QT Movies from FCP - For the Web .
Another tutorial on QuickTime Pro is:
Compressing and Hinting Media for Streaming
however this is for streaming and producing an .mp4, neither of which we are suggesting at this time when using QuickTime Pro.
Conversion Alternatives
Two prominent open source MPEG-4 video encoding libraries are: libavcodec (part of the the ffmpeg project), and XviD. Everyone agrees that the libavcodec/ffmpeg codec performs encoding more quickly; opinions vary about which produces better quality. These libraries are available for use within a number of tools:
- The "mencoder" command includes both libraries, and so can use either.
- The "ffmpegX" OSX GUI can use either the "ffmpeg" or the "mencoder" command, and so can use either.
It can use "ffmpeg" to place video in a .avi, .mov, or .mp4 file. It can only use "mencoder" for placing video in an .avi file. - The "mp4creator" command uses ffmpeg, plus its own capabilities.
- The "MeWiG" GUI uses ffmpeg (planning to add XviD).
If one of these procedures results in a .avi or a .mov file rather than a desired .mp4 file, QuickTime Pro or mp4creator could be used to convert to .mp4 with no re-encoding. (In QuickTime Pro, export "Movie to MPEG-4", and select "Pass through" in the "General" tab for both tracks. This choice will be greyed out if QuickTime Pro does not consider the particular track to be in encoded in an acceptable way for mp4.)
XviD QuickTime Component
The "XviD QuickTime Component" is a free plugin for QuickTime Pro on OSX. Download it, and put it in your ~/Library/QuickTime directory. After you restart QuickTime Pro, you will have a new export choice.
As long as you do not use any of the advanced choices, the resulting file can be played in any QuickTime 6.5 player, without the plugin.
mencoder (command shell)
The "mencoderosx" OSX GUI seems not to be maintained, but the "mencoder" command line is not hard to use at all. See MPlayer Documentation which includes the mencoder documentation.
Note that because QuickTime 6.5 does not support MPEG-4 Advanced Simple Profile (ASP), but only SP, you cannot use any of these features: B-frames, Qpel (Quarter Pixel), GMC (Global Motion Compensation), MPEG quantization (must use H.263). This is not entirely the same as the "Advanced" options you see in a GUI. For example, "Adaptive Quantization" in XviD is ok.
You should not encode as interlaced.
Using mencoder to encode mpeg-4 using ffmpeg in two passes at a 500kbit bitrate:
from http://www.mplayerhq.hu/DOCS/HTML/en/menc-feat-dvd-mpeg4.html
LAVCOPTS=v4mv:mbd=2:trell:cmp=3:subcmp=3:mbcmp=3
http://b0rken.dk/dvdrip has: vlelim=-4:vcelim=9:lumi_mask=0.05:dark_mask=0.01:v4mv:mbd=2:trell:cmp=10:subcmp=10:mbcmp=10:autoaspect
vhq means spend extra time in optimization, same as mbd=1
vqmin=2 is default and recommended
VPROCESS=-ofps 15 -vop scale=320x240
have to have audio "copy" not "-nosound" to keep sync
mencoder -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=500:${LAVCOPTS}:vpass=1 $(VPROCESS) input.dv -o /dev/null mencoder -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=500:{(LAVCOPTS}:vpass=2 $(VPROCESS) input.dv -o output.avi
Using mencoder to encode mpeg-4 using xvid, in two passes:
me_quality=6 is default, and slowest. motion estimation.
max_key_interval defaults to 10*fps.
trellis is faster than vhq. maximum value for vhq is 4.
quant_type=h263 not mpeg, for QT playback.
max_bframes defaults to 0
noqpel is default
XVIDOPTS=max_key_interval=150:vhq=4:quant_type=h263:me_quality=6 mencoder -ovc xvid -xvidencopts pass=1:$(XVIDOPTS) $(VPROCESS) -passlogfile menc.log inputfile.dv -o /dev/null mencoder -ovc xvid -xvidencopts bitrate=500:pass=2:$(XVIDOPTS) $(VPROCESS) -passlogfile menc.log inputfile.dv -o output.avi rm menc.log
Either way, to obtain AAC audio and mp4 output:
extract audio and convert to AAC. -vn means no video
-y means overwrite
-hq means high quality
-r video frame rate
-s 320x240 video frame size
ffmpeg -y -i input.avi -r 12 -vn temp_audio.wav
-w means mp4 (not needed if -o)
-b 128 = 128kbit average bit rate
-c 20000 = frequency cutoff (< half of sample rate)
--obj-type 0 = Low Complexity profile (default)
--mpeg-vers 2 = 2 for .aac and 4 for .mp4 or .m4a
-q 125 = quality 125% if want to code by quality instead of ABR
faac --mpeg-vers 4 -w -b 128 temp_audio.wav output.mp4
OR:
faac -w -b 128 temp_audio.wav temp_audio.aac
mp4creator -c temp_audio.aac -H -I output.mp4
extract video
avi2raw --video input.avi temp_video.m4v
-c same as -create=
-H same as -hint
-I same as -interleave
-r same as -rate=
mp4creator -c temp_video.m4v -H -r 15 -verbose=5 output.mp4
no -hint, no -interleave
mp4creator -optimize output.mp4 rm temp_audio.wav temp_audio.aac temp_video.m4v
ffmpeg (command shell)
Conversion using ffmpeg:
extract and encode audio
ffmpeg -i film.avi -vn temp_audio.mp3 faac -w -b 128 temp_audio.mp3 temp_audio.aac
extract and encode video
ffmpeg -i input.avi -an -b 400 -vcodec mpeg4 temp_video.m4v
mux into mp4
mp4creator -c temp_video.m4v -hint -r 30 output.mp4 mp4creator -c temp_audio.aac -hint -interleave output.mp4 rm temp_audio.mp3 temp_audio.aac temp_video.m4v
ffmpeg can produce mp4 [can it?]:
ffmpeg -i input.avi -an -vcodec copy output.mp4
MPEG4IP mp4creator (command shell)
Some articles:
Streaming MPEG-4 with Linux (out of date, 2003)
Use of the MPEG4IP Server Side Tools
-V =
-I = use the ISO MPEG-4 standard implementation instead of OpenDivX (xvid?)
-M = use mp3 instead of AAC
-R = input is RGB instead of YUV12
-d = leave intermediate files
mp4encode -w 640 -h 480 -r 30 -I -R -V 1000 -M -A 128 mycontent.avi mycontent_mpeg4_1000_mp3_128.mp
ffmpegX (OSX GUI)
See ffmpegX Documentation Choose "MPEG4 [.MP4] (ffmpeg)". The ffmpexgX just uses its GUI dialogs to generate shell commands -- commands which the user can't see; only the error messages. At this time, ffmpegX is unable to handle Sorenson input (although ffmpeg just added this ability, so presumably ffmpegX will handle it soon).
Article Links - More Than You Want To Know
- A Quick Guide to Digital Video Resolution and Aspect Ratio Conversions
- analogue video (chapter 9 of capture guide; disable javascript for link to work)
- Bandwidth versus Video Resolution
- Horizontal resolution: Pixels or lines
- Video Signal Measurement Fundamentals
- Conventional Analog Television - An Introduction
Archived at http://web.archive.org/web/20060831215926/http://www.ee.washington.edu/conselec/CE/kuhn/ntsc/95x4.htm - MPEG-4 AVC Quality Guide (x264 Optimized)
- H.264/MPEG-4 AVC from Wikipedia
- NTSC from Wikipedia
- DVD FAQ
- Video CD Authoring FAQ
- CD-Recordable FAQ
- John McGowan's AVI Overview
- Guide to making your own digital stereo-video movies in DVD quality for playing on computers
- The DV, DVCAM, & DVCPRO Formats
- MPEG-4 Information (including AVC/H.264)
- MP4 FAQ
- AVI Overview
- Playing Those Damn Videos on Windows
- Macos Movie FAQ
Tools
Product | OS | Category | Description | Converts | Cost |
---|---|---|---|---|---|
QuickTime Pro | OSX, Windows | converter GUI | enables "export" within the QuickTime player | many to many | commercial $30 |
ffmpegX | OSX | converter GUI | on top of ffmpeg and (optionally) mencoder | many to many | shareware ($15) with usable trial |
SUPER | Windows | converter GUI | on top of ffmpeg, MEncoder, mplayer, x264, mppenc | many to many | free binary |
Windows Media Encoder | windows | converter GUI | free binary | ||
mpegable X4 live | Windows | converter GUI | produces .mp4 files; specifically oriented around 3G files for mobile devices (see 3gp encoding) | many to MP4 | 20eu ($28) |
mplayer and mencoder osx (look in download section) and MeWiG | all (mplayer, mencoder), OSX (mplayerosx), Windows (MeWiG) | converter GUI (mencoderosx, MeWiG), converter command (mencoder), player (mplayer) | on top of mencoder. mencoderosx has not been updated since 2003, though mencoder is quite recent. | many to many | GPL |
StreamStudio | unix-like with X, uses python and QT | converter GUI | on top of ffmpeg. not maintained since 2003. | many to many | |
MediaPipe | OSX | converter GUI, converter command | apparently not an active project anymore | many to many | BSD |
HandBrake | OSX, Linux | converter GUI | for ripping to MPEG-4 | DVD to MPEG-4 | GPL |
Fairuse Wizard | Windows | converter GUI | for ripping VOB to MPEG-4, iPod, etc. | VOB to MPEG-4 | free binary, shareware |
OpenShiiva | OSX | converter GUI | for ripping VOB to MPEG-4 | VOB to MPEG-4 | GPL |
DiVA | OSX | converter GUI | for ripping VOB to MPEG-4 (no change since 2003?). no audio support, just video. uses 3ivx. | VOB to MPEG-4 | free binary |
OSex | OSX | converter GUI | for ripping VOB to MPEG-4 (no change since 2002?) | VOB to MPEG-4 | GPL |
MPEG Streamclip | OSX | converter GUI | for ripping to editable format | MPEG-1 and MPEG-2 to DV or mov | free binary |
HackTVCarbon and WhackedTV | OSX | converter GUI | for capturing firewire DV direct to a compressed format. See http://digitalmedia.oreilly.com/pub/a/oreilly/digitalmedia/2005/01/26/hacktv.html?page=1 and http://digitalmedia.oreilly.com/2005/02/02/hacktv.html | firewire to many | BSD |
MakeRefMovieX | OSX,Windows | converter GUI (MakeRefMovieX), converter command (MakeRefMovie) | make multiple encoded variants of the same source material, see Introduction to Alternate Data Rate Movies | only MOV | free binary |
DScaler | windows | real time video processor | requires AGP card, a Brooktree (Conexant) TV tuner card, and Windows. focused on deinterlacing. | GPL | |
Avisynth | windows | converter/processor command-line | AVI-oriented | AVI filtering | GPL |
VirtualDub | windows | capture and processing GUI | AVI-oriented. Uses (older) VfW drivers. | AVI, MPEG-1 | GPL |
VirtualVCR | windows | capture and processing GUI | uses DirectShow WDM drivers (not older VfW) | GPL | |
Vidomi | Windows | converter GUI, player | encodes to XviD MP4; supports distributed encoding | many to XviD MP4 | GPL (encoder), proprietary (player) |
FreeVCR | windows | capture GUI | not maintained since 2001? | GPL | |
GPAC MP4Box | Windows, Linux | converter command | uses ffmpeg, XviD and others; has its own MP4 container library. does dumping of mp4 info. | many to MP4 | GPL |
XviD QuickTime Component | OSX | converter plugin | makes QuickTime Pro on OSX capable of using XviD to encode MPEG-4 video in a .mov file | many to many | GPL |
Tuxrip | unix-like | converter command | shell script using other tools such as ffmpeg to rip DVD | DVD to MPEG-4; uses Ogg Vorbis for audio | |
acidrip | unix-like with X | converter GUI | DVD ripper in Perl, using mencoder | DVD to many | GPL |
dvd::rip | unix-like with X | converter GUI | DVD ripper in Perl, using transcode | DVD to many | GPL/Artistic |
TMPGenc | windows | converter command | convert AVI to MPEG-1 and MPEG-2. See Configuring TMPGEnc for high-quality, DVD-compliant MPEG-2 | MPEG-1 and MPEG-2 | free binary |
ffmpeg | all | converter command | arbitrary conversion; includes libavcodec used by many other projects | many to many | LGPL |
xvid and koepi xvid and nic xvid | all | converter command (mostly a library used by other programs like mencoder). Comes with dlls for both Microsoft Video for Windows (VfW, old) and DirectShow (which Microsoft is now promoting). Both support AVI files. DirectShow supports VfW drivers as well as those with a (newer) WDM (Windows Driver Module). | mpeg-4 codec | many to mpeg-4 | GPL |
JM | all | converter command | mpeg-4 part 10 (H.264) | encode and decode | open source but patent encumbered |
transcode | unix-like | converter command | arbitrary conversion; depends on mplayer, ffmpeg, and other open source projects | many to many | GPL |
mpeg4ip | all | converter command ("mp4creator"), linux capture ("mp4live"), player ("gmp4player") | creates MP4 files, using other open source libraries including ffmpeg. | many to many | LGPL/MPL |
faac and faad2 | all | converter command | AAC encoding (faac) and decoding (faad2) | audio to AAC | LGPL |
mp4ui | windows | editor GUI | only for mp4 files. can view and change header information, and add/remove tracks. does not encode. | mp4 | GPL |
mpgtx | unix-like | converter command | utilities for MPEG-1 and MPEG-2 (mpgsplit, mpgjoin, mpgcat, mpginfo, mpgdemux, tagmp3). not very active. no AC3 or mpeg-4 support. | MPEG-1 and MPEG-2 | GPL |
mjpeg tools | unix-like, particularly Linux | converter command | utilities for MJPEG video | MJPEG | GPL |
bbMPEG and bbTools and macbbdemux | all | command | various tools for demuxing MPEG-1 or MPEG-2. not active. | MPEG-1 and MPEG-2 | GPL |
VLC | all | player, streaming server | GPL | ||
Darwin Streaming Server | all | streaming server | APSL | ||
Amadeus II | OSX | audio editor and audio capture | probably best of the affordable but for-$ OSX audio editors | many audio formats | shareware ($30) with 1-month trial |
Audacity | all | audio editor and audio capture | probably best of the free audio editors. This Audacity Review compares to ProTools | many audio formats | GPL |
Sony Sound Forge | Windows | audio editor | many audio | $400 | |
Sony Vegas | Windows | video editor, audio editor | Sony acquired both Vegas and Sound Forge | $525 | |
Apple GarageBand | OSX | multitrack audio recording and mixing | see Comparison between Audacity and GarageBand | part of iLife ($79) | |
Apple iMovie | OSX | basic video editing. a tutorial is Video Editing with iMovie | part of iLife ($79) | ||
Apple Final Cut Pro | OSX | prosumer video editing | $999 | ||
Adobe Premier Elements | Windows | basic video editing | $99 | ||
MainConcept EVE | Windows | basic video editing, capture | $69 | ||
MainConcept MainActor | Windows and Linux | intermediate video editing, capture | $299 | ||
MainConcept MainActor | Windows | video editing | $199 | ||
Ulead VideoStudio | Windows | basic video editing | $99 | ||
Pinnacle Studio | Windows | basic video editing | $99 | ||
Cinellera | unix-like with X | video editing | GPL | ||
Kino | unix-like with X | basic video editing | has a particular focus on capture | GPL | |
Adobe Premier Pro | Windows | prosumer video editing | $699 | ||
GoldWave Digital Audio Editor | Windows | audio editor | $45 trialware | ||
Adobe Audition | Windows | audio editor | has some multitrack abilities | many audio | $300 |
DigiDesign ProTools Free | Windows 98/ME (not XP, and Mac version is OS9 only) | audio editor | the non-free ProTools is more advanced and supports current operating systems | free binary |