This thread is a spin-off of some posts
regarding how to get MKV files encoded with x264 to work with hardware acceleration (a/k/a DirectX Video Acceleration, or DXVA) on ATI HD2000, HD3000, HD4000 and NVIDIA 8000 and 9000 video cards.
The following settings will ensure hardware compatibility with players like the PS3, and also allow smooth DXVA playback on ATI and NVIDIA graphics cards when using the Cyberlink H.264 decoder included with PowerDVD
, or the free MPC Video Decoder (32-bit
), available as a standalone DirectShow filter, or as part of Media Player Classic HomeCinema
. While the settings detailed below ensure compatibility with either the Cyberlink or the MPC decoder, it is really the Cyberlink decoder that demands the stream both comply with L4.1 and declare L4.1 in the stream.
The settings have been tested to work with PowerDVD, ZoomPlayer, Media Player Classic HomeCinema, using the Haali Splitter or the Nero Digital Parser, and using the Overlay Mixer, VMR7, and VMR9 Windowless/Renderless video renderers.The Bottom LineEverybody should be encoding HD content (1080p, 720p) to Profile High @ Level 4.1. For smooth playback, "--level 4.1" should be used to mark the file as compatible when encoding. The best MeGUI profile for x264 is the DXVA-HD-HQ profile.
Edit: Avoid B-pyramids --- they still have an outstanding fix required.Note: Older Nvidia driver versions exhibited decoding errors with B-pyramid enabled. This is no longer an issue since Forceware 169.21.
The MeGUI DXVA-HD-HQ profile options:
--level 4.1 --ref 4 --mixed-refs --bframes 3 --b-rdo --bime --weightb --direct auto --filter -1:-1 --trellis 2 --partitions p8x8,b8x8,i4x4,i8x8 --8x8dct --vbv-bufsize 50000 --vbv-maxrate 50000 --me umhEverybody should be encoding SD content (576p, 480p, or less) to Profile High @ Level 3.1 For smooth playback, "--level 3.1" should be used to mark the file as compatible when encoding. The best MeGUI profile for x264 is the DXVA-SD-HQ profile.
The MeGUI DXVA-SD-HQ profile options:
-level 3.1 --ref 8 --mixed-refs --bframes 3 --b-rdo --bime --weightb --direct auto --filter -1:-1 --trellis 2 --partitions p8x8,b8x8,i4x4,i8x8 --8x8dct --vbv-bufsize 14000 --vbv-maxrate 17500 --me umhThe Details
The associations responsible for the HD DVD and Blu-ray Disc standards approved the H.264 profile/level [email protected]
for HD content, and [email protected]
for SD content. As such, the Cyberlink decoder enforces compliance with the levels.
That has resulted in two implications:
1. H.264 video must comply with the L4.1 and L3.1 limitations for the Decoded Picture Buffer (DPB) size, which limits the video resolution and number of reference frames.
2. H.264 streams must declare L4.1 or L3.1 in the "level_idc" flag (set by --level with x264) in order to achieve smooth DXVA playback.The Settings
Keep in mind that, no matter the resolution, it is still generally recommended to only use between 1-5 reference frames, usually centering on 3.
A patch was added in x264 revision 721
that changes the way --ref works, allowing it to specify the total Decoded Picture Buffer (DPB) size. Now, B-frames can be used without the DPB size exceeding the --ref value.
The DPB size is the max at the given resolution, so if your resolution is between the resolutions given, use the lower DPB size (i.e., 1920x816 is between 1920x720 and 1920x864, so you can have a max DPB of 5).Resolution: Max DPB Size (x264 revision 721+ encoder settings)
1920x1088: 4 (--ref 4)
1920x864: 5 (--ref 5)
1920x720: 6 (--ref 6)
1280x720: 9 (--ref 9)
1280x648: 10 (--ref 10)
1280x588: 11 (--ref 11)
1280x540: 12 (--ref 12)
1280x498: 13 (--ref 13)
1280x462: 14 (--ref 14)
1280x432: 15 (--ref 15)
1280x405: 16 (--ref 16)
720x(any): 8 (--ref 8)
720x576: 11 (--ref 11)
720x480: 13 (--ref 13)Resolution: Max DPB Size (x264 revision < 721 encoder settings, bframes+b-pyramid count towards DPB size)
1920x1088: 4 (--ref 3 --bframes 3 --no-b-pyramid)
1920x864: 5 (--ref 4 --bframes 3 --no-b-pyramid)
1920x720: 6 (--ref 5 --bframes 3 --no-b-pyramid)
1280x720: 9 (--ref 8 --bframes 3 --no-b-pyramid)
1280x648: 10 (--ref 9 --bframes 3 --no-b-pyramid)
1280x588: 11 (--ref 10 --bframes 3 --no-b-pyramid)
1280x540: 12 (--ref 11 --bframes 3 --no-b-pyramid)
1280x498: 13 (--ref 12 --bframes 3 --no-b-pyramid)
1280x462: 14 (--ref 13 --bframes 3 --no-b-pyramid)
1280x432: 15 (--ref 14 --bframes 3 --no-b-pyramid)
1280x405: 16 (--ref 15 --bframes 3 --no-b-pyramid)
720x(any): 8 (--ref 10 --bframes 3 --no-b-pyramid)
720x576: 11 (--ref 10 --bframes 3 --no-b-pyramid)
720x480: 13 (--ref 12 --bframes 3 --no-b-pyramid)Retrofitting MKVs or other H.264 videos
Existing MKV, MP4, TS or AVI files that work with DXVA, but do not play back smoothly, can have their level_idc value changed, if the H.264 video stream actually complies
with Profile [email protected]
(HD) or L3.1 (SD).
Courtesy of DJBlu, you can use one of his IDC Changer utilities to automatically change the level_idc flag for MKV or AVI files. Note that they are intended for use on 720p files, because they only need the level_idc flag changed, while 1080p files usually exceed L4.1 specs. If you have an L4.1 1080p file, IDC Changer will work for it, too, but your decoder or hardware may choke (errors or video corruption) when you come across video that exceeds the L4.1 specs.
IDC Changer comes in three varieties:IDC Changer GUI v0.3
- GUI version for changing single filesIDC Multi-Changer GUI v0.1
- GUI version for changing multiple files at onceIDC Changer Command-Line v0.1
- CLI version for batch scripts, etc.
To manually change your files with much more work, continue on.
This process is for MKV files and has been adapted from a process originally described by DJBlu
Download the following programs:MKVtoolnixMKVExtractGUIH264info
Extract MKVtoolnix into a folder.
Extract MKVExtractGUI into the same
Extract H264info into another folder (can be the same folder).
Optional: Extract AVInaptic into another folder (can be the same folder).
Open your MKV with MKVExtractGUI. Check Options menu > Tabs > TimeCode. Check the boxes for all the video, audio, and subtitle tracks you want to keep and click Extract.
Once all are extracted, you will have separate files for your video, audio and subtitle tracks, plus TimeCode_TrackX.txt files for each track.
Set Input = Extracted .h264 file
Set Output = new_file_name.h264
In the "Level (1 - 5.1)" box, enter 4.1 for an HD stream, or 3.1 for an SD stream.
Click Start and wait for the stream to be fixed.
Open the MKVtoolnix mkvmerge GUI (mmg.exe).
Click add and select the new_file_name.h264 file created by H264info.
Click add and select a file for each audio and subtitle track you need to add.
In the Tracks box, click on the "MPEG-4 part 10 ES" video track.
At the far right of the Timecodes box at the bottom of the window, click Browse and select the TimeCode_TrackX.txt file for your video track (probably Track1).
Click the "Format specific options" tab.
In the FPS box, enter the frames per second of your original MKV file. If you don't know the framerate, you can use the AVInaptic tool to open the original MKV file to get all manner of information, including the FPS. If your video is FILM content, the likely choice is "24000/1001". If your video is progressive NTSC VIDEO, the likely choice is "60000/1001". If your video is interlaced NTSC VIDEO, the likely choice is "30000/1001". If your video is PAL VIDEO, the likely choice is "25".
Click on your audio track in the Tracks box.
Click on the "General track options" tab.
At the far right of the Timecodes box at the bottom of the window, click Browse and select the TimeCode_TrackX.txt file for your audio track (probably Track2). Do the same for any subsequent tracks.
Create an "Output filename" in the box at the far bottom of the window and click "Start muxing".
Wait for the new MKV to be remuxed and you should have an MKV file with smooth DXVA playback.