VideoHelp Forum

Our website is made possible by displaying online advertisements to our visitors. Consider supporting us by disable your adblocker or try DVDFab and copy, convert or make Blu-rays and DVDs! :)
+ Reply to Thread
Results 1 to 16 of 16
Thread
  1. Greeting Folks,

    I'm having trouble to obtain correct DAR when encoding my old NTSC full frame 4:3 DVD into x264. DVD has letterboxing so I want to remove letterboxing and keep original aspect ratio 4:3 to watch on PC as well on TV through USB drive. I tried anamorphic (overcrop to achive selected mode) option in Megui to avoid any resizing but then I get very weired aspect ratio 5:3. When I crop video I get 718x386 resolution and then get 5:3 DAR after encoding in Megui by using anamorphic option. So I please suggest me what should I do in order to achieve correct aspect ratio. So basically I have three question:

    1- Do I have to add letterboxing to get correct DAR ? If yes, then please suggest me least letterboxing pixels I need to add.
    2- My video is telecine interlace so what method should I use to deinterlace it ? For test purpose I used below Avisynth script to deinterlace it and result seems good.
    Code:
    AssumeTFF()
    TFM(d2v="Sample2.d2v", clip2=QTGMC(Preset="Medium").SelectEven()).TDecimate()
    But let me know if there is any other method would be more feasible?
    3- I am also confused in correct PAR. AvsPmod shows 8:9 when I computed it through d2v file so I used 8:9 in x264 settings, is that correct sar ?

    I've attached few secs clip cut from DVD, so please advise me how to get maximum quality, I want to keep as much as details I can.
    Image Attached Files
    Quote Quote  
  2. I've just looked at your sample. It's stored at a resolution of 720 * 480 px (3:2).

    When it plays, then it's shown (correctly) in 4:3, i.e. at 720 * 540 px. So, if you want to have the result in 4:3 you should leave the blackbars as they are.

    Suggestion for encoding:
    Code:
    ffmpeg -i Sample2.demuxed.m2v -r 30000/1001 -aspect 4:3 -vf yadif,scale=720:540 -c:v libx264 -preset fast -crf 18 -an -y sample_264_4-3.mp4
    If you want to remove the blackbars, then you will get an aspect of 5:3 at 720 * 432 px.

    Suggestion for encoding:
    Code:
    ffmpeg -i Sample2.demuxed.m2v -r 30000/1001 -aspect 5:3 -vf yadif,scale=720:540,crop=720:432:0:54 -c:v libx264 -preset fast -crf 18 -an -y sample_264_5-3.mp4
    For deinterlacing I've simply used yadif. I'm sure one can suggest a more sophisticated approach.

    I'll attach the results.
    Image Attached Files
    Quote Quote  
  3. Thank you fornit for replying me. I have few questions. I am not an expert so I am not able to understand this.

    I've just looked at your sample. It's stored at a resolution of 720 * 480 px (3:2).
    How do you know its stored in 3:2 ? Mediainfo shows 4:3.

    If you want to remove the blackbars, then you will get an aspect of 5:3
    How did you figure out 5:3 DAR?

    I hate letterboxing so i decided to keep DAR 5:3 if I have to but no letterboxing.

    I also see you didn't pass any -sar paramater? isn't that important to play on TV?
    Last edited by sameerkool25; 9th Jul 2018 at 07:30.
    Quote Quote  
  4. Storage aspect ratio simply follows from the number of pixels. If you look at your sample with the help of MediaInfo, you'll notice a width of 720 and a height of 480 px:
    720/480=1,5=3:2

    The display aspect ratio is 4:3 here. This tells the player to stretch height from 480 to 540 px to display the video correctly. Because 720/540=1,333333=4:3. This means: Pixels are not square.

    The DAR of 5:3 is the result of a little math: Video is displayed at 720 * 540 px. Blackbars have a height of 54 px, so there are 720 * 432 px remaining for the video. 720/432=1,666667=5/3.

    The result of the conversion is a video with square pixels. In that case DAR = SAR. Usually that makes things much easier for video players.

    But please try the samples on your TV. 5:3 is a format which is not that usual. If that doesn't work maybe some additional switches can help.
    Quote Quote  
  5. The display aspect ratio is 4:3 here. This tells the player to stretch height from 480 to 540 px to display the video correctly. Because 720/540=1,333333=4:3. This means: Pixels are not square.
    I think I am getting it now. But I thought for full frame we adjust width and keep height steady ? so isn't it should be 638/480=1.33 ?
    Quote Quote  
  6. Usually pixels are stretched in horizontal direction, but interestingly it's vertical here.

    638 * 480 px (or better 640 * 480 px) would lead to a correct display aspect ratio, too, but then pixel information would get lost, that is physically available.

    Please try your sample with VLC player. You'll notice that it plays it at 720 * 540 px.
    Quote Quote  
  7. Ok I saw that height is stretched to 540px in VLC. I had to take a snapshot of sample to check stretched height.

    One more thing.
    The DAR of 5:3 is the result of a little math: Video is displayed at 720 * 540 px. Blackbars have a height of 54 px
    How did you figure out 54px blackbars height to calculate 5:3 aspect ?

    Please bear me with questions as this is very confusing with these shitty old dvds. I never had any problem with BluRays.
    Quote Quote  
  8. Originally Posted by sameerkool25 View Post
    How did you figure out 54px blackbars height to calculate 5:3 aspect ?
    The principle hasn't been much different from your approach. I've taken a snapshot of a frame with bright colours so that top and bottom of the video could be clearly identified.

    I've then tried some transparent rectangles with a fixed aspect as video overlays and I've found that 5:3 seems to fit quite good. The rest has been a bit of math again ...

    If you want something like a "pixel perfect fit" for this specific video, then you can invest more work:
    • For analysis (only) encode it with the storage aspect ratio as display aspect ratio (i.e.: set aspect to 3:2 instead of 4:3)
    • I've just done that, encoding string will then be
      Code:
      ffmpeg -i Sample2.demuxed.m2v -r 30000/1001 -aspect 3:2 -vf yadif -c:v libx264 -preset fast -crf 18 -an -y sample_264_3-2.mp4
    • The video will then look a bit stretched when you view it with VLC because it's a wider aspect than intended. -> see attachment
    • Then take a snpashot with bright colours and look at the number of pixels of blackbars, black pixels at the left and at the right.
    • Then change the encoding string so that the cropping is done before the scaling. To get your sample "pixel exact" I've found: Blackbars of 47 px at the top and at the bottom, no black pixels at the left, 2 black pixels at the right (i.e.: a width of 718 px instead of 720).
    • This leads to a crop statement as follows: -vf crop=718:386:0:47. (Note: 386 + 2 * 47 = 480 px)
    • Then scale it up to 5:3, i.e.: to 720 * 432 px. Because that's obviously the aspect intended by the producers of the video. The final encoding string will then result to:
      Code:
      ffmpeg -i Sample2.demuxed.m2v -r 30000/1001 -aspect 5:3 -vf yadif,crop=718:386:0:47,scale=720:432 -c:v libx264 -preset fast -crf 18 -an -y sample_264_5-3v2.mp4
      -> see attachment

    But if you want to convert many videos and blackbars and/or pixels at the left and at the right differ a bit from video to video then I'd suggest not to invest that work for each video and to use the statement above shown in my first post.
    Image Attached Files
    Last edited by fornit; 9th Jul 2018 at 20:02.
    Quote Quote  
  9. Your source is 720x480 4:3 DAR which means it's 8:9 SAR. Crop whatever you like and encode 8:9 SAR and you will get the right DAR.

    If you prefer square pixel encoding, resize to any 4:3 frame size, then crop whatever you like. The remaining image will have the correct DAR.
    Quote Quote  
  10. Originally Posted by jagabo View Post
    Your source is 720x480 4:3 DAR which means it's 8:9 SAR. Crop whatever you like and encode 8:9 SAR and you will get the right DAR.
    I've written above "The result of the conversion is a video with square pixels. In that case DAR = SAR. Usually that makes things much easier for video players."
    In "ancient times" video encoding has required techniques which have made encoding more complex. If you suggest a SAR of 8:9 this would mean not to have DAR=SAR=1:1. Why do you want to keep that complexity of old days?

    Originally Posted by jagabo View Post
    If you prefer square pixel encoding, resize to any 4:3 frame size, then crop whatever you like. The remaining image will have the correct DAR.
    That's exactly what I have proposed. Sorry, but I don't understand why you emphasize that.
    Last edited by fornit; 9th Jul 2018 at 21:00. Reason: typo
    Quote Quote  
  11. Originally Posted by sameerkool25 View Post
    AvsPmod shows 8:9 when I computed it through d2v file so I used 8:9 in x264 settings, is that correct sar ?
    Yes, 8:9. No matter how you crop it, the SAR is always 8:9.
    But let me know if there is any other method would be more feasible?
    No, your IVTC is good.


    Originally Posted by fornit View Post
    Why do you want to keep that complexity of old days?
    I think the argument can be made that by encoding with the 8:9 SAR the resulting quality will be better because no resizing is done during the encode. And there's nothing obsolete about using a SAR to get the correct aspect ratio, rather than doing a resize into square pixels.

    I don't believe jagabo was contradicting you, but just proposing an alternative (and perhaps better) method. In addition, my own opinion is that you made the whole explanation unnecessarily difficult to understand and it's little wonder sameerkool25 asked followup questions.
    Quote Quote  
  12. Member Cornucopia's Avatar
    Join Date
    Oct 2001
    Location
    Deep in the Heart of Texas
    Search PM
    I agree with manono & jagabo. Every lossy generation added loses quality. But so do interpolative/extrapolative resizes, even when using lossless encoding.
    Look at it this way: in the original rip, what percentage of pixels are the original, ground truth pixels (as decoded)? - 100%.
    In a non-resized lossy re-encode, barring a few percent that change due to dct re-blocking and possible color subsampling adjustments, they are the same pixels. So, close to 100%.
    In a 2:1 resize, your original pixels now amount to only 50% of the total. And that's one of the special cases - it would normally likely include an even higher percentage of guessed-at, newly synthesized pixels.
    Why would that be considered truer to the original, just because it's easier math for your visual understanding?

    Scott
    Quote Quote  
  13. Your source is 720x480 4:3 DAR which means it's 8:9 SAR. Crop whatever you like and encode 8:9 SAR and you will get the right DAR.
    I cropped and added 8:9 sar in Megui and encoded. Mediainfo shows DAR 16:10

    If you prefer square pixel encoding, resize to any 4:3 frame size, then crop whatever you like. The remaining image will have the correct DAR.
    Resized source to to 4:3 frame (720x540) and then cropped to remove letterboxing then encoded with sar 1:1 in Megui. Mediainfo shows DAR 5:3 (is it correct way to resize first and then crop? I thought its other way.)
    Quote Quote  
  14. Starting with the 720x480 frame:

    Cropping 44 lines off the top, 48 lines off the bottom leaves 720x388:

    Code:
    DAR = FAR * SAR
    DAR = 720:388 * 8:9
    DAR = (720/388) * (8/9)
    DAR = 1.649
    Resizing to 640x480 first, cropping 44 lines off the top, 48 lines off the bottom leaves 640x388:

    Code:
    DAR = FAR * SAR
    DAR = 640:388 * 1:1
    DAR = (640/388) * (1/1)
    DAR = 1.649
    Quote Quote  
  15. Originally Posted by manono View Post
    Originally Posted by fornit View Post
    Why do you want to keep that complexity of old days?
    I think the argument can be made that by encoding with the 8:9 SAR the resulting quality will be better because no resizing is done during the encode. And there's nothing obsolete about using a SAR to get the correct aspect ratio, rather than doing a resize into square pixels.
    I'm not sure whether really nothing is obsolete keeping it anamorphic. I've just tested an anamorphical x264 encode on the mobile devices, I've lying around here in my office.

    On the iPad it plays fine.

    On my older Samsung S5 (Android 6.0.1) it is squeezed when opened with the standard player.
    Click image for larger version

Name:	Screenshot_2018-07-12-02-12-54.png
Views:	11
Size:	1.34 MB
ID:	46049

    On my newer Android device (7.1.1) it starts squeezed for a second but is then corrected to the right dimensions. But if a pause the video, switch to another application and back, then it's squeezed, too. And I must restart it to get the correct dimensions again.

    I've then tried to "beam" it to my TV with Google Chromecast. Again it appeared squeezed.


    This is far away from a broad research. And of course there is a lot of video players that can be installed on mobile devices. But isn't it fine if things work out of the box?
    Quote Quote  
  16. Yes, not all devices display anamorphic encodes properly. On the other hand, resizing always has the possibility of creating artifacts.
    Quote Quote  



Similar Threads