View Full Version : Encoding DVD to x264 [Updated: 06-12-2010]
Denaniel
01-02-2010, 02:49 AM
Note: I have updated this tutorial to reflect recent changes in MeGUI and x264. Important changes are marked in dark red type.
Links to other posts in this thread:
Custom bluray profiles for MeGUI
How to use the bitrate calculator
(scroll down to the section "Using the bitrate calculator")
How to extract and remux MP4 files
(including how to mux video and audio to create MP4 files)
How to correct faulty aspect ratio
How to encode audio to AAC
I used to encode with XviD. It worked great for me and I had very good results for several years, while constantly tweaking the settings and playing around with the filesize vs. quality balance. I had heard about H.264/x264 but I resisted trying it for a long time because I wanted my rips to be playable on standalone players as well as PC's and Macs. I finally made the switch when I learned about bluray compatible settings in x264, and now I'm a total convert.
There are many free programs available for converting from DVD or Blu-ray to mp4/mkv with x264. You can find a list here:
http://forum.doom9.org/showthread.php?t=129748
I recommend MeGUI for encoding. It is not the simplest option available, but it is fairly easy to use, and works well for beginners and advanced users. You'll find a tutorial and more info here:
http://mewiki.project357.com/wiki/Guides/Basic_Guide
http://forum.doom9.org/showthread.php?t=96032
http://sourceforge.net/projects/megui/
http://i50.*******.com/2h6wnco.jpg
This post is not a tutorial on MeGUI -- that has already been done, and the link is above. This is about how to use MeGUI (or any other GUI) to make vids that can be played on standalone Blu-ray players.
How to make your vids bluray compliant
If you are using MeGUI, the latest version comes with a recent patched build of x264, which allows bluray settings that are not available with the regular builds.
If you are going to use MeGUI, then read the next post (#2), and skip the rest of this post.
If you don't use MeGUI...
If you use another GUI to do your encoding, and you want your vids to be bluray compatible, so they will play on the new standalone bluray players, you need to grab a build of x264 that is "patched" with the proper features, and you need to use some very specific settings that are not part of the standard profiles.
You can get the latest patched version of x264 here:
http://x264.fushizen.eu/
Be sure to avoid the "unpatched build" and choose either 32 bit or 64 bit depending on your OS.
You need to put the x264.exe file in whatever folder your GUI places it by default. If you can't find that folder, then do a search for x264.exe and find the original version that came with your GUI. You may need to find the configuration or options menu in your GUI and point the program to wherever you put x264.exe.
Command line options
You need to include the following in your command line, or figure out how to get whatever GUI you are using to include the following settings in the x264 command line:
--level 4.1 --bframes 3 --ref 4 --slices 4 --keyint 24 --min-keyint 2 --vbv-bufsize 30000 --vbv-maxrate 40000 --aud --nal-hrd
Notes:
1. --ref 4 is for 1080p; if your source is 720p or SD (720x576 or smaller), use --ref 6
2. --keyint should be between 24 and 30 if the maximum bitrate is over 1.5 Mbit/sec; set it to equal the framerate. If max bitrate is less than or equal to 1.5 Mbit, you can set --keyint to twice the framerate (48 to 60).
3. if you are using SD material, you can set the level to 4.0 instead of 4.1, and avoid slices. This will improve the quality. But you also have to lower the vbv-maxrate. Here is the new command line for standard def:
--level 4.0 --bframes 3 --ref 6 --keyint 48 --min-keyint 2 --vbv-maxrate 15000 --aud --nal-hrd
[Note: no need to set vbv-bufsize for SD material]
(--keyint 50 for PAL, --keyint 60 for NTSC without decimation; --keyint 48 is for 24 fps film)
About using presets
If you want bluray compatibility, then the slowest preset that really makes sense IMHO is "slower". Because of bluray's requirement of maximum 3 bframes, the benefits of the other settings in "very slow" and "placebo" (without also increasing bframes) are negligible and they will only slow down your encodes for naught.
If you are using one of the faster presets, (medium, fast, faster), then a few of bluray's custom command line settings will overrule the preset needlessly. For example, in the fast preset, the number of reference frames is 2. If you include --ref 6 in the command line, this will slow down the encode dramatically. The --ref 6 is a maximum, which is needed if your preset is "slower", which normally sets --ref 8. But you don't need --ref 6 for "slow" (= --ref 5) or anything faster.
Likewise, --bframes 3 is a maximum that is not needed for "medium" or anything faster.
Denaniel
01-03-2010, 01:14 AM
To make your life much easier, I created custom profiles with bluray compatible settings and exported them in a format you can use in your own copy of MeGUI.
Here is the download link:
(Note: these are new profles, updated for the latest version of MeGUI)
http://rapidshare.com/files/396416925/MeGUI_bluray_profiles2010-06-07.rar
UnRAR into an empty folder, and you should have 26 .xml files (each .xml file is a different profile). Then copy the files into this folder:
megui\allprofiles\x264
When asked if you want to overwrite files with the same names, choose "Yes".
http://i48.*******.com/nxl4b8.jpg
Next time you open MeGUI, you will see 26 new choices in the dropdown list of profiles (aka presets).
Update: When I first wrote this tutorial, there were no bluray profiles among the many that came with MeGUI, so I made up my own. Recent versions of MeGUI do include bluray profiles, but they are not very good IMHO. They are the ones that look like this:
Bluray - 2pass
Bluray - Balanced
Bluray - High Quality
etc.
These profiles are designed for HD (high definition) sources, and they don't allow for the flexibility available to improve encoding quality when using SD (standard definition, e.g. DVD) sources. Another reason they are not very good, is that the only setting that changes between the lowest- and highest-quality profiles is the crf (constant rate factor). It is better to also tweak some of the other settings to improve quality -- e.g. me, subme, trellis -- similar to the way the fast, medium, and slow presets tweak these settings. I have adapted these standard bluray profiles that come with MeGUI so that they make more sense, and give you a better spectrum of choices (quality vs. speed) when encoding HD sources.
The HD profiles, listed in order from highest to lowest quality:
Insane > Very High Quality > High Quality > Balanced > Standard
[see note below re: Bluray - 2pass profile]
SD profiles
The other custom bluray profiles, which I created for SD material from film sources, look like this:
bluraySD-NTSC-16-9-faster-film
bluraySD-PAL-slow-film
etc.
The first one above is a profile for bluray compliance, standard def (SD), NTSC source, 16:9 anamorphic, faster preset (i.e. lower quality than slow preset), and from a film source.
The second one is also for bluray compliance, standard def, and from film, but PAL instead of NTSC, 4:3 instead of 16:9, and slow preset instead of faster preset (i.e. better quality but takes longer to encode).
The "faster" profiles will produce lower quality than the "slower" ones, but I suggest you experiment with some short clips and decide for yourself where to draw the line regarding quality vs. speed.
All of these profiles assume that you are not resizing after cropping (if any cropping is used), that your source is mod4 (width and height are multiples of the number 4), and so they will adjust the SAR (source aspect ratio) accordingly.
With x264 it is generally unnecessary to resize (which can degrade the quality) so long as you use an adequate bitrate (about 50-65% of XviD). If you do use resizing to get the proper aspect ratio, then you will need to remove "--sar xx:yy" from the custom command line. In the example below, you would simply delete the --sar 40:33 from the box under "Custom Command Line", and that line would become blank:
http://i50.*******.com/osbe52.jpg
If your source is not from film (or a DVD/video that was mastered from a film source), then you can adjust three of the settings manually, but the changes are optional. See sections in next post that begin with "If your source is film..."
Saving your own custom profiles
If you want to adapt my profiles, alter any of the profiles that come with MeGUI, or just create your own from scratch (better know what you're doing though), you can. Maybe you want a profile for TV captures, or one for anime, or maybe you don't care about bluray compliance and want to create your own "unrestricted" profile. Whatever your reasons, here's how to do it
Once you have the settings you want, click on the "New" button, give your new preset a name, and then click OK. That's it.
BTW, as if things weren't confusing enough, there are two types of "presets". First, there are the internal presets built into x264 (fast, medium, slow, etc.) Then there are presets that come with MeGUI (also called "profiles", but the GUI still says "presets") and that you can invent on your own (iPod, PSP, AppleTV, etc.)
Next time you load a vid in MeGUI, you can choose the profile/preset that you invented, and you'll get the exact same settings without all the hard work. If you tweak the settings a bit for some reason, but don't want to save the new version, MeGUI will save the new settings to the scratchpad, and it will load the scratchpad settings next time you open the program.
Bluray - 2pass profile
If you are targeting a particular file size, you can use a bitrate calculator (there is one included in MeGUI) to determine the bitrate needed to give you the size you want (based on the running time, framerate, size of the audio, and any subtitles or other extras.)
When targeting a specific bitrate, you normally use 2pass mode. The first pass gathers information about which frames or sections are more complex and need higher bitrates, and the second pass uses that information to calculate the best bitrate for each frame while the vid is encoded.
The "Bluray - 2pass" profile has an arbitrary bitrate of 8000 selected as a target. This is designed for 1080p HD material, but is too high for 720p and SD material. You can adjust the bitrate to meet the target suggested by a bitrate calculator, or you can choose based on your own preferences. If you want to match the Bluray - 2pass profile's target of 8000 kbps with non-1080p material, here are the equivalent bitrates:
1080p -> 8000 kbps
720p -> 3000
PAL -> 1350
NTSC -> 1125
640x480 -> 1000
etc.
Denaniel
01-03-2010, 01:16 AM
Edit: this post is now out of date. The latest version of MeGUI has many new options and different standard settings and profiles than the older version that was available at the time I wrote this.
I will update this post when I get a chance, but for now it will probably only confuse you.
The final section titled "Using the bitrate calculator" is still useful, however.
If you want to manually tweak the settings yourself to get the best quality (without sacrificing a lot of speed for very little gain), here is a step by step guide. This will show you how to create the "slower" profiles from scratch, and you can learn a little about the MeGUI interface at the same time.
Another thing I've learned since I wrote the first post, is that if your source is standard def (SD), e.g. from a DVD or VHS source, you can lower the Level (from 4.1 to 4.0) and thus avoid using slices, and you can also raise the Max GOP Size. Both of these changes will increase the quality of your encodes.
Setting up Config the 1st time
I'm going to show you how to set up MeGUI to make the highest quality encodes using x264 if your source is standard def, i.e. SD not HD, and you want Blu-ray compliance.
After opening* MeGUI, click on Config to get to the x264 configuration dialog.
(if it opens too slowly, see tip at the bottom of this post)
At bottom left, under Presets, choose "p6 - Slower"
Click box next to "Advanced Settings"
You should now see this:
http://i47.*******.com/5fka3n.jpg
We will come back to the Main tab after tweaking the settings on the other tabs. The command line settings in this pic are not what we want; notice how they change each time we switch to a new tab.
Misc tab
Under "Adjustments" click on the button "Preset Settings"
Under "Custom Command Line" type in (or paste) the following:
--aud --nal-hrd
http://i48.*******.com/2il0mrm.jpg
Notice that --aud --nal-hrd now appears near the end of the command line, and that many of the other command line settings have changed.
Optional: If you want, you can also enter an adjustment for the aspect ratio. Instead of resizing your 720x576 or 720x480 DVD resolution (or a smaller cropped resolution), you can use any mod 4 resolution (width and height both must be a multiple of the number 4) without resizing if you adjust the "source aspect ratio" (SAR). Here is a chart with the proper setting depending on your source:
PAL 4:3 --sar 12:11
PAL 16:9 --sar 16:11
NTSC 4:3 --sar 10:11
NTSC 16:9 --sar 40:33
Note2: if you are using my profiles and you decide to resize to the proper aspect ratio, then you can simply remove the "--sar xx:yy" (xx and yy are numbers) from the custom command line.
Analysis tab
All of the settings are as they should be.
Optional: If your source is film (or DVD/video that was mastered from a film source, e.g. not shot on video or captured from TV), there is one change you should make on this tab:
Psy-Trellis Strength = 0.20
Otherwise, leave it at zero.
http://i46.*******.com/10fxksx.jpg
Psy-Trellis Strength is set to 0.20 for film tuning only, otherwise leave it untouched.
Rate Control tab
VBV Buffer Size = 24000
Leave everything else untouched.
http://i49.*******.com/nd2yxd.jpg
--vbv-bufsize 24000 is now included in the command line.
Frame-Type tab
Maximum GOP Size = 48 to 60, set to twice framerate*
Minimum GOP Size = 1
Number of Reference Frames = 6
*If your source is
NTSC (29.97 fps), set Max GOP = 60
PAL (25 fps), set Max GOP = 50
Film (24 fps), set Max GOP = 48
anthing else, set Max GOP = 2x frames per second
Optional: If your source is film (see note under Analysis tab, above) there are two more changes:
Deblocking Strength = -1
Deblocking Threshold = -1
http://i47.*******.com/ets36x.jpg
Deblocking Strength and Threshold are set to -1 for film tuning only, otherwise leave them untouched.
Back to Main tab
AVC Level = Level 4
MeGUI won't let you make this Level setting until you set the VBV Max Bitrate to 15000 (which it did automatically when you set the VBV Buffer Size), so we have to come back to the Main tab again.
While you're here, you can change the crf (Const. Quality) setting, or you can elect to do a 2 pass or 3 pass encode.
The default setting is --crf 23, which is fine for some sources, and will probably give you relatively small file sizes. Best quality is --crf 18 (lower number equals higher quality plus larger filesize), but 18 will produce about 2.5 times the file size of 23. Personally, I like --crf 21, which is about 50% larger than 23, but also noticeably better quality in many cases. You can play around with encoding short clips and make your own decision.
Using the bitrate calculator
http://i45.*******.com/292qm54.jpg
You set the framerate, the audio type and audio bitrate you want, the container (mkv or mp4), and the file size -- the calculator will then tell you what the average video bitrate should be.
You can use the bitrate calculator (in Tools menu) if you want to target a specific file size (700 MB or 1 GB, for example), and MeGUI will automatically enter the proper bitrate in the command line. The default option in this case is ABR (average bitrate), but I recommend selecting "Automated 2pass" instead, and then click the box marked "Turbo" to speed up the first pass.
http://i48.*******.com/2re358n.jpg
It really isn't necessary to do a full quality first pass, because the idea of the first pass is just to get statistics that help the codec to calculate the bitrate distribution during the second pass. The Turbo option changes some of the settings during the first pass to speed it up a lot, but the second pass settings will stay as you set them.
*Tip: if you find that it takes a long time for your script to open in MeGui, you can speed this up by preventing the preview window from opening automatically each time you open a new script (it can always be opened afterward if you like).
You will find this under Options->Settings->Main then deselect “Open preview after AviSynth script selection". (Thanks, Porsche_fan.)
melvin
01-06-2010, 10:16 PM
This codec is real magic. I´m just about to restore and resize some old movies and the results are stunning.
However, it needs a lot of calculation time unless you have a very fast machine...
louiscar
01-07-2010, 03:29 PM
Just a question about your own choices. Any reason why you choose MP4.
Personally I find mp4 files a pain when it comes to editing or cutting. Vdub for instance won't look at them and I presume by the error message it's nothing to do with a codec not being present, (could be wrong). I think it's the mp4 format it doesn't recognise.
Gom player and kmplayer also don't seek smoothly through the video. A number of other problems compared to the avi wrapper.
Just interested if there are issues that I've not understood that make an mp4 wraooer better than avi.
Porsche_fan
01-07-2010, 06:02 PM
I'll let Denaniel answer from his prospective but I can address the question from my limited prospective. As I mentioned earlier, the advantage of mp4 is the use of the more effective h.264 codec's (x.264 is the free version) compressibility.
The bit rate require to achieve the same image quality is greatly reduced...Denaniel mentioned in the tutorial it is about "about 50-65% of XviD". The result is that the video quality on a mp4 file, done correctly, is visibly better than one with Xvid. This is even true for extremely high 4,500+ kbps bitrate files in HD.
Personally, I think the advantage is more than just bitrate related, as to me h.264 more correctly represents the original image than Xvid. It is also much easier to obtain the optimal configuration compared to Xvid as a result of the new x.264 presets...slower, slow ect.
There are several downsides to h.264. First, because it is highly compressed it requires more CPU to decode, especially if the codec's internal deblocking is utilized. Ffdshow allows the user to select different levels of activating the internal deblocking architecture, which reduces CPU cycles.
The second downside is the lack of easy to use editing software. There are a couple of solutions to this problem. First, you can frameserve the file to VirtualDubMod using directshowsource...you need to have a codec like ffdshow installed. Also be aware that any settings that are selected on ffdshow such as resize or sharpeners will show up in the video you are frameserving to VDM. My personal experience is that VDM doesn't handle this too well and outputs as an uncompressed file. Sometimes I have to also use "converttoRGB()" to correct the image.
An alternative is to use avidemux (http://avidemux.org/). I personally haven't used it but it handles a variety of containers (avi, mp4, ASF & mkv) and has features similar to VirtualDub such as a nice preview window.
As to the player compatibility issue with mp4, I personally have had fewer issues with wrapping in the mkv (http://forum.doom9.org/showthread.php?threadid=54306) container. So if you find player compatibility issues, try rewrapping the mp4 file in mkv...it is extremely easy and takes a few seconds. I'd recommend mkvmerge GUI (http://www.bunkus.org/videotools/mkvtoolnix/downloads.html). It is user friendly and has a number of nice features.
The mkv container is superior to avi btw, allowing smaller file sizes through reducing overhead. You are probably aware of this but you can place Xvid files in a mkv container and shrink the file size. Mkv also handles VBR better than avi and allows to wrap subtitles within the container instead of having them as separate files.
MeGui also allows output as a mkv file as opposed to a mp4 file...so you don't have to go through that extra step. Personally, I think Denaniel's choice of mp4 is the right one as it is much easier, with the tools available, to change from mp4 to mkv than the other way around.
louiscar
01-07-2010, 07:23 PM
Thanks Porsche fan,
Editing H264/mp4:
I liked the frameserve suggestion although it appears that I'd need to re-encode rather than use direct stream copy this way. I end up with uncompressed video (gspot reports : IYUV w/ U & V switched) and the file is massive. A test of a few mins gave me 1.3G. :-). I'm sure I can get good results but it's a shame to degrade the original quality, there is always a downside to re-encoding.
I'll have a look at avidemux although I feel another steep learning curve coming on. :-)
Creating H264/mp4:
I tried my first test on meGUI today but it's not going too well. I see that when selecting h264, it only allows mp4 mkv or raw, so at least I can see why avi is not even an option here. However, any attempt to encode mp4 crashes x264.exe regardless of whether I create a d2v file separately or via the interface. I prefer doing it manually because I've got my avs templates set up but one thing that does cause a problem is that I convert ac3 to wav with dgindex. This is gives me another problem as meGUI won't deal with uncompressed WAV format.
As for the crash I have to assume that I have a faulty patched file. I was only able to get something output selecting the raw option. Xvid errors as well but that's more than likely because I've not installed the required file.
As for mkv, I had a file the other day that I had problems with and it appears the same, I really only wanted one scene from this file and couldn't cut it with vdub. I can play it with Gom or Vlc but the problem might be that I need a matroska codec. Not that familiar with mkv yet.
anyway thanks for your explanation.
EDIT: x264 - tried another patch version and that crashes even when using from the command line.
I finally found a version that works but I'm not sure it's a patched version so -nal-hrd params are not supported however, if anyone else is experiencing problems try here:
http://x264.nl/
Denaniel
01-08-2010, 01:59 PM
Louiscar, I will address some of your points in my next post, but I have to get this other thing dealt with right away, because it affects a bunch of people who downloaded one of my latest vids.
How to extract and remux MP4 files
I recently posted a new rip of Laura's Toys (post is here (http://vintage-erotica-forum.com/t95007-lauras-toys-1975-rebecca-brooke.html)) and after posting I found out that the 2nd audio track (director's commentary) was somehow cut short by 32 minutes. So I re-ripped the audio track from the DVD, converted it to AAC audio, and remuxed it with the original video and 1st audio track (original soundtrack) to create a new MP4 file. Problem is, a lot of people already downloaded the original file, which plays and sounds fine, except that the commentary is incomplete. There's no reason they should have to redownload the entire vid (1.22 GB) just for an optional 48 MB audio track.
So I'm going to use this opportunity to explain how to extract the video and audio streams from my original LaurasToys.mp4 and then remux the video and 1st audio track with the newly ripped commentary audio. This same method can be used to add additional language tracks, subtitles, chapters and other media files to MP4 files.
Download Yamb
We'll use a cool little piece of freeware called Yamb, which is a GUI for mp4box, the versatile tool for making, editing and extracting mp4 files. The program is free and only 6.8 MB (checked clean for viruses and malware). The download page and direct download link are here:
http://yamb.unite-video.com/download.html
http://yamb.unite-video.com/Yamb-2.1.0.0_beta2_setup.exe
Extracting the video and audio streams
On the left side of Yamb, click on Editing, then double click "Click to extract streams from AVI/MP4/MOV/TS files"
http://i205.photobucket.com/albums/bb28/barronovsky/Yamb/Yamb-editing-extract.jpg
Under Input, navigate to LaurasToys.mp4
Under Content you should now see three files listed, one video (AVC) and two audio (AAC). Tick the radio button "Extract all streams to raw format"
The Output location by default is the same folder that LaurasToys.mp4 is already in.
Click Next
http://i205.photobucket.com/albums/bb28/barronovsky/Yamb/Yamb-file-extraction.jpg
Wait a few minutes while the tracks are extracted
http://i205.photobucket.com/albums/bb28/barronovsky/Yamb/Yamb-running-process1.jpg
http://i205.photobucket.com/albums/bb28/barronovsky/Yamb/Yamb-running-process2.jpg
When extraction is complete, click the Back button twice to get back to the Main window
Muxing audio and video files
On left side, click on Creation
Double click "Click to create an MP4 file with multiple audio, video, subtitle and chapters steams"
http://i205.photobucket.com/albums/bb28/barronovsky/Yamb/Yamp-creation-mp4.jpg
Click Add, and choose LaurasToys_track1.h264 [this is the video track]
Click Add again, and choose LaurasToys_track2.aac [this is the main audio track]
Click Add again, and choose commentary.mp4 [this is the commentary audio track]
The first two files were created by Yamb and should be in the same folder where LaurasToys.mp4 is located. The third, commentary.mp4, you should have downloaded from rapidshare -- the link is in my original thread here (http://vintage-erotica-forum.com/t95007-lauras-toys-1975-rebecca-brooke.html)
In the Output box, give the new file a different name, e.g. LaurasToys_remux.mp4
http://i205.photobucket.com/albums/bb28/barronovsky/Yamb/Yamb-MP4-File-Creation.jpg
Optional: If you want to specify the language and title of the two audio tracks, here's how.
Click on LaurasToys_track2.aac to highlight it, then click Properties
In the Properties dialog, click the Language dropdown box and select English
In the Track Name box, you can type in whatever you want, e.g. Original Soundtrack (just to distinguish this track from the commentary track)
Click Ok
http://i205.photobucket.com/albums/bb28/barronovsky/Yamb/Yamb-Properties-Language.jpg
Do the same for the Commentary track, but Track Name = Commentary
Click Next
http://i205.photobucket.com/albums/bb28/barronovsky/Yamb/Yamb-running-process3.jpg
It might take awhile before you see any progress, so be patient. Notice in the sample above it took three minutes to "begin importing" the first stream. It seems to take mp4box a few minutes to prepare the files. Eventually, you'll see "Importing AVC Stream..." in the list of Events, and the green progress bar will start to move.
http://i205.photobucket.com/albums/bb28/barronovsky/Yamb/Yamb-running-process4.jpg
This muxing took six and a half minutes to complete. Yours might be more or less, depending on your processor, etc.
The new file has the original video and 1st audio tracks, plus the new secondary audio (commentary) which is now complete.
My copy of Yamb always gets stuck at 99% and won't finish, but the files are complete regardless. I have to use Task Manager to "End Task" because Yamb won't finish and it won't close on its own. Minor hassle but the program works fine otherwise.
louiscar
01-08-2010, 02:50 PM
Louiscar, I will address some of your points in my next post, but I have to get this other thing dealt with right away...
No problem and this post is also of interest because I wa about to ask about adding more than one track.
Just to update my own situation, I've downloaded the latest Virtualdub 1.9.8. There are now plugins for mp4 and quicktime which I wasn't able to get to work (might be something to do with my codec choked machine). With this it loads rather than complains but it sees no audio and the preview is blank.
I did manage to load though forcing directshow.vdplugin to be used and now can see and edit the movie but curiously (which brings me to the question of multiple streams) it sees only one track, luckily the english one.
The downside is that the directshow plugin is no good for direct stream copy so re-encoding is still necessary if one needs to cut scenes.
Back to creation - I hadn't realised that audio needed to be muxed in meGUI, rather hoping that it would accept a complete avisynth offering and do the whole thing. Now I understand it's a separate step but will accept a separate avisynth file for audio (if I can figure out how to alter the script just for audio only) - this means that I can probably serve it my uncompressed wav file in some way and get it to encode that. I still need to get the muxing and other tools for meGUI but I spent a rather frustrating day on all this so taking a break.
My experience has been that I have had less sync problems if I start with an uncompressed file and using vdub code it with the audio. Muxing after encoding is a new method for me so now I'll read your post in detail to see how this is done.
louiscar
01-08-2010, 03:33 PM
This muxing took six and a half minutes to complete. Yours might be more or less, depending on your processor, etc.
As an exercise I've done this with Lingerie Intimes. Extracted to raw and muxed just one track back. It worked however I end up with a 2GB file rather than the orginal 700MB. This is odd because the .264 raw file is only 655MB and audio 30Mb.
Bitrate has gone from 1450 on the original vid to 4800 on the final so I guess it's uncompressed it in the process.
Is there something I've missed?
EDIT: LOL! Ok Yamb was having a strange moment. I tried it with both tracks and could see that once muxed I get the right size but it keeps doing it over and over again. 4 times in all. If I aborted the first file it produces is valid. I then killed it and restarted, did the first test, ie. single track and it stopped after one pass. I think something got confused somewhere. I think I may have found a possible bug but need to replicate it to be sure. The only difference is that I didn't close it after demuxing the first time around.
groovesection
01-22-2010, 02:29 AM
To answer the question posted earlier by louiscar..
MP4 is simply a container (or wrapper as you call it)
The fact the container used is MP4 has no relevance to being able to open them in Virtualdub.
Virtualdub cannot open x264 (even in an avi container) as its a AVC codec. (ISO/IEC 14496-10 - MPEG-4 Part 10)
Virtualdub only supports VFW codecs.(Directshow compatibile) (Xvid,Divx, etc)
If you want a program simillar to virtualdub to edit x264 files (in an avi/MP4 container) then i suggest avidemux
Its free and is pretty much the same as virtualdub functionality wise :D
http://fixounet.free.fr/avidemux/
I like a free software.
They are powerful & efficient compare with other expensive software
Thanks to Denaniel for this great tutorial.
If you want to convert a multimedia files to any format, I currently use WinFF.
:)
bigbobnobody
03-13-2010, 04:11 AM
My issue with the MP4 codec is the lack of use for it outside the realm of the PC.
Several DVD players will play the DivX and xvid but spits mp4's out as fast as you
put the disc with them on it in. I just don't see the better clarity with mp4 as was
suggested and being able to put 10 hours of video on one disc and watch it on TV
thru a cheap dvd player that is DivX compatible makes much more sense at least in
my circumstance.
Denaniel
06-08-2010, 01:38 AM
I updated the first two posts in this thread to reflect recent changes in MeGUI and x264. The third post is now hopelessly out of date, and I will update it when I get a chance.
My issue with the MP4 codec is the lack of use for it outside the realm of the PC.
Several DVD players will play the DivX and xvid but spits mp4's out as fast as you
put the disc with them on it in. I just don't see the better clarity with mp4...
I have one of those older DVD players that will play DivX and XviD files, but does not play mp4, so I understand what you're saying.
But many newer Blu-ray standalone players can play mp4 and mkv files, and this is why I focused this tutorial on creating mp4 files that are bluray compatible.
If you don't see the better clarity with mp4 over XviD and DivX, then either you haven't watched any high quality mp4 vids, like my recent upgrades of the Alpha France DVD's, or maybe you just need new glasses. :)
Denaniel
06-12-2010, 09:23 PM
How to correct faulty aspect ratio
Let's say you made a mistake and encoded your vid with the wrong aspect ratio (AR), or you downloaded an .mp4 with a faulty aspect ratio, like this:
http://i46.*******.com/dbir6x.jpg
This was made from a standard 4:3 PAL source, but it was encoded at 16:9 NTSC (anamorphic), so it looks squashed. The image is much wider than it should be.
Thankfully, you can correct the aspect ratio without re-encoding.
Follow the instructions in post #8 above until you get to the MP4 File Creation screen:
http://i46.*******.com/2ltlfrs.jpg
Click on the .h264 file to highlight it, then click Properties
In the Properties dialog, click the Pixels Aspect Ratio dropdown box and select 4:3 PAL (or whatever the correct AR should be for your vid).
Click Ok
http://i46.*******.com/122nrf4.jpg
Back on the MP4 File Creation screen, click Next
Continue with the instructions in post #8 from the first screen that reads "Running process".
Here is the same frame before and after:
http://i46.*******.com/dbir6x.jpg http://i48.*******.com/2lxdytg.jpg
original vid with faulty aspect ratio (AR) at left; fixed vid with corrected AR at right
Denaniel
06-12-2010, 11:26 PM
How to encode audio to AAC
AAC = Advanced Audio Codec, and it is the preferred audio format in mp4 files
Most newer DVD's have relatively high bitrate audio in .ac3 (Dolby Digital) or .dts format. Sometimes this audio is as high as 1536 Kbps with six or seven channels.
If your source DVD has stereo (2 audio channels) in .ac3 format at 192 Kbps or less (use GSpot or MediaInfo to find out), or if you don't care about the size of your mp4, you can leave the audio unchanged and simply mux it with your x264 video. Technically, you should encode the audio to AAC to comply with the H.264 standard, but many bluray standalone players and software media players will play an mp4 file with .ac3 audio. You might want to make a clip with x264 video and .ac3 audio and test it in your player.
But if the bitrate is any higher, or you want to comply with the H.264 standard to ensure your vid plays in everything it should, or if you want to reduce the size of your mp4 as much as possible, you can encode to AAC.
MeGUI comes with two AAC encoders (enc_aacplus and faac), but to get the best quality audio, I recommend using Nero AAC Encoder, which is freeware easily found by googling, or you can try this link:
http://www.videohelp.com/download/NeroAACCodec-1.5.1.zip
Look for the neroAacEnc.exe file (it comes in a "win32" folder). You can put it anywhere you want and then point MeGUI to the file. You may want to create a new folder in the megui/tools folder, call it "nero aac encoder" and put the .exe file in there.
Wherever you put the .exe, you need to point MeGUI to that location.
With MeGUI open, click on the Options menu and choose Settings.
Click on the External Program Settings tab.
At the top, to the far right of neroAacEnc, click on the button with three dots (...) and navigate to the folder where you put neroAacEnc.exe.
Then click Save.
http://i45.*******.com/66hr3b.jpg
Downmixing to stereo
If you have multichannel audio (up to 7 channels), and you want to convert it to two channels (stereo), or if your source is already stereo, then read this section. If you have multichannel and you want to keep all the channels, then see the section below "Encoding with multiple channels".
When you downloaded or updated MeGUI, you were given a choice of audio profiles (also called presets), one of which is called "Nero AAC: NDAAC-HE-64Kbps".
http://i50.*******.com/bgydjl.jpg
Start on the MeGUI Input tab. If you can find this profile in the dropdown box under Audio/Encoder settings, then click on Config and modify it as follows. If not, then choose Nero AAC: *scratchpad* click Config and modify it like this:
http://i46.*******.com/53232c.jpg
When you have tweaked the settings to match the image above, you can click on "Update" to save the new settings to the "NDAAC-HE-64Kbps" profile, or you can click on "New" and give the new preset a name of your choosing.
Just use this preset when encoding your audio, and you will get surprisingly good quality sound at about half the standard bitrate for mp3 (64 vs. 128 Kbps).
Encoding with multiple channels
If your source audio has more than two channels, you can keep all the channels and still reduce the file size by encoding in multichannel AAC.
Just choose one of the profiles that have "MultiChannel" in the name, such as "NDACC-HE-MultiChannel-HQ-192Kbps" - and modify it as above to include Apply Dynamic Range Compression and Normalize Peaks to 98. If you don't have any profiles in your Encoder settings dropdown list with "MultiChannel", then you can use the Nero AAC: *scratchpad* setting and modify it to look like this:
http://i47.*******.com/16jkbo8.jpg
Note the differences from "Downmixing to stereo"
- Output Channels = Keep Original Channels
- NeroDigital AAC Options = Adaptive Bitrate @ 192 Kbit/s
When you have tweaked the settings to match the image above, you can click on "Update" to save the new settings to the "NDACC-HE-MultiChannel-HQ-192Kbps" profile, or you can click on "New" and give the new preset a name of your choosing.
Encode it!
Once you have chosen and tweaked the preset, you are ready to begin encoding.
Start again on the MeGUI Input tab. To load the audio file, click the [...] button next to "Audio Input" and navigate to your source audio (.ac3, .dts, .mp2 or .wav). Then click on "Enqueue", move over to the "Queue" tab, and click on "Start".
A Status dialog box will open, showing you the percentage of job that is completed, and when finished encoding, the dialog will close. Your new AAC audio file (with extension .mp4) should be in the same folder as the source, unless you changed the output location in Settings.
See the Yamb tutorial in post #8 above for directions on muxing video and audio.
thedorcel
06-20-2010, 04:04 AM
thanks Denaniel i am going to try it
GailFan
01-30-2011, 09:05 AM
My issue with the MP4 codec is the lack of use for it outside the realm of the PC.
Actually, my cellphone supports MP4 (LG Arena). In fact, when I bought it last year, the documentation talked about AVI as the only container format it recognised. Trouble is, I often got a DRM error message when I tried to play an AVI that I had created myself. Did a search on the net and found out that it only supports low-res AVIs and in fact MP4 is the container I should be using.
Note that MP4 is a container format not a codec. :)
superuseron
02-18-2011, 07:39 PM
As an exercise I've done this with Lingerie Intimes. Extracted to raw and muxed just one track back. It worked however I end up with a 2GB file rather than the orginal 700MB. This is odd because the .264 raw file is only 655MB and audio 30Mb.
Bitrate has gone from 1450 on the original vid to 4800 on the final so I guess it's uncompressed it in the process.
Is there something I've missed?
EDIT: LOL! Ok Yamb was having a strange moment. I tried it with both tracks and could see that once muxed I get the right size but it keeps doing it over and over again. 4 times in all. If I aborted the first file it produces is valid. I then killed it and restarted, did the first test, ie. single track and it stopped after one pass. I think something got confused somewhere. I think I may have found a possible bug but need to replicate it to be sure. The only difference is that I didn't close it after demuxing the first time around.
I had the same problem. I have found this solution : I have tried to extract all the streams to "Mp4 format" instead of "raw format". Then I have create a new MP4 file using the video track and another audio track instead of the original audio track. The result is a correct file size without other manipulation. Hope it will work for you.
i4004
05-27-2011, 01:03 AM
To answer the question posted earlier by louiscar..
MP4 is simply a container (or wrapper as you call it)
The fact the container used is MP4 has no relevance to being able to open them in Virtualdub.
Virtualdub cannot open x264 (even in an avi container) as its a AVC codec. (ISO/IEC 14496-10 - MPEG-4 Part 10)
Virtualdub only supports VFW codecs.(Directshow compatibile) (Xvid,Divx, etc)
If you want a program simillar to virtualdub to edit x264 files (in an avi/MP4 container) then i suggest avidemux
Its free and is pretty much the same as virtualdub functionality wise :D
http://fixounet.free.fr/avidemux/
to correct a thing or two here:
it's true that mp4 is a container, however, most of other statements are a bit misleading: most of the problem regarding loading mp4 to vdub was EXACTLY the container, not the codec itself. but by now (and long time ago) it should be possible to load mp4 to vdub via plugins (visit vdub forum to get latest versions etc.)
2nd, i'm using avi container to store x264, as you can see from this mediainfo details:
Format : AVI
Format/Info : Audio Video Interleave
File size : 156 MiB
Duration : 46mn 52s
Overall bit rate : 464 Kbps
Writing library : VirtualDub build 24415/release
Video
ID : 0
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L2.1
Format settings, CABAC : Yes
Format settings, ReFrames : 3 frames
Codec ID : H264
Duration : 46mn 52s
Bit rate : 407 Kbps
Width : 512 pixels
Height : 384 pixels
Display aspect ratio : 4:3
Frame rate : 25.000 fps
Resolution : 24 bits
Colorimetry : 4:2:0
Scan type : Progressive
Bits/(Pixel*Frame) : 0.083
Stream size : 136 MiB (88%)
Writing library : x264 core 67 r1145bm d2e1e1c
Encoding settings : cabac=1 / ref=3 / deblock=1:-4:-4 / analyse=0x3:0x133 / me=umh / subme=7 / psy_rd=0.0:0.0 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / chroma_qp_offset=0 / threads=2 / thread_queue=2 / nr=0 / decimate=1 / mbaff=0 / bframes=2 / b_pyramid=1 / b_adapt=1 / b_bias=0 / direct=3 / wpredb=1 / keyint=250 / keyint_min=25 / scenecut=40 / rc=crf / crf=24.0 / qcomp=0.60 / qpmin=10 / qpmax=51 / qpstep=4 / ip_ratio=1.40 / pb_ratio=1.30 / aq=1:1.00
(notice i use "bframes"..a thing that's usually thought of as limitation of avi(it has no "native" way to put b-frames), but as you can see i'm putting them into avi just as they were used with xvid/divx)
so that's easilly possible, answer is x264vfw (that would be version of the codec that's compatible with vdub)
to end, vfw and directshow are 2 different things: both video frameworks for windows, but vfw is MUCH older than directshow.
dshow was/is usually used mainly to display video, or to feed video to encoders, it's rarely used as encoder in itself.
if somebody needs to convert x264 to xvid, try "pocket divx encoder".
i believe it uses dshow to decode any source, so anything that plays in windows players (like windows media player, or zoom player etc. with the exceptions of vlc, mpc home cinema and smiillar that pack their own decoders) should be "encodable" to xvid, and ergo playable in standalones of older kind.
(i myself hooked one pc to tv and it plays anything in existance...heh..i have no dvd-player and no intention of getting one..they don't have seek-bar to jump thru the content...:) )
ps/ tried megui twice, and it was rather fast to crash...yamb also wasn't really doing what i wanted it, tried many versons. i would probably use ffmpeg (even though it's command line) to do muxing/demuxing if need be.
gordian_knot
08-14-2011, 10:39 AM
Who has Blu-ray? I suppose some people must - Denaniel for instance :) - but I don't know anyone who has one or even wants one. Maybe we're all cheapskates where I live :).
However, I don't use a DVD player either, I use a very simple method for watching porn - stick it on a USB flashdrive and stick the flashdrive into the side of the TV. No more disk burning for me ha ha! It can play avi, mpeg, mp4 and mkv - though depending on the codec. The only real problem I have with mkv is that I create clip compilations for myself and mkv files are a bugger to edit with any degree of accuracy - despite the claims of many programs. The TV also doesn't play AAC audio. Basically it means conversion is required. It's unfortunate because Denaniel consistently posts outstanding rips of great films but for me a lower-quality avi is the way to go if it is available.
EDIT: When I said AAC I meant to say ac3. Not that it makes a difference, the TV can't play either one lol
but for me a lower-quality avi is the way to go if it is available.
I just convert them to avi, because I have difficulty editing 264. It's not that hard to do.
I haven't yet tried it, but this app claims to convert mkv:
http://www.mediacope.com/
gordian_knot
08-14-2011, 02:52 PM
I just convert them to avi, because I have difficulty editing 264. It's not that hard to do.
I haven't yet tried it, but this app claims to convert mkv:
http://www.mediacope.com/
I know how to convert and have the tools for it, but converting takes time so if there's a reasonable quality alternative I'll use that. I spend too long as it is mucking about with video files to want to convert more than I have to. Of course there are exceptions for special films or versions and for those I will do whatever is necessary :)
GailFan
08-14-2011, 07:04 PM
Who has Blu-ray? I suppose some people must - Denaniel for instance :) - but I don't know anyone who has one or even wants one. Maybe we're all cheapskates where I live :).
I have Blu-ray. Actually, I have two Blu-ray players, a Panasonic player and a PS3. Content by purely internet download is still some way off in the future for me, so its cheaper to buy discs.
I can't understand how someone can live without blu-ray today. The quality difference is significant and blu ray players are becoming quite cheap. Though I watch my porn on my computer so I haven't bothered to make my SD stuff blu-ray compliant yet. I also have a Western Digital Live Player that can play most files and upscale to 1080 if need be. 4 Tb of HD porn looks surely better on a ""50...
Denaniel
08-16-2011, 12:02 AM
I have to confess that I don't have a blu-ray player yet. When I first switched from encoding in XviD to x264, I wanted to ensure that my newly encoded vids could play on a standalone player in addition to a PC or Mac. I've since learned that even the MP4 files I've made that are not "blu-ray compliant" will often play on blu-ray players anyway.
The reason for this is that most blu-ray players can not only play commercial blu-ray discs, but also MKV and MP4 files that meet the H.264 standard, e.g. files encoded with x264. Turns out "blu-ray compliant" really means that the compliant file can be used in blu-ray authoring software to compile a standard blu-ray disc for playing in any blu-ray standalone player.
This is equivalent to converting an AVI file to standard DVD format (VOB, IFO and BUP files in a VIDEO_TS folder) for playing in a standalone DVD player. You could convert an AVI file to MPEG-2 to create DVD-compliant files that can be used by DVD authoring software, just as you could use my blu-ray compliant MP4 files in blu-ray authoring software.
But just as many standalone DVD players will also play AVI files, most blu-ray players will also play MP4 files, regardless of whether they are "blu-ray compliant". When I first began encoding in x264, I didn't realize this, and so I made all of my earliest MP4 files to be blu-ray compliant. You could probably convert those MP4 files to standard blu-ray format, but there is really no need to do so. :)
That's interesting news Denaniel. It probably means my SD x264 stuff in mp4 container could play on stand alone players without me having to to do the proper adjustments to my encoder settings. Though I use my PS3 for blu ray stuff. .and it is probably more picky than newer versatile Blu ray players so I don't expect it to run mp4 files that are not properly ps3 profile encoded.
I made experiments with "Je Suis A Prendre". Thank you for instructions.
1. If I add JeSuisAPrendre_english_audio.mp4 directly to list (h264 + aac filles from original mp4) then size of output file has been increased approx. twice. Morever I received 4 tracks (2 English & 2 French). I got rid of this effect if I extracted aac from JeSuisAPrendre_english_audio.mp4 ( commentary file) and added to list not mp4 file but just aac file.
2. I could not return to main screen by pressing "Back" twice. This method lead me to nowhere and process could be killed only from Windows Task Manager. I pressed button "Finish". Then Yamb asked me if I really want to close application. I press "No" and returned to main screen of Yamb
I can't understand how someone can live without blu-ray today. The quality difference is significant and blu ray players are becoming quite cheap.That's quite easy. After being a victim of HD-DVD, I no longer play around with expensive formats anymore. Plus, I'm not that anal about video quality to the point where a nicely encoded Xvid or DivX will also do the trick.
No, I'm going to have to agree with gordian knot here. Blu ray isn't for everybody.
[QUOTE=GWT;1766887]That's quite easy. After being a victim of HD-DVD, I no longer play around with expensive formats anymore. Plus, I'm not that anal about video quality to the point where a nicely encoded Xvid or DivX will also do the trick.
We seem to disagree what is expensive formats here. I find $2oo for a blu ray player acceptable when you consider what you get in return.
We seem to disagree what is expensive formats here. I find $2oo for a blu ray player acceptable when you consider what you get in return.I'm afraid so. I'm not going to play the format games anymore. I did it with Laserdic in the early 90s and I did it again with HD-DVD. Besides, Blu-ray discs average about twice the price of regular DVD and I believe the future will be in data streaming, anyway.
In the meantime, I'll settle for upscale DVD or the Xvid or DivX formats. I have no problem with that.
i4004
01-18-2012, 01:29 AM
to resurrect this a bit, the problem i have with hardware players (any sort of those, be it dvd. br, or some hdd with playback capability) is they're not as flexible as pc with ffdshow as a tool to improve video quality.
none of them really has sharpenign methods ffdshow has, none has adding noise and other tweaks i can use on pc to improve quality.
also, pcs are quaite cheap by now, so i would always invest 200 or 300$ to build a pc, rather than buy a player.
but i do understand most people won't be so pedantic, but i really was sold the minute i saw what ffdshow can do, looong time ago. makes no sense for me to go to hardware players esp. for divx or xvid (or other) media from web that usually needs some improvement upon playback.
though i value content over quality, still i will always prefer pc hooked to tv (pc monitors are too small) because i just can get better quality that way.
also, pc software players can do things hardware players can't.
scrubbing thru timeline is faster, i can jump anywhere i want, i can jump in any step i prefer, i can zoom easilly, i can frame advance much easier (with mouse wheel and zoom player) etc.etc. just an "ol" pc hooked to tv and few programs to run it all.
amantpoche
07-19-2012, 09:58 AM
hello all
I arrive after the battle, but maybe it'll even help some of you whether for PC or MAC.:)
I even tried some converter "Episode 5.2" I personally find it a little "gas plant, for software to 990$", short after all these tests I have returned to "MPEG Streamclip" which is free and efficient, you just load the codec "MPEG 2 to 30$" it opens the DVD converted into
of mulple format "avi, wmv, mp4, etc ..." and some other very interesting features (discovered on the publisher's site) which I will join the link.
In case you want to drill down.;)
Regards
http://www.squared5.com/
alover686
03-29-2013, 03:02 AM
Have you tried Freemake Video Converter (http://www.freemake.com/free_video_converter/) at http://www.freemake.com/free_video_converter/ ?
Freeware & super easy to use!
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.