MPEG-4 AVC / H.264
- Tab.
- Joined: Tue May 13, 2003 10:36 pm
- Status: SLP
- Location: gayville
MPEG-4 AVC / H.264
Yo.
As some of you are aware, the recent addition to the MPEG-4 standard, ISO 14496-10 Advanced Video Coding, has finally been breaking out of infancy as companies and open projects take up its development. For a long time, this standard has been purely mythical -- lacking any decent implementation for either encoding or decoding. Fortunately, this is rapidly becoming untrue. As of now, it is finally possible to produce an MP4 file containing AVC video and HE-AAC audio entirely with free (as in beer) software.
Here's a list of important applications that currently support AVC:
E = encode D = decode M = mux S = split/demux
ffdshow (x264, lavc):____ E_D____
ffmpeg (lavc):____________D___S
mencoder (x264):_______E______
mplayer (lavc):___________D___S
VLC (x264, lavc):_______E_D_M_S
moonlight dshow filters:___ D___ S
mpeg4ip:__________________M_S
and a list of applications that are slated to support AVC in the near future:
Nero (ateme):__________E_D_M_S
Quicktime:____________ E_D_M_S
3ivX:_________________E_D_M_S
GPAC:____________________M_S
The things in parenthensese are the libraries/sources used for encoding/decoding AVC content. Muxing and splitting refers to ability to handle AVC in MP4, which is its native container format.
The encoders from Nero and Quicktime are going to be a big boon for the standard. I've personally beta-tested ateme/nero's encoder and it is by far the best AVC codec to date, if not the best codec in general (a conclusion that sagittaire's initial tests seem to agree with). For animated content it is about on par with RV10. I'd like to provide a sample, but unfortunately only the ateme decoder that I can't redistribute to you supports all the features of main profile AVC.
AVC is, without a doubt, the codec that will become defacto in the near future. It has been included mandatorily in both the HD-DVD and Blu-Ray disc standards. The technologies it implements are largely the most complex and efficient to be seen any time soon. Infant encoders such as x264 already outperform the most sophisticated MPEG-4 part 2 codecs of the day. Think of x264 as the opendivx of AVC. Yeah.
That said, support is still meager. Mplayer, VLC, and ffdshow all do a pretty good job of playing AVC content, however, the libavcodec decoder is not yet totally complete. The primary thing it lacks is proper b-frame support. This is because Michael Niedermayer is a douche about them and isn't implementing them simply on principal. Hopefully someone will take care of that soon :|
The moonlight splitter and decoders don't work well yet, for me anyway. By far the best decoder is the Ateme one... but that's not out yet. Wait another week or two...
Regardless, streams encoded with x264 play back fine using ffdshow/vlc/mplayer, so the above is mostly moot. Grab one of the recent ffdshows from here, the latest vlc, or a copy of the windows-friendly mplayer here, and you'll be set. Mirrors for the sites just mentioned are badly needed, so if anyone can help out, please do.
AVC encoding is probably not something you're going to want to do immediately for your AMVs. This kind of thing is for those who used DivX 3 back in the day of Indeo and MPEG-1. Right now, it's more for testing and playing around with the new toys. However, rest assured that in the future this technology will become prevalent, so if you like what you see, you should be content to know that you'll be seeing a lot more of it. With more support from major companies, especially Ahead and Apple, distributing these files will become slightly less absurd. I've no doubt in my mind AVC will quickly phase out the use of older standards as it is rapidly absorbed into the market and adopted en-masse.
That said, and without further adieu, here's how to encode AVC right now, with good quality, absolutely free.
_________________________________________
Start out by grabbing the most recent version of ffdshow (which will most likely be here), the most recent version of mpeg4ip tools, found here, and your choice of AAC encoder (to be detailed in the next post).
Open your source in virtualdub. Go to the video compression dialog and select ffdshow. Hit configure to get to the ffdshow video for windows codec properties window. From the encoder drop down box, select H.264 | x264.
From here you'll want to modify the defaults like this:
-Bump the max I-frame interval up to whatever you're accustomed to (300 for me)
-Change IDR interval to 1
-Depending on how smooth you want the output to be, increase Deblock a and b (range: 6... -6). For anime I've found that high values usually do far more good than harm, which isn't always true of other material.
-Check "Loop filter"
Go on to the ME page.
-Check all intra- and inter- analyzer flags
-Change subpel refinement to "more iterations"
-Bump max reference frames up between 5 and 15, depending on how much time you're willing to spend encoding.
Under "Quantization"
-Change min and max for all frames to 0 and 51, respectively
Move down to "Output".
Here, you'll need to check "Store frames to external file" and select "Raw frames" while unchecking "output to avi"*** if you plan on muxing to mp4. Select a place to store your raw file and name it with a .264 extension. If you want to create AVC in AVI, leave the output settings as they were at the defaults. I wouldn't advise use of avi for distributing AVC content... however, given the lack of a good mp4-avc splitter for directshow at the moment... if you need to use windows media player then avi is your only realistic option. If you're just using VLC or mplayer then there's no reason at all to use avi.
***don't forget to go back and re-check this if you ever plan on encoding something to avi from ffdshow. Otherwise you'll get no output.
If you're using consant quantizer mode then this is all you need to do. If you plan on using multipass, on the other hand, then there's a bit more.
Multipass users continue here. CQ users skip the next paragraph.
In the output dialog, you need to check "Write" under libavcodec/x264 stats and run the encode once using either CQ or CBR. After the first encode has finished, open the same source and go back to the output dialog. Check "use" under lavc/x264 stats and calculate your bitrate from the bitrate button. Run the encode again. The result of this second encode is your final, second-pass file.
By now you should have your final .264 file. Open a command prompt (run>cmd.exe) and drop mp4creator60.exe, from the mpeg4ip tools, into the console window. The generic commandline for muxing .264 to .mp4 is this:
mp4creator60 -create=input.264 -rate=29.97 out.mp4
where input.264 is the path to your input file, -rate is the framerate of the file, and out.mp4 is the path to your final file.
Most of you know how to generate (HE-)AAC audio files, but in case you don't, I'll cover that in the next post. For now we'll just assume you have your .aac file ready and waiting. Mux it to the mp4 using the following command:
mp4creator60 -create=input.aac out.mp4
where input.aac is your aac file, and out.mp4 is the same file that contains your AVC video.
_________________________________________
That's all there is to it. I've uploaded a sample generated with x264 and RACP (to be covered tomorrow) here, and for comparison, a sample generated with xvid 1.x cvs and apple AAC (to be covered...) to contrast the old face of MPEG-4 with the new. Enjoy.
As said numerous times, I'll cover the free ways to encode audio to aac and he-aac in another post tomorrow. Till then, if you have any questions about the encoding process or AVC itself, ask away. For some more information on the technical features of AVC have a look at the FAQ on doom9. You can also follow the progress of ffdshow, x264, mpeg4ip, the moonlight splitters, and other tools in the codecs and containers forums.
If the mods want to sticky this, it may be a good idea. Your call.
Night folks.
As some of you are aware, the recent addition to the MPEG-4 standard, ISO 14496-10 Advanced Video Coding, has finally been breaking out of infancy as companies and open projects take up its development. For a long time, this standard has been purely mythical -- lacking any decent implementation for either encoding or decoding. Fortunately, this is rapidly becoming untrue. As of now, it is finally possible to produce an MP4 file containing AVC video and HE-AAC audio entirely with free (as in beer) software.
Here's a list of important applications that currently support AVC:
E = encode D = decode M = mux S = split/demux
ffdshow (x264, lavc):____ E_D____
ffmpeg (lavc):____________D___S
mencoder (x264):_______E______
mplayer (lavc):___________D___S
VLC (x264, lavc):_______E_D_M_S
moonlight dshow filters:___ D___ S
mpeg4ip:__________________M_S
and a list of applications that are slated to support AVC in the near future:
Nero (ateme):__________E_D_M_S
Quicktime:____________ E_D_M_S
3ivX:_________________E_D_M_S
GPAC:____________________M_S
The things in parenthensese are the libraries/sources used for encoding/decoding AVC content. Muxing and splitting refers to ability to handle AVC in MP4, which is its native container format.
The encoders from Nero and Quicktime are going to be a big boon for the standard. I've personally beta-tested ateme/nero's encoder and it is by far the best AVC codec to date, if not the best codec in general (a conclusion that sagittaire's initial tests seem to agree with). For animated content it is about on par with RV10. I'd like to provide a sample, but unfortunately only the ateme decoder that I can't redistribute to you supports all the features of main profile AVC.
AVC is, without a doubt, the codec that will become defacto in the near future. It has been included mandatorily in both the HD-DVD and Blu-Ray disc standards. The technologies it implements are largely the most complex and efficient to be seen any time soon. Infant encoders such as x264 already outperform the most sophisticated MPEG-4 part 2 codecs of the day. Think of x264 as the opendivx of AVC. Yeah.
That said, support is still meager. Mplayer, VLC, and ffdshow all do a pretty good job of playing AVC content, however, the libavcodec decoder is not yet totally complete. The primary thing it lacks is proper b-frame support. This is because Michael Niedermayer is a douche about them and isn't implementing them simply on principal. Hopefully someone will take care of that soon :|
The moonlight splitter and decoders don't work well yet, for me anyway. By far the best decoder is the Ateme one... but that's not out yet. Wait another week or two...
Regardless, streams encoded with x264 play back fine using ffdshow/vlc/mplayer, so the above is mostly moot. Grab one of the recent ffdshows from here, the latest vlc, or a copy of the windows-friendly mplayer here, and you'll be set. Mirrors for the sites just mentioned are badly needed, so if anyone can help out, please do.
AVC encoding is probably not something you're going to want to do immediately for your AMVs. This kind of thing is for those who used DivX 3 back in the day of Indeo and MPEG-1. Right now, it's more for testing and playing around with the new toys. However, rest assured that in the future this technology will become prevalent, so if you like what you see, you should be content to know that you'll be seeing a lot more of it. With more support from major companies, especially Ahead and Apple, distributing these files will become slightly less absurd. I've no doubt in my mind AVC will quickly phase out the use of older standards as it is rapidly absorbed into the market and adopted en-masse.
That said, and without further adieu, here's how to encode AVC right now, with good quality, absolutely free.
_________________________________________
Start out by grabbing the most recent version of ffdshow (which will most likely be here), the most recent version of mpeg4ip tools, found here, and your choice of AAC encoder (to be detailed in the next post).
Open your source in virtualdub. Go to the video compression dialog and select ffdshow. Hit configure to get to the ffdshow video for windows codec properties window. From the encoder drop down box, select H.264 | x264.
From here you'll want to modify the defaults like this:
-Bump the max I-frame interval up to whatever you're accustomed to (300 for me)
-Change IDR interval to 1
-Depending on how smooth you want the output to be, increase Deblock a and b (range: 6... -6). For anime I've found that high values usually do far more good than harm, which isn't always true of other material.
-Check "Loop filter"
Go on to the ME page.
-Check all intra- and inter- analyzer flags
-Change subpel refinement to "more iterations"
-Bump max reference frames up between 5 and 15, depending on how much time you're willing to spend encoding.
Under "Quantization"
-Change min and max for all frames to 0 and 51, respectively
Move down to "Output".
Here, you'll need to check "Store frames to external file" and select "Raw frames" while unchecking "output to avi"*** if you plan on muxing to mp4. Select a place to store your raw file and name it with a .264 extension. If you want to create AVC in AVI, leave the output settings as they were at the defaults. I wouldn't advise use of avi for distributing AVC content... however, given the lack of a good mp4-avc splitter for directshow at the moment... if you need to use windows media player then avi is your only realistic option. If you're just using VLC or mplayer then there's no reason at all to use avi.
***don't forget to go back and re-check this if you ever plan on encoding something to avi from ffdshow. Otherwise you'll get no output.
If you're using consant quantizer mode then this is all you need to do. If you plan on using multipass, on the other hand, then there's a bit more.
Multipass users continue here. CQ users skip the next paragraph.
In the output dialog, you need to check "Write" under libavcodec/x264 stats and run the encode once using either CQ or CBR. After the first encode has finished, open the same source and go back to the output dialog. Check "use" under lavc/x264 stats and calculate your bitrate from the bitrate button. Run the encode again. The result of this second encode is your final, second-pass file.
By now you should have your final .264 file. Open a command prompt (run>cmd.exe) and drop mp4creator60.exe, from the mpeg4ip tools, into the console window. The generic commandline for muxing .264 to .mp4 is this:
mp4creator60 -create=input.264 -rate=29.97 out.mp4
where input.264 is the path to your input file, -rate is the framerate of the file, and out.mp4 is the path to your final file.
Most of you know how to generate (HE-)AAC audio files, but in case you don't, I'll cover that in the next post. For now we'll just assume you have your .aac file ready and waiting. Mux it to the mp4 using the following command:
mp4creator60 -create=input.aac out.mp4
where input.aac is your aac file, and out.mp4 is the same file that contains your AVC video.
_________________________________________
That's all there is to it. I've uploaded a sample generated with x264 and RACP (to be covered tomorrow) here, and for comparison, a sample generated with xvid 1.x cvs and apple AAC (to be covered...) to contrast the old face of MPEG-4 with the new. Enjoy.
As said numerous times, I'll cover the free ways to encode audio to aac and he-aac in another post tomorrow. Till then, if you have any questions about the encoding process or AVC itself, ask away. For some more information on the technical features of AVC have a look at the FAQ on doom9. You can also follow the progress of ffdshow, x264, mpeg4ip, the moonlight splitters, and other tools in the codecs and containers forums.
If the mods want to sticky this, it may be a good idea. Your call.
Night folks.
- Tab.
- Joined: Tue May 13, 2003 10:36 pm
- Status: SLP
- Location: gayville
- Zero1
- Joined: Fri Jan 02, 2004 12:51 pm
- Location: Sheffield, United Kingdom
- Contact:
Great work Tab.
Quality in general was much better.
If the Universe DVD is as noisy as the OAV Ultimate Ed. then that was a pretty bad source, which shows how much of an improvement AVC is.
I can't wait to see how it performs on these new digital inked animes, perfectly still frames, solid colours. with B frames encoding that sort of source would be a doddle.
What about highly saturated colours (ie red and the like, heh, no codec likes red), any improvement on the encoding of those?
As for AAC encoded audio files, I'll hapilly move from mp3 and to aac providing I could encode my files using the Nero DLLs in CDex, and play them back with no hassle in such apps as Windows Media Player.
AVC will be awesome, as you stated it's in it's infancy, I mean look how DivX started out, then the XviD team tried their hand at it. Overall the progress is very good. So if AVC is this good already, it holds a lot of promise.
How scalable will AVC and/or MP4 be?, I'm wondering if it will be relatively easy to implement brand new features as they become available (whether they are covered in the standard or not) or will it be a hack job like B frames in AVI video?
Getting the masses to move to a new codec can be troublesome at first, especially when the mere mortals download a video and "It's broken" or "This video don't work", but getting people to leave their beloved AVI format is going to be even tougher.
Well that's OK if you use Media Player Classic or VLC, but your average person using the default apps will cause a surge of pleas and "OMG WTF THSI VIDOE IS TEH NOT WARKING" threads in forums all over the internet.
Bah, mass market, or quality. I know what I would choose.
Now if MS include MP4/AAC/AVC playback as a standard item in the next media player, things would become so much more simple. It seems non techs and most n00bs these days have forgotten what www.google.com and "trial and error" is, and want everything handed to them, IE in the form of closed source, corporate codecs/containers, aka WMV.
Enough with my random ranting, I want media player 11 to feature out of the box MP4/AAC/AVC playback, to be able to encode AAC audio using Nero DLLs with CDex, and to encode MP4 compliant A/V in some sort of MP4 friendly virtualdub.
Good day, and keep up the good work
Quality in general was much better.
If the Universe DVD is as noisy as the OAV Ultimate Ed. then that was a pretty bad source, which shows how much of an improvement AVC is.
I can't wait to see how it performs on these new digital inked animes, perfectly still frames, solid colours. with B frames encoding that sort of source would be a doddle.
What about highly saturated colours (ie red and the like, heh, no codec likes red), any improvement on the encoding of those?
As for AAC encoded audio files, I'll hapilly move from mp3 and to aac providing I could encode my files using the Nero DLLs in CDex, and play them back with no hassle in such apps as Windows Media Player.
AVC will be awesome, as you stated it's in it's infancy, I mean look how DivX started out, then the XviD team tried their hand at it. Overall the progress is very good. So if AVC is this good already, it holds a lot of promise.
How scalable will AVC and/or MP4 be?, I'm wondering if it will be relatively easy to implement brand new features as they become available (whether they are covered in the standard or not) or will it be a hack job like B frames in AVI video?
Getting the masses to move to a new codec can be troublesome at first, especially when the mere mortals download a video and "It's broken" or "This video don't work", but getting people to leave their beloved AVI format is going to be even tougher.
Well that's OK if you use Media Player Classic or VLC, but your average person using the default apps will cause a surge of pleas and "OMG WTF THSI VIDOE IS TEH NOT WARKING" threads in forums all over the internet.
Bah, mass market, or quality. I know what I would choose.
Now if MS include MP4/AAC/AVC playback as a standard item in the next media player, things would become so much more simple. It seems non techs and most n00bs these days have forgotten what www.google.com and "trial and error" is, and want everything handed to them, IE in the form of closed source, corporate codecs/containers, aka WMV.
Enough with my random ranting, I want media player 11 to feature out of the box MP4/AAC/AVC playback, to be able to encode AAC audio using Nero DLLs with CDex, and to encode MP4 compliant A/V in some sort of MP4 friendly virtualdub.
Good day, and keep up the good work
7-zip // x264 (Sharktooth's builds) // XviD (Koepi's builds) // MP4box (celtic_druid's builds) // Firefox // CCCP
- Tab.
- Joined: Tue May 13, 2003 10:36 pm
- Status: SLP
- Location: gayville
Yeah, so I'm probably never going to tell you about AAC or answer zero's questions, if he even had any. I'd like to some day, though.
What I will do is give a short update. In the time since my post, which was something on the order of ten million years, a few important things have happened.
1. Ahead released their AVC codec to the public in the latest version of Nero Recode and it is sweet.
2. High-profile AVC was ratified, bringing with it 8x8 transforms, quantization matrices, some cool high-frequency reconstruction shit, and other stuff that you have absolutely no conception of.
3. Doom9 conducted another of his well-known codec comparisons, resulting in a win by Nero's AVC codec, taking the position from XviD.
4. x264 and FFMPEG got better.
5. Apple released their AVC codec.
Actually, #5 was a lie. That's all though.
What I will do is give a short update. In the time since my post, which was something on the order of ten million years, a few important things have happened.
1. Ahead released their AVC codec to the public in the latest version of Nero Recode and it is sweet.
2. High-profile AVC was ratified, bringing with it 8x8 transforms, quantization matrices, some cool high-frequency reconstruction shit, and other stuff that you have absolutely no conception of.
3. Doom9 conducted another of his well-known codec comparisons, resulting in a win by Nero's AVC codec, taking the position from XviD.
4. x264 and FFMPEG got better.
5. Apple released their AVC codec.
Actually, #5 was a lie. That's all though.
- Tab.
- Joined: Tue May 13, 2003 10:36 pm
- Status: SLP
- Location: gayville
A few things:
sysKin did some work on x264's gui and released a binary of it:
sex264 (sysKin's experimental x264 gui)
Doom9 wrote a gui for encoding x264 with mencoder here. Requires the .net 2.0 beta framework.
Both x264 and libavcodec now have working b-frame implementations. That's working, not optimal. x264's bframe placement is not yet adaptive, and I'm not sure if all block modes are implemented yet. lavc doesn't apply deblocking to bframes. Still, the gains already warrant using at least 1.
celtic_druid's site seems to be down at the moment, but there's a trimmed-down mirror of ffdshow here. For mplayer/mencoder and ffmpeg I guess you're SOL for the moment. VLC nightly builds are always here.
Also, the VideoSoft decoder supports all features that lavc doesn't (filtered bframes, weighted prediction).
sysKin did some work on x264's gui and released a binary of it:
sex264 (sysKin's experimental x264 gui)
Doom9 wrote a gui for encoding x264 with mencoder here. Requires the .net 2.0 beta framework.
Both x264 and libavcodec now have working b-frame implementations. That's working, not optimal. x264's bframe placement is not yet adaptive, and I'm not sure if all block modes are implemented yet. lavc doesn't apply deblocking to bframes. Still, the gains already warrant using at least 1.
celtic_druid's site seems to be down at the moment, but there's a trimmed-down mirror of ffdshow here. For mplayer/mencoder and ffmpeg I guess you're SOL for the moment. VLC nightly builds are always here.
Also, the VideoSoft decoder supports all features that lavc doesn't (filtered bframes, weighted prediction).
- Tab.
- Joined: Tue May 13, 2003 10:36 pm
- Status: SLP
- Location: gayville
features that lavc doesn't (filtered bframes, weighted prediction).
Scratch wpred from that list, it's been added. Aside from b-frame filtering and whatever bugs may exist, lavc's implementation of baseline and main-profile AVC is now complete and it should be able to decode anything Nero (or any other AVC encoder) spits out.
Scratch wpred from that list, it's been added. Aside from b-frame filtering and whatever bugs may exist, lavc's implementation of baseline and main-profile AVC is now complete and it should be able to decode anything Nero (or any other AVC encoder) spits out.
- AbsoluteDestiny
- Joined: Wed Aug 15, 2001 1:56 pm
- Location: Oxford, UK
- Contact:
