VideoHelp Forum




+ Reply to Thread
Results 1 to 27 of 27
  1. Hi guys, hopefully, this is the right forum for this question!

    I use the program PS3 Media Server to stream my mkvs across to my TV. In said program, there's a few transcoding enguines you can use: MEncoder and AVISynth/MEncoder. I normally choose AVISynth/MEncoder over MEncoder due to my having had a few issues with the MEncoder engine. Most of my mkvs play without a hitch, however, the occasional one will have black bars to the sides. The problem is, these videos are 16:9 ratio, they're not suppose to have black bars! This results in the video looking all squashed and ugly. The interesting thing is, when I play these videos using MEncoder as the engine, the aspect is correct. This makes me think AVISynth is the culprit here.

    When I load up these troublemaker mkvs in MediaInfo, I notice something odd: these videos have extra aspect ratio information! An example would be:
    Width : 704 pixels
    Height :
    480 pixels
    Display aspect ratio : 16:9
    Original display aspect ratio :
    1.467

    The 16:9 mkvs that play properly when using AVISynth/MEncoder only make mention of one aspect ratio. This makes me think AVISynth is looking at "Original display aspect ratio" to get it's aspect ratio, while MEncoder is looking at "Display aspect ratio". This would explain why MEncoder gets it right, while AVISynth/MEncoder gets it wrong. Interestingly enough, the same mkvs that AVISynth has issues with, also show up as 4:3 thumbnails in Windows, instead of 16:9 like the non-troublesome ones. Obviously, Windows is being tripped-up in the same way AVISynth is.

    Ideally, I would like the change the way AVISynth gets it's aspect ratio. In the troublesome mkvs, the "Display aspect ratio" field is normally correct, so if AVISynth would use this information instead, the problem would be solved. But failing that, how would I remove the extra, incorrect aspect ratio? I've tried using MKVtoolnix, both the "aspect ratio" option, as well as entering in the correct display width/height (which should be 704x480, but came up as 853x480 when I loaded up the video in MKVToolnix), both these options don't solve the problem.

    Little help?
    Quote Quote  
  2. I'm a MEGA Super Moderator Baldrick's Avatar
    Join Date
    Aug 2000
    Location
    Sweden
    Search Comp PM
    I don't think it's possible. avisynth should be used for editing and you should set the display aspect ratio in the output file. YOu could manually resize to 16:9 size with avisynth though, like resize to 704x396.
    Quote Quote  
  3. Originally Posted by billyboy12 View Post
    This makes me think AVISynth is the culprit here.
    You think wrong. AviSynth has nothing to do with setting Display Aspect Ratios unless, as Baldrick suggests, you use it to resize to a proper 1:1 resolution.
    Quote Quote  
  4. I do? What would be causing my aspect ratio issue then? And what would you suggest to solve it?
    Quote Quote  
  5. Your video is 704x480, or a ratio of about 1.47:1. That's what AviSynth 'sees' and that's what it encodes. If you want it to be resized by the player you have to set a DAR/PAR for the container or the video. Either that or have AviSynth resize it to some 1.78:1 ratio as Baldrick suggested earlier. I don't make MKVs so someone else can tell you how to set a DAR/PAR.
    Quote Quote  
  6. Ah ha! The video size would be the problem! 704x480 isn't wide enough! That's probably what's messing AVISynth up! How would I know what the correct size would be? I check an online database, and 704x480 is the known resolution for this video, but it's clearly not correct. When I load the video up in MKVToolnix, it defaults to 853x480, which looks to be the correct aspect ratio. That would mean it was correct to begin with! Yet both Windows and AVISynth are reading the resolution as 704x480! I tried remuxing it anyway, but Windows still thinks the new video is 704x480.
    Last edited by billyboy12; 3rd May 2011 at 07:23.
    Quote Quote  
  7. The video is 704x480. You even showed us the MediaInfo information to confirm that. It'll always be that resolution unless you change the resolution when reencoding. It's a flag you set that can tell a player to resize it to 854x480 or whatever. Again, it's nothing to do with AviSynth.

    If you want a 1.78:1 ratio video, resize it to 624x352 or 704x396 (Baldrick's suggestion) or even 854x480.
    Quote Quote  
  8. Member AlanHK's Avatar
    Join Date
    Apr 2006
    Location
    Hong Kong
    Search Comp PM
    Your MKVs have been encoded anamorphically.

    Can you see the Avisynth scripts created for these files?

    I suspect the black bars aren't in the AVS file. If not, your TV may have a control to override the aspect ratio so it displays this correctly.
    Otherwise, in Avisynth, resize it to the correct ratio.
    Quote Quote  
  9. Originally Posted by manono View Post
    The video is 704x480. You even showed us the MediaInfo information to confirm that. It'll always be that resolution unless you change the resolution when reencoding. It's a flag you set that can tell a player to resize it to 854x480 or whatever. Again, it's nothing to do with AviSynth.

    If you want a 1.78:1 ratio video, resize it to 624x352 or 704x396 (Baldrick's suggestion) or even 854x480.
    Yeah, I've tried changing the size in mkvmerge, but nothing happens! The new video still has the same size as before! What am I doing wrong?

    Originally Posted by AlanHK View Post
    Your MKVs have been encoded anamorphically.

    Can you see the Avisynth scripts created for these files?

    I suspect the black bars aren't in the AVS file. If not, your TV may have a control to override the aspect ratio so it displays this correctly.
    Otherwise, in Avisynth, resize it to the correct ratio.
    Ah ha! That sounds correct, they're appearing as 4:3 ratio, but are normally expanded out to 16:9, which is what MEncoder is doing, but Windows and AviSynth are not doing. Unless PS3 Media Server creates scripts, not I can't see any AviSynth scripts.
    Quote Quote  
  10. Originally Posted by billyboy12 View Post
    Ah ha! That sounds correct, they're appearing as 4:3 ratio,
    They're appearing in the same ratio as the resolution, 704/480=1.47. or 1.47:1, not 4:3 or 1.33:1. Saying they're appearing as 4:3 implies they're being resized incorrectly by the player when they're not being resized at all.

    I know nothing about MKVMerge, but unless you're using an AviSynth script with the video resized to whatever you want and then reencoded, I don't think it can do what you want it to do.
    Quote Quote  
  11. Ah, I get it, the video itself is 704x480, which would normally be 4:3, but is normally stretched out to 16:9 to make the correct image. Windows and AviSynth are both telling it like it is, while MEncoder is applying the correct aspect ratio. Is there a way to solve this issue without re-encoding the video? I still think it's rather interesting that all the videos that give me trouble have two aspect ratios contained within them, while the ones that work, only have one. Is it possible to remove this extra aspect ratio or something?
    Quote Quote  
  12. Member AlanHK's Avatar
    Join Date
    Apr 2006
    Location
    Hong Kong
    Search Comp PM
    Originally Posted by billyboy12 View Post
    while the ones that work, only have one. Is it possible to remove this extra aspect ratio or something?
    Like I said, the problematic ones are anamorphic. The two ratios are what tell you that.

    To "remove" that you'd have to reencode to the widescreen ratio.

    But also, usually you can set the aspect ratio on the TV or media player, overriding the default, without reencoding.
    Quote Quote  
  13. Yeah, I can remove the black bars and stretch the video out to the correct aspect by changing the PS3's screen settings, but it would be nice if there were a neater solution than this.
    Quote Quote  
  14. Member AlanHK's Avatar
    Join Date
    Apr 2006
    Location
    Hong Kong
    Search Comp PM
    Originally Posted by billyboy12 View Post
    Yeah, I can remove the black bars and stretch the video out to the correct aspect by changing the PS3's screen settings, but it would be nice if there were a neater solution than this.

    For the third and last time: your videos are anamorphic.
    You'd have to reencode them to their true ratio to "fix" that .
    Quote Quote  
  15. Bummer.

    Well, I know that PS3 Media Server had the ability to insert AVISynth code, would there be any that someone could suggest that might solve this issue? Like, it resizes the video to the correct aspect? Obviously, the tricky part would be in getting it to leave videos that are suppose to be 4:3 alone!
    Quote Quote  
  16. Member AlanHK's Avatar
    Join Date
    Apr 2006
    Location
    Hong Kong
    Search Comp PM
    Originally Posted by AlanHK View Post
    For the third and last time: your videos are anamorphic.
    You'd have to reencode them to their true ratio to "fix" that .
    Well a few years later, found another possible solution, by remuxing, not reencoding.

    See http://blog.komeil.com/2006/09/modify-mp4-aspect-ratio-mp4box-mpeg4.html

    1) demux (with mkvdemuxgui)
    2) mux to mp4 and set SAR (and DAR if necessary) (mp4box).
    3) optionally remux the mp4 to mkv (MKVmergegui).


    note:

    Display Aspect Ratio = Storage Aspect Ratio × Pixel Aspect Ratio
    DAR = SAR × PAR
    You can't change the PAR without reencoding, but you can change the others by remuxing

    You can change the DAR with MKVmergegui, but some players pick up the "original aspect ratio" and use that.
    mp4box lets you change the SAR as well.
    Last edited by AlanHK; 31st Oct 2014 at 11:13.
    Quote Quote  
  17. Member Cornucopia's Avatar
    Join Date
    Oct 2001
    Location
    Deep in the Heart of Texas
    Search PM
    @AlanHK, you have that wrong: you can't change the SAR without re-encoding. mp4box let's you adjust PAR to arrive at a revise/corrected DAR. see http://tools.rodrigopolo.com/mp4box_aspect_fix/, and notice the "PAR" in the code.

    This is another misconception that really screws many people up: People like to use the SAR shorthand in AR calculation, without realizing that "there is no such thing as a stored aspect ratio". In no codec, nor container, is there a field known as SAR. Why? Because the apps & devices deal with the actual resolutions themselves directly, never relying on "SAR" for anything. The only place where SAR reliance seems to have traction is in peoples' minds.

    I think it would make discussions much clearer around here if people stopped using that stupid formula "DAR = SAR * PAR". I've been guilty of using it in a pinch also, but it's lazy! The real formula ought to be "DAR = (horizontal rez / vertical rez) * PAR" or simply "DAR = Hrez/Vrez*PAR". Basically the same thing, but it gets the point across that there is never a field called SAR that can be adjusted in any app or format. Keeps one from lazy thinking. And lazy thinking leads to faulty thinking.

    And it's always been clear that one cannot resize without re-encoding (barring a few "runtime cropping method" exceptions).

    What I think the OP had problem with was the lack of understanding that AVISynth has no notion of AR. It just deals with pixels & their sizes & placements. Whatever it's frameserving to is the app that needs to understand this and account for it as necessary, usually by expecting AVISynth to be serving 1:1 PAR material and adjusting for encoding or display needs.

    Scott
    Quote Quote  
  18. Just to confuse everyone more There are dozens of different acronyms for the same thing

    SAR is officially the Sample Aspect Ratio in MPEG4-AVC / h.264 terminology according to the specs, not the Storage Aspect Ratio. It used to be known as the "PAR" in MPEG2 days. "PAR" actually doesn't exist in AVC specs, only SAR.

    And it is an AVC VUI parameter bitstream flag as sar_width, sar_height, which you can change without re-encoding using various tools. e.g. this ffmpeg patched build, but there are others
    http://forum.doom9.org/showthread.php?t=152419

    Storage Aspect Ratio in the old terminology can be though as the w:h of the frame dimensions; it's also sometimes called the Frame Aspect Ratio or FAR. This is the one you cannot change - the "physically" encoded frame dimensions without re-encoding

    So if you are using MPEG4-AVC terminology, mp4box mislabells it the "PAR", but it's actually the "SAR", Sample Aspect Ratio that is being altered.
    Quote Quote  
  19. Member Cornucopia's Avatar
    Join Date
    Oct 2001
    Location
    Deep in the Heart of Texas
    Search PM
    Correct.
    But at least with mp4box, it isn't misleading one to think that Storage AR could be changed.

    Scott
    Quote Quote  
  20. And this is a gravedig. Even though it's Halloween, Alan knows better than to bump old threads Maybe the all the protesting in HK is getting to him
    Quote Quote  
  21. Member Cornucopia's Avatar
    Join Date
    Oct 2001
    Location
    Deep in the Heart of Texas
    Search PM
    Happy Halloween, from my avatar & me!

    Name:  Groucho_Zombified.png
