VideoHelp Forum




+ Reply to Thread
Results 1 to 6 of 6
  1. Banned
    Join Date
    Nov 2005
    Location
    United States
    Search Comp PM
    ok, this might sound like a silly question, but bear with me:

    as some of you may know, i have a few (quadzillion) high def mkv files, that have "odd" resolutions, such as 1920x800 (2.40) or 1920x816 (2.35), encoded using x264 with ac3 audio that i'm in the process of transcoding to mpeg-2 with ac3.

    in order to reduce the size (i'm actually running out of hdd space and i currently have over 2tb of space) i am lowering the resolution so that i can use less bitrate and maintain excellent quality (i max out the settings in tmpgenc) and by encoding to mpeg-2 less time will be required to transcode each file (because encoding h264 at hi def resolutions with a phenom 9500 takes way more patience than i have).

    so i started creating a batch file and i was originally going to go down to 1280x544 or 1280x533 in order to maintain the movies aspect ratio, but wanted a bit higher quality.

    after some thought, i came up with the following plan: transcode all the movies to 1368x768 with 4:3 pixels. why?

    because while 1368x768 with square pixels has an aspect ratio of 1.78, with 4:3 pixels, by my calculations, the aspect ratio becomes 2.375 ((1368x4)/768x3)) and from what i can tell no movie really has an aspect ratio of 2.35 or 2.4, the actual value is somewhere around 2.37.

    to my thinking the above makes sense and it would really simplify setting up a batch job and letting the encodes go, i just want to make sure that i'm not missing something before i commit.

    lastly, is 1368x768 4:3 a "legal" blu-ray compliant resolution, i know that 1440x1080 with 4:3 pixels is a legit blu-ray resolution, and i know many tv's have native resolutions of 1368x768, so i'm thinking maybe it's a "legal" resolution.

    thanks...
    Quote Quote  
  2. Illegal.

    If you click on "What is Blu-ray" in the top left corner:

    High Definition Video
    1920x1080x59.94i, 50i (16:9)
    1920x1080x24p, 23.976p (16:9)
    1440x1080x59.94i, 50i (16:9) AVC / VC-1 only
    1440x1080x24p, 23.976p (16:9) AVC / VC-1 only
    1280x720x59.94p, 50p (16:9)
    1280x720x24p, 23.976p (16:9)
    Standard Definition Video
    720x480x59.94i (4:3/16:9)
    720x576x50i (4:3/16:9)

    One option would be to do the normal frame dimension 1280x720 and add the borders back to keep the aspect ratio, since you are re-encoding anyways. This is how you would do it to make it legal and playable on blu-ray standalone units & PS3 etc...

    If you are not authoring a blu-ray disk for BD5, BD9, BD25 or BD50, then you don't need to keep it "legal dimensions". That is only for compliance, you wouldn't need to do that if this was for HTPC , for example.

    I'd strongly advise against using MPEG2, at the 720p size you often use ~5-10Mbps video bitrate range, and the differences are much more apparent than when using bitrates in BD50 range. We're talking ~30-50% difference in size for the same quality at that range when using h264 vs. MPEG2
    Quote Quote  
  3. Banned
    Join Date
    Nov 2005
    Location
    United States
    Search Comp PM
    bummer...and thanks...it looks like i have some more planning to do.
    Quote Quote  
  4. Member
    Join Date
    Dec 2008
    Location
    Ca, United States
    Search Comp PM
    Can somebody help me with avisynth?

    I have this script:

    LoadPlugin("Autocrop.dll")
    Input_Clip = Directshowsource("File", fps=23.976, convertfps=true).convertfps(23.976).autocrop(mode= 0)
    i_width = Input_Clip.Width
    i_height = Input_Clip.Height
    d_a_r = float(i_width) / float(i_height)
    p_o_height = (d_a_r < 1.7647058823529411764705882352941) ? 272 : 480/float(d_a_r)
    p_o_width = (d_a_r < 1.7647058823529411764705882352941) ? 272*d_a_R : 480
    p2_o_width = Round(p_o_width/4)*4
    p2_o_height = Round(p_o_height/4)*4
    o_width = Round(float(p2_o_width))
    o_height = Round(float(p2_o_height))
    Output = Input_Clip.LanczosResize(o_width,o_height).convert toyv12()
    Return Output



    The purpose of this script is to automatically resize any direct show movie to 480x??? for movies with an aspect ratio of 16:9+ and ???x272 for movies with an aspect ratio of < 16:9

    It works perfectly on files which do not have DAR, SAR or PAR. Does anyone know of a way to retrieve DAR, SAR, etc. from an input video file? Is there an avisynt plugin or something? This problem is driving me crazy!!! I recently released a video converter KG6ZVP's PSP Converter which impliments this script. Unfortunately, it doesn't work properly when given a 720x480 wmv file with a DAR of 4:3 or 16:9.

    REALLY NEED HELP!!!
    Quote Quote  
  5. Originally Posted by ZedVamp
    It works perfectly on files which do not have DAR, SAR or PAR. Does anyone know of a way to retrieve DAR, SAR, etc. from an input video file?
    Mediainfo will show some information like DAR, you can elicidate the SAR from frame dimensions. You might be able to incorporate this into your application.

    Avinaptic will work on some files, it uses slightly different terminology but the math is the same, DAR, FAR (frame aspect ratio), and PAR (pixel aspect ratio) which is the function equivalent to the SAR (sample aspect ratio)
    Quote Quote  
  6. Member
    Join Date
    Dec 2008
    Location
    Ca, United States
    Search Comp PM
    Thanks for the tip about MediaInfo. I just put it into version 1.05 of my converter. Problem solved! (by the way, it also solved a problem I didn't know I had with VFR input video.)

    I was wondering if you could help me with a couple of problems:
    1.) I need a way to set DAR in either mp4box or x264.exe (Unfortunately, it MUST BE DAR, SAR and PAR are not accepted by the PSP)

    2.) I have a batch file which generates the AVIsynth script with the DAR and Framerate retrieved with MediaInfo, however, I cannot seem to get MS DOS's "set /a" command to do the calculation. Could someone give me a hand? The batch script is included below along with the contents of "AVS_ALL_SMALL.txt":


    Batch File
    :%1 is Input
    :%2 is AppPath\Cores
    :%3 is Output

    cd "%~dp0"



    :AVSGen
    MediaInfo.exe --Inform=Video;file://Info.txt "%~1">> "DAR_file.txt"
    set /p DAR=<DAR_file.txt

    MediaInfo.exe --Inform=Video;file://fps.txt "%~1">> "FPS_file.txt"
    set /p iFPS=<FPS_file.txt



    echo LoadPlugin("FFmpegSource.dll")>> "%~2\X264\Adaptive.avs"
    echo LoadPlugin("Autocrop.dll")>> "%~2\X264\Adaptive.avs"
    echo Input_Clip = FFmpegSource("%~1", vtrack=-1, atrack=-1)>> "%~2\X264\Adaptive.avs"
    echo DAR = %DAR%>> "%~2\X264\Adaptive.avs"
    echo if_width = Input_Clip.Width>> "%~2\X264\Adaptive.avs"
    echo hf = float(if_width) / DAR>> "%~2\X264\Adaptive.avs"
    echo if_height = round(hf)>> "%~2\X264\Adaptive.avs"
    echo Input_ClipS = Input_Clip.autocrop(mode=0).LanczosResize(if_width ,if_height).Autocrop(mode=0)>> "%~2\X264\Adaptive.avs"
    echo i_width = Input_ClipS.Width>> "%~2\X264\Adaptive.avs"
    echo i_height = Input_ClipS.Height>> "%~2\X264\Adaptive.avs"
    echo D_A_R = float(i_width) / float(i_height)>> "%~2\X264\Adaptive.avs"



    cd X264
    Type AVS_All_Small.txt>> Adaptive.avs


    cd ..
    :BitCalc
    MediaInfo.exe --Inform=Video;file://iW.txt "%~1">> "iW_file.txt"
    set /p iWIDTH=<iW_file.txt


    :b240
    If /I %iFPS% GTR 30 (
    set iFPS=29.970
    ) ELSE (
    GOTO b240sec
    )

    :b240sec
    set /a Bitrate=((((240*%DAR%)*240)/76800)*(%iFPS%/30.000))*256
    GOTO X264_passo

    :320b
    set /a Bitrate=((((320/%DAR%)*320)/76800)*(%iFPS%/30.000))*256
    GOTO X264_passo

    :X264_passo
    cd X264
    x264.exe --pass 1 --bitrate %bitrate% --stats "%~2\X264\Adaptive.stats" --level 3 --bframes 3 --b-adapt 2 --weightb --direct auto --subme 2 --partitions none --vbv-bufsize 10000 --vbv-maxrate 10000 --me dia --threads auto --thread-input --sar 1:1 --progress --no-psnr --no-ssim --output NUL "%~2\X264\Adaptive.avs"



    :X264_pass2
    x264.exe --pass 2 --bitrate %bitrate% --stats "%~2\X264\Adaptive.stats" --level 3 --ref 3 --mixed-refs --bframes 3 --b-adapt 2 --weightb --direct auto --subme 7 --trellis 1 --partitions p8x8,b8x8,i4x4 --vbv-bufsize 10000 --vbv-maxrate 10000 --me umh --threads auto --thread-input --sar 1:1 --progress --no-psnr --no-ssim --output "%~2\X264\Adaptive_vd.mp4" "%~2\X264\Adaptive.avs"



    cd ..



    :AACGen
    ffmpeg.exe -y -i "%~2\X264\Adaptive.avs" -vn -acodec libfaac -aq 100 -vol 400 -f mp4 "%~2\X264\Adaptive_au.mp4"
    mp4box.exe -add "%~2\X264\Adaptive_vd.mp4" -add "%~2\X264\Adaptive_au.mp4" -new "%~2.mp4"

    cd x264

    elTempFiles
    del "Adaptive_au.mp4"
    del "Adaptive_vd.mp4"
    del "Adaptive.stats"
    del "Adaptive.avs"

    cd ..
    del "DAR_file.txt"
    del "iw_file.txt"
    del "Factor.txt"
    del "FPS_file.txt"

    :ThumbGen
    old_ffmpeg.exe -y -i "%~1" -f image2 -ss 5 -vframes 1 -fixaspect -s 160x120 -an "%~2.THM"


    AVS_ALL_SMALL.txt
    p_o_height = (d_a_r < 1.3333333333333333333333333333333) ? 240 : 320/float(D_A_R)
    p_o_width = (d_a_r < 1.3333333333333333333333333333333) ? 240*d_a_R : 320
    p2_o_width = Round(p_o_width/4)*4
    p2_o_height = Round(p_o_height/4)*4
    o_width = Round(float(p2_o_width))
    o_height = Round(float(p2_o_height))
    first = Input_Clip.Framerate*1000
    second = Round(Float(first))
    FPS_oi = int(second)
    FPS = (FPS_oi > 30000) ? 29970 : FPS_oi
    Output = Input_Clip.changefps(int(FPS), 1000).LanczosResize(o_width,o_height).converttoyv1 2()
    Return Output
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!