SD Encoding Guide (from DVD sources)
Use this guide to encode DVDs to H.264 for upload to the site. The guide is quite long because it covers many aspects of encoding. Read the sections that interest you. It's here to help guide first time encoders and as a reference for everyone. Not following certain aspects of this guide may result in your encode being nuked; rules which must be followed are listed in the first question in the Q & A section at the end of the guide and in the
rules page. Have fun encoding and don't forget our
Encoding Forum, the place to post your encoding questions.
What You NeedTools and minimum versions:
AviSynth 2.5.7DGMPGDec 1.5.3DVDShrink 3.2.0.15MeGUI 0.3.1.1006x264 build 1074
x264.nl techouse Note: x264 is updated regularly, you should do the same
mkvmerge 2.4SDB MeGUI profiles 3.0Follow installation instructions accompanying each software package. Additional installation notes:
Copy x264.exe into \Program Files\MeGUI\
Copy DGDecode.dll from \Program Files\DGMPGDec to \Program Files\AviSynth 2.5\plugins\
Extract sdb_profiles_3.0.zip into directory \Program Files\MeGUI\
Step 1: Source SelectionFor the majority of DVDs, select all VOB files apart from file 0 belonging to the largest titleset and drag them into DGIndex. Files can reside on harddisk if the DVD has already been ripped or if it was downloaded, or files can be located on a mounted physical DVD as long as AnyDVD is running. For example, in the image below (click for big version), titleset 2 (files beginning with VTS_02) is the largest:
Using the slider at the bottom of DGIndex's video window check for copyright warnings and trailers at the beginning and end. If encoding an episode of a TV series check there is only one episode. Skip to step 3 if both checks are successful.
Step 2: Extract Movie/EpisodeIf there are trailers or warnings present, or the title set contains more than one episode of a TV series then additional processing is required using DVDShrink. Either click 'Open Files' and select the folder containing the downloaded DVD files or click 'Open Disc' if you're working from a disc.
(a) Click 'Re-author'.
(b) Drag the feature to be encoded from (usually) the Main Movie section into the compilation window on the left.
(c) Click 'Compression Settings'
(d) Select 'No Compression'
(e) Click 'Backup!'
Click Yes to continue if a 'Target Exceeded' message is shown. The Backup DVD dialog is displayed. Select 'Hard Disk Folder' and click OK to extract the feature.
Go to step 1 using the newly created set of VOBs as the source.
Step 3: Index Video & Demux AudioThe video we want to encode is now loaded in DGIndex. Ensure your settings match those shown below:
Video iDCT Algorithm ==> IEEE-1180 Reference
Field Operation ==> Honor Pulldown Flags
YUV -> RGB ==> PC Scale
Audio Output Method ==> Demux All Tracks
Options Enable Info Log
From the File menu select 'Save Project'. Type in a name or accept the default and click Save. After a short time the process will be complete. A file with extension .d2v will have been created and one or more audio tracks will have been demuxed.
An information window will be displayed. Make note of the 'Frame Size' and 'Aspect Ratio' values, we will need them later. Some examples are shown below. This information will also be written into a log file when DGIndex is closed.
Step 4: Generate Encoding ScriptUsing your favourite editor create a base AviSynth script called encode.avs as follows:
MPEG2Source("VTS_01_1.d2v",cpu=0) # d2v file created from Step 3
Start MeGUI. Select 'AviSynth Script Creator' from the 'Tools' menu, then click the 'Video Input' browse button and select 'All files' from the 'Files of type' drop down menu:
Select encode.avs and press Open. A preview window will appear. Do not attempt to resize the picture. If the picture looks squashed the DVD is
anamorphic. The picture will be adjusted and displayed correctly during playback.
Important Note: At no point should the avisynth script be saved in MeGUI. Changes to encode.avs will be made manually in the following steps.
4.1 Deinterlace / IVTCFind a scene with motion using MeGUI's preview window and step though frame by frame looking for
interlacing (
example). DGIndex's 'Video Type' field in its information window (or log file) from Step 3 may be useful. MeGUI has an 'Analyze' function in the 'Filters' tab of the 'AviSynth Script Creator' dialog that occasionally produces a correct de-interlacing filter chain, although they are not the best to use and are frequently wrong. Below are a few common scenarios and recommended de-interlacing filters.
Important Note: The source video type must be identified correctly. Using a deinterlace filter on a source type it was not designed for will produce bad results. DGIndex will report 'Interlaced' for both interlaced and telecine material.
4.1.1 ProgressiveIf there are no interlaced frames then the source is progressive and no deinterlace filter is required. Skip down to 'Crop Black Borders'. Be sure to check several scenes, especially those containing computer generated imagery (CGI) or other kinds of special effects.
4.1.2 Hard or soft telecined Film (applicable to NTSC DVDs only, common for NTSC movies)Check for a repeating pattern of 3 progressive frames followed by 2 interlaced frames. This is called
telecine. Check several scenes for this pattern. Pay attention to any scenes that use special effects. If all scenes show the same repeating pattern then use inverse telecine to completely recover progressive frames:
TIVTC v1.0.5 [
doom9]
TFM().TDecimate()
4.1.3 Pure interlaceTemporarily add SeparateFields() to encode.avs and re-load into MeGUI. The video will be half the original height, these are called fields. One field will be all the horizontal odd lines from the original image, the second field will be all the even lines from the original image. Step through field by field. If every field is unique then the video is pure interlace. Remove the SeparateFields() filter and use one of the following filter chains. Filters are listed in decreasing order of quality:
McBob v0.3u using NNEDI [
doom9] | Superb. Not practical for many users because it is very slow.
MCBob(sharpness=1.0).SelectEven()
YADIFMod using NNEDI [
tritical's filters] | Very good. Little or no interlace artifacts remain (not good with horizontal scrolling credits)
YADIFMod(edeint=NNEDI())
TDeint using TMM & NNEDI [
tritical's filters] [
doom9] | Average to good depending on the source. (excellent with horizontal scrolling credits)
TDeint(edeint=NNEDI(),emask=TMM())
YADIF [
avisynth] [
doom9] | Reasonable. Can leave noticeable interlace artifacts.
Load_Stdcall_plugin("path\to\yadif.dll")
YADIF()
TDeint [
tritical's filters] | Average. Can leave noticeable interlace artifacts.
TDeint()
Emulate VirtualDub's PAL deinterlace filter | Poor for general use. Can produce 'ok' results on some sources.
DoubleWeave().SelectOdd()
4.1.4 Hybrid - telecine and progressive or interlace scenes in the same videoHybrid sources typically require VFR (variable frame rate) so that film sequences are inverse telecined and shown at 23.976 frames/sec, and non-film sequences (usually special effects) are shown at 29.970 frames/sec. Examples that require VFR are Stargate SG1, Star Trek TNG, Babylon 5 and many "Making Of" documentaries. Refer to
this guide to make a VFR encode.
If special effects sequences are very short (a few seconds) or if the only non-film sequences are scrolling credits then you may consider the effort required to make a VFR encode does not outweigh the downside of having a small number of blended frames, dropped frames or stutter. In these cases use one of the following filter chains:
Mostly Film (telecine) TFM(mode=5,slow=2,clip2=NNEDI()).TDecimate(hybrid=1)
Mostly Video (interlace) TFM(mode=5,slow=2,clip2=NNEDI()).TDecimate(hybrid=3)
4.1.5 Miscellaneous Anime, cartoons [
doom9]
AnimeIVTC()
Deal with residual combing (invented for Family Guy) [
doom9]
VInverse()
De-interlacer for masochists [
ivtc.org]
Yatta
Additional ReferencesThere are many online resources that discuss interlacing, here are a few to be familiar with:
Interlace Telecine DGIndex Field Operation Force Film, IVTC, and De-interlacingAdd an appropriate de-interlacing filter to encode.avs and reload it into MeGUI. Use the slider to scan through the preview window, check that all interlace artifacts are removed. Post in the
Encoding forum for help with specific sources.
4.2 Crop Black BordersUncheck 'Resize'. Check 'Crop'. Click 'Auto Crop':
Ensure the cropped width and height are mod 4, divisible by 4 with no remainder. Over crop as necessary to achieve mod 4. Use the slider to scan through the video, review cropping in the preview window. If further cropping is required, crop to the next mod 4 resolution.
In this example the:
Width has been auto cropped by 10+2=12 pixels making the width 720-12=708 pixels
Height has been auto cropped by 6+4=10 pixels making the height 576-10=566 pixels
To achieve mod 4 the:
Width needs no further cropping, 708/4=177 with no remainder
Height needs to be cropped by a further 2 pixels to make 564 pixels
Since cropping can only be performed on a multiple of 2 pixels in the colour space we're working with, the extra 2 pixels can be cropped from either the top or the bottom, we'll crop them from the bottom. Final crop settings are:
Left = 10 Top = 6 Right = 2 Bottom = 6
If cropping was required then add a crop filter to encode.avs :
MPEG2Source("VTS_01_1.d2v",cpu=0) # d2v file created from Step 3
YADIFMod(edeint=NNEDI())
Crop(10,6,-2,-6) # crop(left,top,-right,-bottom)
Important Note: If the number of pixels cropped from the top of the frame is not divisible by 4 then ensure de-interlacing filters appear before crop filters. Adding de-interlacing filters before crop is always best practice.
Step 5: Determine Sample Aspect Ratio (SAR)The Sample Aspect Ratio (SAR) determines how the image is displayed on playback. The following criteria determine the SAR to use when encoding:
Source type, NTSC or PAL
Frame type, Anamorphic Widescreen or Full Screen
Whether the DVD was mastered as "
ITU" or "non-ITU"
Use the method described below to determine the correct SDB Profile for MeGUI or --sar option for x264 command line encoding.
Save the following script as sar.avs : (thanks to ajpanton for this script)
| Цитата: |
avsfile = "encode.avs" # Encoding script format = 1 # 1=NTSC, 0=PAL wide = 1 # 1=Widescreen 16:9, 0=Full screen 4:3 ######################### ITU = (format==1?10:12)/11.0*(wide==1?4.0/3:1) SARs = """"12:11","16:11","10:11","40:33","16:15","64:45","8:9","32:27"""" ITUprof = "SDB "+(wide==1?"ANAMORPHIC ":"")+(format==1?"NTSC":"PAL") i=import(avsfile).converttorgb i ab = round(height*(sqrt(45.0/44)-1)) a = spline36resize(round(width*ITU),height) a = a.addborders(0,floor(ab/2.0),0,ceil(ab/2.0)) bb = width(a)-round(width*ITU/sqrt(45.0/44)) b = spline36resize(round(width*ITU/sqrt(45.0/44)),height+ab) b = b.addborders(floor(bb/2.0),0,ceil(bb/2.0),0) interleave(a,b) scriptclip("""subtitle("Playback Resolution: "+\ string(round(width(i)*ITU*pow(44.0/45,current_frame%2)))+"x"+string(height(i))+\ "\nMeGUI Profile: "+ITUprof+(current_frame%2==1?" NON-ITU":"")+\ "\nx264 --sar "+eval("select(2*format+wide+current_frame%2*4,"+SARs+")"),lsp=0)""") |
Edit the first three lines:
Set 'avsfile' to the name of your encoding script, typically encode.avs
Set 'format' to 1 if the DVD is NTSC, set to 0 for PAL
Set 'wide' to 1 if the DVD is anamorphic widescreen (16:9 reported in DGIndex), set to 0 for full screen (4:3 reported in DGIndex)
Load sar.avs into MeGUI. Using the preview window step through a frame at a time, frames will alternate between ITU and non-ITU sizing and will show the SDB profile and SAR for each at the top of the image. Choose which one you think looks correct. Ignore black borders introduced by this script (they won't be present in the encode), focus on aspect ratio. For example, the Universal 'Earth' logo should be as close as possible to circular.
Additional methods that can help determine if the source is ITU or non-ITU:
If the DVD was produced around 2006 or later it's most likely non-ITU
If 4 pixels or less were cropped in total from the width to remove black borders it's most likely non-ITU
Make a comparison between a high definition source and the upscaled DVD
Find other perfect circles to measure such as clocks, car wheels, any kind of ball, etc but careful of the camera angle, the picture may be skewed.
For reference, the following table shows the various SAR and SDB MeGUI profiles for each source type where 'Aspect' and 'FrameSize' are the values reported by DGIndex:
DVD Aspect FrameSize ITU SAR & SDB Profile Non-ITU SAR & SDB Profile PAL 4:3 720 x 576 12:11 SDB PAL 16:15 SDB PAL NON-ITU
PAL 16:9 720 x 576 16:11 SDB ANAMORPHIC PAL 64:45 SDB ANAMORPHIC PAL NON-ITU
NTSC 4:3 720 x 480 10:11 SDB NTSC 8:9 SDB NTSC NON-ITU
NTSC 16:9 720 x 480 40:33 SDB ANAMORPHIC NTSC 32:27 SDB ANAMORPHIC NTSC NON-ITU
Step 6: Level complianceIf you wish to encode to an H.264 compliance level then read on, otherwise skip to the next section. Level compliant encodes are not required at sdbits.
Calculate the number of reference frames as follows:
Round up width and height (purely for this calculation, not the encode) to the nearest mod 16 value
Reference frames = MaxDPB * 1024 / 1.5 / ( mod16_width * mod16_height )
Round down the result
Select MaxDPB, --vbv-maxrate and --vbv-bufsize options from the table below depending on which level you wish to encode to:
Level MaxDPB vbv-maxrate vbv-bufsize 3.0 3,037.5 10,000 10,000
3.1 6,750 14,000 14,000
3.2 7,680 20,000 20,000
4.0 12,288 20,000 25,000
4.1 12,288 50,000 62,500
4.2 13,056 50,000 62,500
5.0 41,400 135,000 135,000
5.1 69,120 240,000 240,000
MaxDPB = Maximum Decoded Picture Buffer size. Although the table shows maximum values for --vbv-bufsize, this typically should be set to a maximum of 14000, it depends on the device you're encoding for.
Example:
In the video used as an example in this guide the cropped resolution is 708x564. Rounding width and height up to mod 16 gives us 720x576.
Therefore, the number of reference frames for a
level 3.0 compliant encode is 3037.5 * 1024 / 1.5 / (720*576) = 5
level 3.1 compliant encode is 6750 * 1024 / 1.5 / (720*576) = 11
Settings for a 3.1 level encode of our example video: --level 3.1 --ref 11 --vbv-maxrate 14000 --vbv-bufsize 14000
Note: Mod 16 width and height are only used in the reference frame calculation, the actual encode is NOT required to be mod 16 for level compliance. However, some devices and graphics card acceleration may require mod 16 resolution. It is your choice if you wish to encode to a mod 16 resolution. If you do then there must NOT be any black borders in the encode, you may need to over crop to obtain mod 16.
Note: "--partitions all" can be used when making a level compliant encode. It is NOT required to omit p4x4 to be level compliant. However, some devices and graphics card acceleration may require this partition type to be omitted. It is your choice if you wish to leave out p4x4 partitions.
Step 7: EncodeMeGUI or command line based x264 can be used to perform encodes.
7.1 MeGUI Encoding 1. Select the browse button next to 'Avisynth Script' and select encode.avs
2. Select 'Tools->Bitrate Calculator'
3. Select the appropriate audio track(s) created by DGIndex
4. Set the required file size and click apply
5. Select 'MKV' from the 'File format' option menu
6. Select the appropriate SDB profile from the 'Video profile' option menu using the SDB profile found in the SAR section above
7. Click 'Enqueue'
8. Select the 'Queue' tab
9. Click Start. If prompted to create a 'Worker' say 'Yes'
To determine an appropriate file size make several encodes on a small section of the movie and compare screen shots from the same frame. Use the lowest bitrate possible while maintaining source transparency. To encode 5% of the movie for these comparison encodes add SelectRangeEvery(2400,120) to the end of encode.avs . Maximum file sizes allowed are listed in the
rules.
Additional MeGUI resources:
Wiki General Questions and Troubleshooting Development 7.2 Command Line EncodingHere's an example of x264 command line parameters for a crf encode of our cropped PAL example:
x264 --threads auto --thread-input --sar 12:11 --crf 20 --direct auto --deblock -3:-3 --ref 11
--subme 9 --me umh --merange 24 --partitions all --8x8dct --b-adapt 2 --bframes 6 --b-pyramid --mixed-refs
--weightb --trellis 2 --no-fast-pskip --progress --output encode.h264 encode.avs
Step 8: MuxUse mkvmerge, dsmux or their respective GUI's to merge the video produced by x264 and the audio track(s) extracted in Step 3 to create the final media file. Do not set the display aspect ratio, mkvmerge will set this correctly automatically when it examines SAR in the H.264 stream. The delay automatically placed into the filename of the demuxed audio track by DGIndex can be used as a starting point when syncing audio and video, it's not correct 100% of the time.
Command line example:
mkvmerge -o "The Matrix Revisited PAL DVD.mkv"
--engage keep_bitstream_ar_info
--title "The Matrix Revisited PAL DVD"
--language 0:eng -d 0 -A -S --track-name "0:The Matrix Revisited PAL DVD" encode.h264
--language 0:eng -a 0 -D -S --track-name "0:Main Feature" --sync 0:0 "VTS_01_1 T80 3_2ch 384Kbps DELAY 0ms.ac3"
--track-order 0:0,1:0
Add the command line option "--engage keep_bitstream_ar_info" for maximum compatibility. This option only needs to be specified once regardless of the number of audio and/or subtitle tracks. It keeps SAR information embedded within the H.264 stream intact, enabling (for example) correct aspect ratio on the Play Station 3. This option can be added to the command line using mkvmerge GUI by selecting 'Muxing -> Add command line options' and typing it in. Ensure the command line does not contain option '--display-dimensions' as follows: Select the 'V_MPEG4/ISO/AVC' track, click the 'Format specific options' tab, select 'Aspect ratio' and leave the field blank.
Q & AQ: Does this guide have to be followed exactly?
A: No, it is a guide. It's here to help, if you need it. Rules which must be followed are:
Width and height must be mod 4 (divisible by 4 with no remainder)
Must use correct SAR value
Must not have black borders (also see next question)
Must not use any resize filters
Must not use sharpening or de-noising filters unless staff have agreed with you
Q: What should one do if various sections of the DVD need different crop values?
A: This is common on Documentaries, which are often made up of archive material. Find a scene with the widest possible picture and crop the side at those values. Find a scene with the maximum possible height and crop the top and bottom at those values. Most people will understand, especially with documentaries, that the picture doesn't always fill the screen. Likewise, if you have a movie that shows a small black border (e.g., a few pixels) for a small amount of time (e.g., 5 minutes) then you can choose to leave that black border present, therefore you don't needlessly crop the majority of the movie. Cropping (or not cropping) narrow short-lived borders in these circumstances is done at the encoders discretion.
Q: Can I use a resize filter?
A: No.
Q: Should I use ColorMatrix() ?
A: No. DVD sources do not require this filter.
Q: I am getting error "Direct Show Error. Unable to render the file. You probably don't have the correct filters installed." when trying to load an avs script in MeGUI.
A: This is usually be caused by not having a YUV decompressor installed. If you have
ffdshow installed then enable YUV decompressing as follows:
Start -> ffdshow -> Video decoder configuration
Click the Decoder tab
Click Codecs at the top of the list on the left
In the right hand pane scroll down to 'Raw video' and select 'all supported'
Click OK
Alternatively, if you do not have and do not want to install ffdshow then download and install
Helix YUV Codecs.
Q: Is it ok to use DGDecode_MPEG2Source(index.d2v,cpu=0) instead of MPEG2Source(index.d2v,cpu=0). What are the differences?
A: If another dll was to expose a function called MPEG2Source then a call to that function would be ambiguous; using DGDecode_MPEG2Source ensures the function MPEG2Source() function from the dgdecode.dll is used. Feel free to use what you prefer. cpu=0 is recommended, it is the default value and therefore doesn't need to be specified.
Q: I get an error when trying to load my avs script saying there is no function named MPEG2Source or DGDecode_MPEG2Source, what is the cause?
A: Avisynth is unable to locate the MPEG2Source function, which is part of the DGIndex application. Follow the installation steps at the top of this guide.
Q: What should one do if various sections of the DVD need de-interlacing and others don't ?
A: Use a motion-adaptive de-interlacer such as: mcbob or yadifmod.
Q: How do I install AviSynth filters, such as those listed in the "Deinterlace / IVTC" section?
A: Filters are typically .avsi and/or .dll files provided in a zip or rar file. Installation of these filters is accomplished by extracting the .avsi/.dll files into:
\Program Files\AviSynth 2.5\plugins
Make sure they are not in a subdirectory of plugins , they must be located in the plugins directory. Alternatively, if you do not want your plugins directory cluttered with lots of filters then you can install (extract the zip/rar) into a location of your choice and use the LoadPlugin("/path/to/filter.dll") filter. See
plugins for further information.
Q: MeGUI shows a dialog saying the clip does not have mod16 dimensions, what should I do?
A: As long as the clip has mod4 dimensions the message can be safely ignored.
Q: I notice when encoding in MeGUI two --sar command line options, is this ok?
A: Yes, as long as a SAR from the encoding guide is used and appears in the second --sar option. The last --sar option on the command line overrides any preceding value.
Q: I am seeing "x264 [warning]: width or height not divisible by 16 (XXxYY), compression will suffer", what should I do?
A: As long as the clip has mod4 dimensions the message can be safely ignored. There's a tiny compression loss if mod16 isn't used, but nothing major. Mod4 and above is fine. Leaving any black borders is far worse for compression than non-mod16 cropping
Q: Tell me more about SAR and why it is needed
A: The SAR (aka Pixel Aspect Ratio, PAR) informs the player how to convert the encoded video for playback on a 1:1 PAR device such as a computer monitor or television connected to a computer. The conversion is required because DVDs were originally designed to be shown on analogue CRT displays where pixels are wider than their height (or shorter than their height for 4:3 NTSC DVDs). Encodes at sdbits do not allow a resize filter to do this conversion prior to encoding because doing so would give more pixels (but not more detail) to x264 to encode and thus would require a higher bitrate than necessary to keep the same quality.
Q: Should I specify SAR with a slash or colon, e.g., 12/11 or 12:11?
A: Either. Both formats work.
Q: Where did the SAR values come from?
A: H.264 specification Annex E. They are recommended and closest to the true SAR values (listed
here in section 3). In all cases the difference between the H.264 compliant SAR and the true ITU SAR introduces a small 0.3% aspect ratio error that is not noticeable. The difference between the H.264 SAR and the true non-ITU SAR is zero so there is no aspect ratio error.
Q: Are the SAR values correct?
A: Yes. For ITU compliant discs SAR values are derived from the
visible dimensions of PAL and NTSC at 704x576 and 704x480 respectively. Without cropping, they have a display aspect ratio of 4:3 or 16:9. Example: Full frame 4:3 PAL using ITU SAR 12:11 displays at 704*12/11x576 = 768x576 = 4:3. Likewise, a non-ITU compliant disc containing full frame 4:3 PAL displays at 720*16/15x576 = 768x576 = 4:3.
Q: I've uploaded or seen an encode using an ITU SAR when it should be non-ITU (or vice-versa), can it be corrected?
Q: I've uploaded or seen an encode which has the wrong SAR, can I change it to a new value?
A: Yes. There is no need to re-encode. Use the technique below to set a new SAR value. In this example the original file is called bad_sar.mkv, the new SAR we want to set is 40:33 and the corrected output file is good_sar.mkv.
Use mkvinfo to find the track number and fps (brief output shown below):
mkvinfo bad_sar.mkv
+ EBML head
+ Segment, size 10691570
|+ Segment tracks
| + A track
| +
Track number: 1 | +
Track type: video | + Default flag: 1
| + MinCache: 1
| + Codec ID: V_MPEG4/ISO/AVC
| + Codec decode all: 1
| + CodecPrivate, length 44
| + Default duration: 41.708ms (
23.976 fps for a video track)
| + Language: eng
| + Name: 24 s01e01 - 0000-0100 NTSC DVD
Note: If you don't like looking through all the output from mkvinfo to find this information then you can use "mkvmerge -i bad_sar.mkv" to find the track id and mediainfo to find the fps. Output from mkvmerge -i looks like this:
mkvmerge -i bad_sar.mkv
File 'bad_sar.mkv': container: Matroska
Track ID 1: video (V_MPEG4/ISO/AVC) Track ID 2: audio (A_AC3)
Track ID 3: subtitles (S_TEXT/UTF8)
Extract the H.264 track (The "1:" is the track number found above and a colon):
mkvextract tracks bad_sar.mkv 1:bad_sar.h264
Extracting track 1 with the CodecID 'V_MPEG4/ISO/AVC' to the file 'bad_sar.h264'.
Container format: AVC/h.264 elementary stream
Mux the extracted H.264 stream into a mp4 container using mp4box (or yamb if you like GUI's) using the correct fps we found above, and the SAR you want (specified with par=):
mp4box -add bad_sar.h264:fps=23.976:par=40:33 -new good_sar.mp4
AVC-H264 import - frame size 692 x 472 at 23.976 FPS
Import results: 1074 samples - Slices: 9 I 378 P 687 B - 0 SEI - 9 IDR
Stream uses B-slice references - max frame delay 2
Saving good_sar.mp4: 0.500 secs Interleaving
Drop the original file, bad_sar.mkv, into mkvmerge GUI.
Untick the video (V_MPEG4/ISO/AVC) stream.
Drop good_sar.mp4 into mkvmerge.
Ensure the new video track (avc1) is selected.
Add --engage keep_bitstream_ar_info via Muxing -> Add command line options.
Select an output file and click start muxing.
Example command line generated automatically by mkvmerge GUI:
mkvmerge -o good_sar.mkv
--language 2:eng --track-name "2:Main Feature AC3 2.0ch 192 kbps" --default-track 2:yes
--language 3:eng --default-track 3:yes -a 2 -s 3 -D bad_sar.mkv -d 1 -A -S good_sar.mp4
--track-order 0:2,0:3,1:1
--title "24 s01e01 - 0000-0100 NTSC DVD"
--engage keep_bitstream_ar_info
Q: I'm finding all my old DVDs have an ITU SAR and my new DVDs have a non-ITU SAR, is this correct?
A: Yes. A high proportion of recent DVDs (manufactured after around 2006) are non-ITU. As more people move away from analogue CRT displays (where overscan exists) to HDTV/LCD/Plasma (where overscan does not exist) it makes sense to fill the entire frame with image. The full 720 pixel width image has become available using recent digital filming and digital editing techniques. The age aspect is not part of the main guide because SAR can be usually be determined from the cropped source width alone.
Q: My encode using an ITU SAR has a different width when compared to the dvd, why?
A: The source and encode do not have the same width when
played using a
software player because the software player does not stretch (or shrink) the width correctly when playing ITU DVD discs, the image is displayed with a small aspect ratio error. In contrast, the image is displayed correctly when playing an encode. See
this doom9 article for more information, in particular read the penultimate paragraph of the first post. At sdbits we do not carry the aspect ratio error produced by software players on ITU disc sources forward into our encodes. By ensuring the SARs from the guide are used we guarantee the image from the encode displayed on the screen using a software player has the smallest aspect ratio error possible when compared to the ITU DVD source disc played on a standalone, which is how it should look.
Q: Should I use bitrate based 2 pass or 1 pass crf?
A: Either is fine.
Q: Should I make encodes level compliant?
A: Not unless you are encoding for a specific device (e.g., stand alone player) or for graphics card hardware acceleration.
Q: Where did the MaxDPB values come from in the level compliance section?
A: H.264 specification Annex A. MaxDPB is in KB so it is multiplied by 1024 to obtain bytes and divided by 1.5 to convert from bytes to pixels (1.5 bytes per pixel in YV12 format).
Q: Do the number of reference frames for level compliance depend on --b-pyramid and --bframes?
A: No. Use a build of x264 greater than 721.
Q: I use Linux, how do I do this encoding thing?
A:
http://sdbits.org/wiki/index.php?title=X264_encoding_in_Linux/*BSD (thanks to techouse)
Добавлено спустя 33 минуты 32 секунды:Огромная просьба не распространять это на открытых ресурсах в первоначальмом виде, тем более без указания авторства
(c) jase99 sdbits.org