Views: 2699
Size:  108.3 KBName:  ZombifiedMe copy.png
Views: 2551
Size:  109.6 KB

    Zombified Scott
    Quote Quote  
  22. Member AlanHK's Avatar
    Join Date
    Apr 2006
    Location
    Hong Kong
    Search Comp PM
    Originally Posted by Cornucopia View Post
    @AlanHK, you have that wrong: you can't change the SAR without re-encoding. mp4box let's you adjust PAR to arrive at a revise/corrected DAR. see http://tools.rodrigopolo.com/mp4box_aspect_fix/, and notice the "PAR" in the code.
    Yeah, looks like I screwed up the acronyms.
    They seem designed to obfuscate the whole issue.


    My specific problem, and what prompted this "grave digging":
    (I don't consider this a violation of etiquette since the original question wasn't solved satisfactorily, and I wanted to correct a statement I had made myself, no matter how long ago -- and appears I'm not done self-correcting.)

    I had an MKV 640x480 pixels
    It should have had the same DAR (640:480= 4:3) but when encoded had been set 16:9.


    I thought I'd fixed it by remuxing with MKVmerge and setting a new DAR, and it did play correctly on my old TV and in VLC.
    But on my new media player it was playing at 16:9.

    Media info showed :
    Display aspect ratio : 4:3
    Original display aspect ratio : 16:9

    And my stupid player apparently was using the "original" ratio.
    Similar files encoded correctly from the start had no "Original display aspect ratio" setting at all.


    So, the command line I used was
    mp4box -add 102.h264#video:par=1:1 -add 102.aac#audio 102.mp4
    Muxed that in turn to MKV and that gave me a file that played with the correct 4:3 DAR and no "Original display aspect ratio" shown.


    So yeah, I did change the PAR.

    I was thinking that the PAR was the actual encoded pixels, since that's what it sounded like, but evidently that's the SAR.
    Wrong explanation, right solution.


    Originally Posted by Cornucopia View Post
    What I think the OP had problem with was the lack of understanding that AVISynth has no notion of AR.
    Yeah, that's why I was so dogmatic. I knew it wasn't an Avisynth problem. The AR is set by the encoder and/or muxer. Often though by default, (usually 16:9 these days) which can cause confusing problems.
    Last edited by AlanHK; 31st Oct 2014 at 20:23.
    Quote Quote  
  23. I'm a Super Moderator johns0's Avatar
    Join Date
    Jun 2002
    Location
    canada
    Search Comp PM
    I would have been better to open a new thread on the discussion referencing or quoting the original post to keep it cleaner.
    I think,therefore i am a hamster.
    Quote Quote  
  24. Member AlanHK's Avatar
    Join Date
    Apr 2006
    Location
    Hong Kong
    Search Comp PM
    Originally Posted by johns0 View Post
    I would have been better to open a new thread on the discussion referencing or quoting the original post to keep it cleaner.
    It wasn't piggybacking, it was the same issue.
    I was expanding on my own earlier response.

    This thread came up when I was Googling for a solution, so likely anyone else having the same problem will get here too. Putting the answer in a different thread doesn't help them find it.
    But if it bothers you, go ahead and split it,
    Quote Quote  
  25. I guess there's differing opinions regarding posting in old threads, but in my opinion full credit should go to AlanHK for returning after all this time to admit "maybe I wasn't 100% correct". Not too many posters will even admit the slightest possibility they were wrong yesterday.
    I don't see how starting a new thread would be "cleaner". To my way of thinking it'd be the opposite to a certain extent, if Google leads people to an old thread containing incorrect information. Anyway.....

    Any aspect ratio is usually written to the video stream and at the container level, hence MediaInfo sometimes displaying "original aspect ratio" (video stream) and "display aspect ratio" (container). Mostly they're the same so MediaInfo will only show a "display aspect ratio". At least that's how I think it works.

    In my experience most players follow the container aspect ratio first and the stream aspect ratio second. If memory serves me correctly one of the Bluray players here only obeys the container aspect ratio and ignores the stream aspect ratio completely (MKVs) even when there is no container aspect ratio as such. Some players might do things differently, or even use different rules for different containers (which maybe AlanHK has experienced) but if I'm changing the display aspect ratio, I generally change both so there's no issues. Of course if the "original aspect ratio" is correct and the container aspect ratio is wrong, simply remuxing while setting the correct container aspect ratio should fix the problem.

    I'm not sure if there's another way to do it, but this version of ffmpeg will change the h264 stream aspect ratio amongst other things (it's command line).
    http://forum.doom9.org/showthread.php?t=152419
    If memory serves me correctly it doesn't set a container aspect ratio when muxing, so it's output needs to be remuxed in order to set one, but the end result should be matching container and video stream aspect ratios.
    There's also the MPEG4 Modifier for ASP video (xvid, divx etc).
    Quote Quote  
  26. Member
    Join Date
    May 2014
    Location
    United States
    Search Comp PM
    I can weigh in somewhat here. I was told before that aspect ratio information can be held not only in the container, but in the video stream inside the container as well. I tested this myself once by remuxing a video with a 4:3 ratio and telling mkvtoolnixgui to change it to 16:9. MPC-HC played it with the new aspect ratio, but my PS3 did not. In order to be sure your video plays correctly on all devices, the aspect ratio information should be set not only in the container but also in the video stream, which will require re-encoding.

    AviSynth will lose the aspect ratio information. If you rip an NTSC DVD and process it with AviSynth, it'll come out 720x480. There are no DVDs that actually display 720x480 however, it's either 4:3 (480*4/3=640, so 640x480) or 16:9 (480*16/9=~854, so 854x480). Unless something else is there to change it... MeGUI will let you set the aspect ratio to whatever you want, even when using AviSynth.
    Quote Quote  
  27. You can change the aspect ratio of an existing h264 video stream without re-encoding. The version of ffmpeg I linked to in my previous post (a while ago now) will do it, although it's a command line tool. http://forum.doom9.org/showthread.php?t=152419
    After using it to set a new video stream aspect ratio, you might have to remux with a tool such as MKVToolNixGUI to set the container aspect ratio correctly too.

    I "think" Mpeg4 Modifier changes the video stream aspect ratio for mpeg4 (ASP) video in AVIs, given AVI doesn't officially support anamorphic video.
    Quote Quote  



Similar Threads

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