VideoHelp Forum
+ Reply to Thread
Results 1 to 8 of 8
Thread
  1. Member hydra3333's Avatar
    Join Date
    Oct 2009
    Location
    Australia
    Search Comp PM
    Hello. I use variations of this commandline to convert TV captures, using x264 originally sourced from x264.nl before that site bit the dust.
    Code:
    "x264-x64.exe" --thread-input --frames "148541" --profile high --level 4.1 --preset slow --interlaced --tff --no-cabac --crf 18 --sar 16:11 --colormatrix bt470bg -o "Y:\HDTV\tv-movie-temp.MP4" "Y:\HDTV\tv-movie.mpg"
    The variations are mainly for "--preset xxx" and "--crf dd".

    I thought I'd try to compare using these two supposedly equivalent commandlines in Win7:

    Code:
    "x264-x64.exe" --thread-input --profile high --level 4.1 --preset slow --interlaced --tff --no-cabac --crf 18 --sar 16:11 --colormatrix bt470bg -o "Y:\HDTV\TV-MOVIE.x264.mp4" "Y:\HDTV\TV-MOVIE.mpg"
    Code:
    SET x264opts=cabac=0:interlaced=1:tff=1:colormatrix=bt470bg:sar=16/11
    "ffmpeg.exe" -i "Y:\HDTV\TV-MOVIE.mpg" -map 0:v -an -c:v libx264 -preset slow -crf 18 -profile:v high -level 4.1 -coder 0 -flags +ildct+ilme -x264opts %x264opts% -x264-params %x264opts% -y "Y:\HDTV\TV-MOVIE.ffmpeg.mp4"
    (x264opts and x264-params are repeated because some google results seemed to indicate sometimes one worked better than the other)
    (in this case neither seems to work for SAR, see the encode logs below)

    The results from both encodes seemed close enough, although certainly not identical likely due to a newer version of ffmpeg vs x264.

    So the questions remain
    - how to make ffmpeg accept a specified SAR ?
    - anything else to make them "closer" ?

    Suggestions welcomed.

    x264 log results:
    ffms [info]: 720x576i 64:45 @ 25/1 fps (vfr)
    x264 [warning]: interlace + weightp is not implemented
    x264 [info]: using SAR=16/11
    x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
    x264 [info]: profile High, level 4.1
    x264 [info]: frame I:56 Avg QP:14.00 size: 89713
    x264 [info]: frame P:3002 Avg QP:17.23 size: 26488
    x264 [info]: frame B:5492 Avg QP:22.44 size: 2793
    x264 [info]: consecutive B-frames: 2.9% 4.7% 89.2% 3.2%
    x264 [info]: mb I I16..4: 6.7% 73.8% 19.5%
    x264 [info]: mb P I16..4: 2.7% 13.5% 3.1% P16..4: 40.3% 17.2% 8.5% 0.0% 0.0% skip:14.7%
    x264 [info]: mb B I16..4: 0.2% 0.2% 0.0% B16..8: 47.0% 4.3% 0.4% direct: 2.8% skip:45.1% L0:19.5% L1:65.9% BI:14.6%
    x264 [info]: field mbs: intra: 5.6% inter:2.9% skip:1.8%
    x264 [info]: 8x8 transform intra:69.8% inter:74.6%
    x264 [info]: direct mvs spatial:99.9% temporal:0.1%
    x264 [info]: coded y,uvDC,uvAC intra: 78.7% 78.7% 41.5% inter: 16.7% 18.8% 5.0%
    x264 [info]: i16 v,h,dc,p: 46% 21% 13% 20%
    x264 [info]: i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 26% 16% 30% 4% 4% 5% 4% 6% 7%
    x264 [info]: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 29% 12% 8% 6% 9% 11% 9% 9% 8%
    x264 [info]: i8c dc,h,v,p: 38% 22% 33% 8%
    x264 [info]: ref P L0: 70.4% 20.0% 3.9% 3.0% 2.4% 0.1% 0.0% 0.0% 0.0% 0.0%
    x264 [info]: ref B L0: 75.0% 21.3% 2.7% 1.0% 0.0% 0.0% 0.0% 0.0%
    x264 [info]: ref B L1: 73.7% 25.6% 0.4% 0.2%
    x264 [info]: kb/s:2336.41
    encoded 8550 frames, 71.97 fps, 2336.43 kb/s
    ffmpeg log results:
    ffmpeg version N-59595-g4816d63 Copyright (c) 2000-2014 the FFmpeg developers
    built on Jan 5 2014 22:01:52 with gcc 4.8.2 (GCC)
    configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv -
    -enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrn
    b --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enabl
    e-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libxavs --
    enable-libxvid --enable-zlib
    libavutil 52. 62.100 / 52. 62.100
    libavcodec 55. 47.100 / 55. 47.100
    libavformat 55. 22.102 / 55. 22.102
    libavdevice 55. 5.102 / 55. 5.102
    libavfilter 4. 0.103 / 4. 0.103
    libswscale 2. 5.101 / 2. 5.101
    libswresample 0. 17.104 / 0. 17.104
    libpostproc 52. 3.100 / 52. 3.100
    Input #0, mpeg, from 'Y:\HDTV\TV-MOVIE.mpg':
    Duration: 00:05:41.98, start: 0.240000, bitrate: 1523 kb/s
    Stream #0:0[0x1e0]: Video: mpeg2video (Main), yuv420p(tv), 720x576 [SAR 64:45 DAR 16:9], max. 9608 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x1c0]: Audio: mp2, 48000 Hz, stereo, s16p, 192 kb/s
    [libx264 @ 04f0abe0] interlace + weightp is not implemented
    [libx264 @ 04f0abe0] using SAR=16/11
    [libx264 @ 04f0abe0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
    [libx264 @ 04f0abe0] profile High, level 4.1
    [libx264 @ 04f0abe0] 264 - core 140 r2377 1ca7bb9 - H.264/MPEG-4 AVC codec - Copyleft 2003-2013 - http://www.videolan.org/x264.html - options: cabac=0 ref=5 deblock=1:0:0
    analyse=0x3:0x113 me=umh subme=8 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 thre
    ads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=tff bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=2 b_bias=0 direct=3 weightb=1
    open_gop=0 weightp=0 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=50 rc=crf mbtree=1 crf=18.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=
    1:1.00
    Output #0, mp4, to 'Y:\HDTV\TV-MOVIE.ffmpeg.mp4':
    Metadata:
    encoder : Lavf55.22.102
    Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 720x576 [SAR 64:45 DAR 16:9], q=-1--1, 12800 tbn, 25 tbc
    Stream mapping:
    Stream #0:0 -> #0:0 (mpeg2video -> libx264)
    Press [q] to stop, [?] for help
    frame= 8550 fps= 68 q=-1.0 Lsize= 97662kB time=00:05:41.92 bitrate=2339.9kbits/s
    video:97552kB audio:0kB subtitle:0 global headers:0kB muxing overhead 0.113477%
    [libx264 @ 04f0abe0] frame I:56 Avg QP:13.93 size: 89723
    [libx264 @ 04f0abe0] frame P:3002 Avg QP:17.15 size: 26495
    [libx264 @ 04f0abe0] frame B:5492 Avg QP:22.42 size: 2791
    [libx264 @ 04f0abe0] consecutive B-frames: 2.9% 4.7% 89.2% 3.2%
    [libx264 @ 04f0abe0] mb I I16..4: 6.6% 73.9% 19.5%
    [libx264 @ 04f0abe0] mb P I16..4: 2.7% 13.5% 3.1% P16..4: 40.3% 17.2% 8.5% 0.0% 0.0% skip:14.7%
    [libx264 @ 04f0abe0] mb B I16..4: 0.1% 0.2% 0.0% B16..8: 47.0% 4.3% 0.4% direct: 2.8% skip:45.1% L0:19.5% L1:65.9% BI:14.6%
    [libx264 @ 04f0abe0] field mbs: intra: 5.6% inter:2.9% skip:1.8%
    [libx264 @ 04f0abe0] 8x8 transform intra:70.1% inter:74.6%
    [libx264 @ 04f0abe0] direct mvs spatial:99.9% temporal:0.1%
    [libx264 @ 04f0abe0] coded y,uvDC,uvAC intra: 78.9% 78.9% 41.6% inter: 16.7% 18.8% 5.0%
    [libx264 @ 04f0abe0] i16 v,h,dc,p: 46% 21% 13% 20%
    [libx264 @ 04f0abe0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 26% 16% 30% 4% 4% 5% 4% 6% 7%
    [libx264 @ 04f0abe0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 29% 12% 8% 6% 9% 11% 9% 9% 8%
    [libx264 @ 04f0abe0] i8c dc,h,v,p: 38% 22% 33% 8%
    [libx264 @ 04f0abe0] ref P L0: 70.5% 20.0% 3.9% 3.0% 2.4% 0.0% 0.0% 0.0% 0.0% 0.0%
    [libx264 @ 04f0abe0] ref B L0: 74.9% 21.4% 2.7% 1.0% 0.0% 0.0% 0.0% 0.0%
    [libx264 @ 04f0abe0] ref B L1: 73.8% 25.6% 0.4% 0.2%
    [libx264 @ 04f0abe0] kb/s:2336.66
    Quote Quote  
  2. sar switch seems broken in ffmpeg . Some variations might be -setsar , -sar_num, -sar_den , but none of them work

    A workaround is to use -aspect 16:9 , and ffmpeg will use non ITU ratios (64:45 for PAL 16:9 )
    Quote Quote  
  3. This appears to work (non ITU ratios work as well), and checked at the bitstream level

    Code:
    -x264opts sar=x/y
    Quote Quote  
  4. Member hydra3333's Avatar
    Join Date
    Oct 2009
    Location
    Australia
    Search Comp PM
    Thanks.
    @poisondeathray pls see ffmpeg log above where 16/11 is specified but SAR 64:45 is what the log says ("[SAR 64:45 DAR 16:9]")

    Also, I've been using these based on old posts elsewhere. Are they incorrect ? eg for PAL 720x576i - using 16:11 in a 16:9 frame ?

    Code:
    REM SAR = DAR / PAR
    REM for 16:9 720x576i   use --sar=16:11 (most 4:3 are in 16:9 shell frame nowadays, so use this)  
    REM for 16:9 1440x1080i use --sar=4:3  
    REM for 16:9 1920x1080i use --sar=1:1  
    REM
    REM http://developer.divx.com/docs/divx_plus_hd/Creation_with_x264/
    REM Interlaced resolution 	 Support SARs
    REM 1920x1080i50                  1:1   (16:9 frame)
    REM 1440x1080i50                  1:1   (4:3 frame),  4:3 (16:9 frame)
    REM 720x576i50              1:1, 16:11 (16:9 frame), 12:11 (4:3 frame)
    REM 704x576i50              1:1, 16:11 (16:9 frame), 12:11 (4:3 frame)
    REM 480x576i50              1:1, 24:11 (16:9 frame), 18:11 (4:3 frame)
    REM 352x576i50              1:1, 32:11 (16:9 frame), 24:11 (4:3 frame)
    REM 
    REM 1920x1080i60                  1:1   (16:9 frame)
    REM 1440x1080i60                  1:1   (4:3 frame),  4:3 (16:9 frame)
    REM 720x480i60              1:1, 40:33 (16:9 frame), 10:11 (4:3 frame)
    REM 704x480i60              1:1, 40:33 (16:9 frame), 10:11 (4:3 frame)
    REM 640x480i60                    1:1   (4:3 frame)
    REM 480x480i60              1:1, 20:11 (16:9 frame), 15:11 (4:3 frame)
    REM 352x480i60              1:1, 80:33 (16:9 frame), 20:11 (4:3 frame)
    REM
    Quote Quote  
  5. Short summary: There are ITU and non ITU aspect ratio guidelines. Roughly speaking, the non-ITU are based on the full frame 720 width (they work out mathematically). ITU are based on 702 width (rounded to 704px) even though the frame width can be 720

    The 1st set are ITU values, 2nd set are non ITU values

    NTSC 4:3 => sar 10:11 (or 8:9)
    NTSC 16:9 => sar 40:33 (or 32:27)
    PAL 4:3 => sar 12:11 (or 16:15)
    PAL 16:9 => sar 16:11 (or 64:45)

    Certain situations may require on or the other (e.g SD blu-ray specs use ITU). Some hardware use one or the other




    You're not looking at the correct part of the log file. Look at the libx264 section
    [libx264 @ 04f0abe0] using SAR=16/11

    ("[SAR 64:45 DAR 16:9]") is what the source is "read" as , libx264 using SAR=16/11 is what libx264 is encoding

    e.g Take ffmpeg or ffprobe and look at the output file

    ffmpeg -i "TV-MOVIE.ffmpeg.mp4"

    It will give you SAR 16:11 for the 1st stream. It will say another SAR value as well - I think that's what the original was . But if you check the elementary stream, the sar value is correct
    Last edited by poisondeathray; 21st Apr 2014 at 11:47.
    Quote Quote  
  6. Member hydra3333's Avatar
    Join Date
    Oct 2009
    Location
    Australia
    Search Comp PM
    Thanks. Beaut.
    Originally Posted by poisondeathray View Post
    Short summary: There are ITU and non ITU aspect ratio guidelines. Roughly speaking, the non-ITU are based on the full frame 720 width (they work out mathematically). ITU are based on 702 width (rounded to 704px) even though the frame width can be 720.

    The 1st set are ITU values, 2nd set are non ITU values
    NTSC 4:3 => sar 10:11 (or 8:9)
    NTSC 16:9 => sar 40:33 (or 32:27)
    PAL 4:3 => sar 12:11 (or 16:15)
    PAL 16:9 => sar 16:11 (or 64:45)
    Based on that I guess I should be changing to use 64:45 since that what my incoming PAL TV sources were reported as.
    At least I guess so, these are .mpg outputs from VideoRedo QuickStreamFix ing of recorded .ts files from the venerable TVSchedulerPro.
    I suppose I could run mediainfo or ffprobe over the .ts files and the .mpg files to see if that tells me whether VideoRedo has changed anything.

    Best Regards

    PS
    REM 1920x1080i50 1:1 (16:9 frame)
    REM 1440x1080i50 1:1 (4:3 frame), 4:3 (16:9 frame)
    I suppose for "hd" pal (in Aus that's 1440 ) i should use 4:3; i'll have to google a link.
    Last edited by hydra3333; 21st Apr 2014 at 11:59.
    Quote Quote  
  7. AR discussion is a massive headache, because there is no necessarily correct answer

    It's tough to say what they are, or are supposed to be, as someone might have made a mistake somewhere along the line. (e.g. broadcaster might have goofed up, original transfer might have been messed up, capture hardware might assume something when it's supposed to be something else, etc. etc...) . Eitherway, the AR difference isn't large. If you can find a scene perfect circular object shot straight on (maybe a car tire, circular wall clock...), you can determine what the AR "should" be

    ffmpeg/ffprobe might not read some mpeg2 files correctly (some have a sequence display extension). gspot should reveal more information . => but that doesn' t really matter, because what the file current "is" encoded at, isn't necessarily what it should be content wise

    I suppose for "hd" pal (in Aus that's 1440 ) i should use 4:3; i'll have to google a link.
    Yes, HD PAL or NTSC 1440x1080 DAR 16:9 uses --sar 4:3 . That's uniform for both, and their is no ITU/non ITU confusion (The confusion is only for SD with the conflicting standards) . All the other standard HD resolutions use --sar 1:1 (1280x720, 1920x1080)

    Most broadcast , NLE's tend to use ITU interpretation rules
    Last edited by poisondeathray; 21st Apr 2014 at 12:12.
    Quote Quote  
  8. Member hydra3333's Avatar
    Join Date
    Oct 2009
    Location
    Australia
    Search Comp PM
    OK, so the equivalent commandlines I ended up with for PAL broadcast SD 576i :-
    Code:
    "C:\software\X264\x264-x64.exe" --thread-input --log-level info --profile high --level 4.1 --preset slow --interlaced --tff --no-cabac --crf 18 --sar 64:45 --colormatrix bt470bg -o "Y:\HDTV\TV-MOVIE.x264.mp4" "Y:\HDTV\TV-MOVIE.mpg" 
    
    SET x264opts=cabac=0:interlaced=1:tff=1:colormatrix=bt470bg:sar=64/45:threads=auto
    "C:\SOFTWARE\ffmpeg\0-latest\bin\ffmpeg.exe" -i "Y:\HDTV\TV-MOVIE.mpg" -threads 0 -map 0:v -an -c:v libx264 -preset slow -crf 18 -profile:v high -level 4.1 -coder 0 -flags +ildct+ilme -x264opts %x264opts% -x264-params %x264opts% -y "Y:\HDTV\TV-MOVIE.ffmpeg.mp4"
    (x264opts and x264-params are repeated because googled posts indicated that sometimes some options one worked with one and not the other ... so I put them in both)
    Quote Quote  
Visit our sponsor! Try DVDFab and backup Blu-rays!