VideoHelp Forum
+ Reply to Thread
Page 1 of 2
1 2 LastLast
Results 1 to 30 of 48
Thread
  1. Member
    Join Date: Aug 2014
    Location: Italy
    Search PM
    Hi,
    I'm backing up some DVD (PAL) converting them to mkv/x264 files resized to 720x404 (in case of 16:9) or 720x304 (in case if 2,35:1). I'm using AviDemux 2.6.8.v2, mkv muxer and "Mpeg4 AVC (x264)" encoder with the following setting:
    Use advanced configuration: NO
    Preset: Medium
    Tuning: Film
    For all other parameter I left the default

    Encoding mode: Average Bitrate (Two Pass)
    Average Bitrate: 1200Kbps for 720x304 (2,35:1) or 1600Kbps for 720x404 (16:9)

    Filters: deinterlace (if needed) + crop (if needed) + resize to 720x404 or 720x304

    Audio Output: copy
    I'm quite happy with the above bitrates (clean image, no artifacts, etc..) so much that I have some doubt that they could be oversized (I got them simply applying a 25% reduction to the settings that I usually use with xvid). Is there some suggested bitrate for these settings/formats? Thanks in advance to everyone who will help me.

    P.S.
    I didn't try yet to encode n-times the same source to compare all the results. Is exactly what I would like to avoid with this post...
    Quote Quote  
  2. 1200kBit/s normally isn't to low a bit rate. (I normally use more, but I would also use more when encoding to MPEG-4 ASP.)

    Also if you are uncertain about the bit rate, don't use bit rate based encoding use rate factor based encoding. (crf)

    Cu Selur


    Ps.: Assuming the source was anamorphic I wouldn't want to throw away that much information, but that is your decision.
    users currently on my ignore list: deadrats, Stears555
    Quote Quote  
  3. I'd also recommend CRF (quality based) encoding. You pick the quality and the bitrate/file size will vary (quite a bit) instead. It's faster than 2 pass as it only requires one pass. You could probably even use a slower x264 speed preset than the default (medium) for a little better compression and maybe a little more quality, without spending more time encoding than 2 pass would take.

    CRF18 is roughly where the x264 encoder is considered to be "transparent". Higher values = lower quality and smaller file sizes. The default is 23.

    Do you resize down so much for a reason? You'll probably retain more detail by increasing the width rather than reducing the height. ie 1024x576 rather than 720x404 etc.
    For 16:9 PAL I often resize to something like 960x540 as a compromise between the two. Any lower and usually I can start to see some loss of detail. The resizer used would probably make a bit of difference too (whether it's soft or sharp etc). I mostly use Spline36 myself.

    Resizing "down" to a 720 width was fairly mandatory when for standard definition players (ie AVI capable DVD players) but these days it tends not to be a restriction. Likewise 2 pass encoding made sense when you needed to burn an AVI to a CD or two, but with hard drive space nice and cheap, giving preference to quality over file size seems to be more the norm.
    Quote Quote  
  4. You'll probably retain more detail by increasing the width rather than reducing the height.
    or make an anamorphic encode
    users currently on my ignore list: deadrats, Stears555
    Quote Quote  
  5. Member
    Join Date: Aug 2014
    Location: Italy
    Search PM
    Thanks to all.

    I think I will try the CRF soon, even if I'm a little biased of the single pass encoding. I still believe that nothing can be effective as a two passes process.

    About the resize, I use those values to preserve the aspect ratio. Anamorphic resolutions bring with them the risk of not being fully compliant with some device. And in my experience I learned a very important rule: never never never stretch the source resolution, neither horizontal nor vertical. I tryed more and more times to obtain the 1:1 aspect ratio by enlarging the horizontal resolution but the overall result was always worst of the one obtained with the vertical reduction (despite I increased a lot the bitrate). I honestly do not know why. It 's just an empirical observation but absolutely real.
    Quote Quote  
  6. Originally Posted by Marco Bux View Post
    I think I will try the CRF soon, even if I'm a little biased of the single pass encoding. I still believe that nothing can be effective as a two passes process.
    You are wrong. With bitrate based encoding you specify the file size but you don't know what the quality will be. With CRF (constant quality) based encoding you specify the quality but you don't know what the file size will be. When the two deliver the same file size the quality is equal, and vice versa.
    Quote Quote  
  7. Member
    Join Date: Aug 2014
    Location: Italy
    Search PM
    Originally Posted by jagabo View Post
    When the two deliver the same file size the quality is equal, and vice versa.
    Very interesting. So, essentially, you are saying that if I use the CRF and I obtain for instance a 2GB file and then I use the two-pass encoding to obtain a file with exactly the same size, I get two files with exactly the same quality, despite the 1st one has had the opportunity of a two-pass encoding with stats and mb-tree elaboration etc? I understand correctly?
    Quote Quote  
  8. vanished El Heggunte's Avatar
    Join Date: Jun 2009
    Location: Misplaced Childhood
    Search Comp PM
    Originally Posted by Marco Bux View Post
    So, essentially, you are saying that if I use the CRF and I obtain for instance a 2GB file and then I use the two-pass encoding to obtain a file with exactly the same size, I get two files with exactly the same quality, despite the 1st one has had the opportunity of a two-pass encoding with stats and mb-tree elaboration etc? I understand correctly?
    Exactly --- because the x264 authors designed so, that is to say, x264's 2-pass compression is CRF-oriented.
    Quote Quote  
  9. Originally Posted by Marco Bux View Post
    if I use the CRF and I obtain for instance a 2GB file and then I use the two-pass encoding to obtain a file with exactly the same size, I get two files with exactly the same quality
    The two files won't be exactly the same. If you look at individual frames with a magnifier and compare the two encodings you'll see minor differences. And if you compare them to the original you'll see that sometimes one will be closer to the original, sometimes the other. But overall you won't be able to say one encoding is superior to the other.
    Quote Quote  
  10. Member
    Join Date: Aug 2014
    Location: Italy
    Search PM
    Originally Posted by jagabo View Post
    But overall you won't be able to say one encoding is superior to the other.
    Ok. For "same quality" I meant exactly this.
    Thanks.
    Quote Quote  
  11. When encoding for a particular file size (ie, average bitrate) the encoder needs to know which scenes need more bitrate and which need less bitrate so it can distribute bits accordingly. During the first pass it's really just examining the video for bitrate requirements. During the second pass it encodes, distributing bits from what it learned during the first pass.

    I recommend you do what you suggested. Encode a video using CRF mode, then encode again use 2-pass VBR. Then examine the results yourself.
    Quote Quote  
  12. This is what I found when I compared CRF to 2 pass at the same bitrate. I don't recall any visual quality differences though.
    http://forum.videohelp.com/threads/365873-Const-Quality-or-2-Pass?p=2334138&viewfull=1#post2334138

    From an x264 developer:
    http://forum.doom9.org/showthread.php?p=1448046#post1448046
    - In other words, does it basically mean that pass 1 only serves the purpose of finding the right crf for pass 2 in order to hit the desired filesize?
    - Yes.

    http://forum.doom9.org/showthread.php?p=1579684#post1579684
    2-pass is also constant quality. You just ask x264 for a bitrate instead of a quality.
    Again, they use the same bit distribution algorithm.


    http://forum.doom9.org/showthread.php?p=1373437#post1373437
    "Given the same amount of encoding time, CRF is superior to 2-pass at the same bitrate. Given the same settings rather than the same time, they're effectively identical within margin of error. My recent tests show that CRF generally has a very slight edge, albeit the difference is so small that you'd have to have OCD to care."

    The "given the same amount of encoding time" statement makes sense when you remember CRF doesn't require a first pass, so it might use slower/better encoder settings and still encode a video in the same amount of time as a 2 pass encode using faster encoder settings.
    Last edited by hello_hello; 19th Aug 2014 at 09:42.
    Quote Quote  
  13. Member
    Join Date: Aug 2014
    Location: Italy
    Search PM
    Originally Posted by jagabo View Post
    I recommend you do what you suggested. Encode a video using CRF mode, then encode again use 2-pass VBR. Then examine the results yourself.
    I'm doing it right now. I'm trying to encode the same movie using CRF with more quality values . In your experience, which value do you suggest to conciliate "pretty good quality" and "reasonable file size"?
    Quote Quote  
  14. For testing purposes you don't need to encode an entire movie. Just select a 5 minute section with a mix of shots.

    I usually encode SD movies at CRF=18. HD at CRF=21. Since SD material is enlarged when viewed on TV I think it needs to be encoded with a higher quality.
    Quote Quote  
  15. Member
    Join Date: Aug 2014
    Location: Italy
    Search PM
    Originally Posted by hello_hello View Post
    CRF18 is roughly where the x264 encoder is considered to be "transparent". Higher values = lower quality and smaller file sizes. The default is 23.
    What do you mean for "transparent"? If 18 is considered "transparent"... and (obviously) the quality cannot increase... what sense does it to use lower values? Thanks.
    Quote Quote  
  16. Member
    Join Date: Aug 2014
    Location: Italy
    Search PM
    P.S.
    Thank a lot to everybody for all these precious info
    Quote Quote  
  17. Originally Posted by Marco Bux View Post
    About the resize, I use those values to preserve the aspect ratio. Anamorphic resolutions bring with them the risk of not being fully compliant with some device. And in my experience I learned a very important rule: never never never stretch the source resolution, neither horizontal nor vertical. I tryed more and more times to obtain the 1:1 aspect ratio by enlarging the horizontal resolution but the overall result was always worst of the one obtained with the vertical reduction (despite I increased a lot the bitrate). I honestly do not know why. It 's just an empirical observation but absolutely real.
    If you take a 16:9 DVD and resize it to 720x404 you're resizing it to 16:9 square pixel dimensions. Well 720x406 is closer to 16:9 but for the sake of the discussion.....
    1024x576, 960x540, and 640x360 are 16:9. You should be able to resize to any of those dimensions and the picture will look the same (with more or less picture detail). 1024x576 (or 960x540) should retain more picture detail than 720x404.
    How to you calculate the correct cropping/resizing?

    Originally Posted by Marco Bux View Post
    Originally Posted by hello_hello View Post
    CRF18 is roughly where the x264 encoder is considered to be "transparent". Higher values = lower quality and smaller file sizes. The default is 23.
    What do you mean for "transparent"? If 18 is considered "transparent"... and (obviously) the quality cannot increase... what sense does it to use lower values? Thanks.
    I guess "transparent" doesn't necessarily mean "exactly the same", but rather it means "looks the same".
    That's why I said "roughly" where it's considered to be transparent. Most of the time you could probably run the original video and a CRF18 encode side by side and see no difference, but if you paused each on identical frames you might see they're not exactly the same. Even if it's just the "noise" or "film grain" which looks different when the video is paused, but while the video is playing, any difference is usually very hard to see.
    Of course filtering can effect the output quality for the better or worse before the encoding quality becomes a factor. The de-interlacing quality would be an example of that and/or whether you de-interlace to "half frame rate" (25fps progressive for PAL) or "full frame rate" (50fps progressive). The latter will generally look much better.

    "Transparent" can also be a little resolution dependant. Standard definition video is often upscaled to 1080p which means any compression artefacts are also upscaled, possibly making them more noticeable. So a CRF value which is "transparent" at 1080p might be a little less so at 480p. I tend to use CRF18 for 720p or lower resolutions and CRF20 for 1080p.

    Not all video encodes with equal quality even at the same CRF value. Sometimes there's "harder to encode" scenes where you'll see larger differences between the source and the encode for a given CRF value, even when using lower CRF values. And colour banding can sometimes be a problem, even at CRF18.

    And because "transparent" doesn't mean "the same", a CRF value which is transparent to some may not look as good to others. The more video you encode the more you're likely to notice compression artefacts because you train yourself to notice them.

    As a rule of thumb, if you want "perfection" you'd probably go with something like CRF16. I think a few posters here go as low as CRF14 but even at CRF16 the file sizes tend to increase substantially compared to CRF18. If you want "looks the same" then CRF18 is a good starting place, but higher CRF values can still look very good. Even transparent.....
    Last edited by hello_hello; 19th Aug 2014 at 19:26.
    Quote Quote  
  18. At CRF 18 you'll see some posterization in dark grainy shots. You can alleviate that somewhat by using "--tune grain", or "--aq-strength=1.8" (or anywhere from ~1.6 to ~2.0). But in the end, you'll end up with a higher bitrate.
    Quote Quote  
  19. Member
    Join Date: Aug 2014
    Location: Italy
    Search PM
    You've absolutely convinced me of the goodness of CRF and that the concept of "trasparent" can be quite subjective. I'm doing some test with many CRF values, mainly between 16 and 18. I intend to give you a feedback as soon as I find the time to finish the job. In the meantime, thanks again.
    Quote Quote  
  20. Originally Posted by Marco Bux View Post
    I'm doing some test with many CRF values, mainly between 16 and 18.
    It's very hard to see small differences in quality. I suggest you start with larger steps, say 12, 15, 18, 21, 24. See which of those is in the ballpark you find acceptable. Then look at steps of 1 around that value. Pay close attention to loss of small, low contrast detail; posterization in dark grainy areas; and the smoothness of edges of moving objects. At higher CRF values you'll also start seeing block artifacts.
    Quote Quote  
  21. Originally Posted by hello_hello View Post
    I'd also recommend CRF (quality based) encoding. You pick the quality and the bitrate/file size will vary (quite a bit) instead. It's faster than 2 pass as it only requires one pass. You could probably even use a slower x264 speed preset than the default (medium) for a little better compression and maybe a little more quality, without spending more time encoding than 2 pass would take.

    CRF18 is roughly where the x264 encoder is considered to be "transparent". Higher values = lower quality and smaller file sizes. The default is 23.

    Do you resize down so much for a reason? You'll probably retain more detail by increasing the width rather than reducing the height. ie 1024x576 rather than 720x404 etc.
    For 16:9 PAL I often resize to something like 960x540 as a compromise between the two. Any lower and usually I can start to see some loss of detail. The resizer used would probably make a bit of difference too (whether it's soft or sharp etc). I mostly use Spline36 myself.

    Resizing "down" to a 720 width was fairly mandatory when for standard definition players (ie AVI capable DVD players) but these days it tends not to be a restriction. Likewise 2 pass encoding made sense when you needed to burn an AVI to a CD or two, but with hard drive space nice and cheap, giving preference to quality over file size seems to be more the norm.
    ^This x100.

    Use a program called Handbrake. Use the "High Profile" setting and use one of the RF settings for constant quality. This does a better job in my experience than a static bitrate. I usually go with slower x264 presets rather than upping the RF value from 18. It's a little slower, but it doesn't take me too long since I upgraded to an i7-2700k because my i5-2320 wasn't cutting it.
    Quote Quote  
  22. Member
    Join Date: Aug 2014
    Location: Italy
    Search PM
    Hi, masters!

    As promised I made some test. I tried to backup some movie (SD/PAL) using different values of CFR. I was almost convinced of the benefits of CFR but honestly after these tests I figured out that the resultant bitrate seems to be too unpredictable and often oversized.

    When I was using the xvid encoding I always used an average bitrate within a range between 1.600 and 2.048 Kbits (depending on resolution) and I never had noticeable problems (keep in mind that I am not one that checks the video frame by frame). In other words it was a kind of safety zone in which I was reasonably sure of getting a good encoding at the first shot, avoiding the risk of a decline in the quality explicitly observable while watching the movie. Using x264 I expected to decrease this range at least of 25%.

    Sometime it happens. Even too much... In some cases with CRF 18 I obtained a bitrate nearly embarrassing, so was low (see "Movie #4", below). But in many other cases I obtained completely opposite results (see "Movie #2" and "Movie #3", below).

    For 720x400 resolution, for instance, the bitrate obtained using CRF 18 seems to be often oversized. In some cases I obtained a bitrate much greater than the one I used to encode the same movie in xvid and with which i got a video absolutely appreciable. The figures don't add up... but maybe there is an explanation.

    As the algorithm of quality recognition can be sophisticated will never have the feeling and good sense of a human being (also because the human feeling is subjective). For example, a source video could contains some little dithering or artefacts nearly invisible to the human eye while watching the movie but absolutely visible to the CRF algorithm (enough to get mislead).

    Surely I need more experience but currently I'm inclined to use this simple rule: use CRF18 but if the resultant bitrate is higher than the setting used in the time of xvid, then re-process the video using that value for a two pass encoding.

    What do you think?...

    Name:  01-Movie-4.png
Views: 440
Size:  5.5 KB

    Name:  02-Movie-2.png
Views: 441
Size:  6.2 KB

    Name:  03-Movie-3.png
Views: 437
Size:  6.1 KB
    Quote Quote  
  23. Member
    Join Date: Aug 2014
    Location: Italy
    Search PM
    Originally Posted by hello_hello View Post
    How to you calculate the correct cropping/resizing?
    My video sources are some DVD PAL for which I need a backup. These movie are almost all 16:9 or 2,35:1 anamorphic. They are mainly comedies and similar movies, so my goal is not the absolute perfection of the image. It looks like a minor detail but it is not. In fact, is the key to understanding of this thread...

    For those at 2,35:1, I simply crop about 75 pixel on top and bottom (the typical black bands) and then I resize to 720x304, that is the multiple of 16 closest to 306,38 (= 720 / 2,35). In my point of view, an acceptable compromise...

    The 16:9 ones, often show a couple of black pixel on top and bottom so I remove these tiny bands with the crop filter (2 on top and 2 on bottom) and then I resize to 720x400, that is the multiple of 16 closest to 402,18 (= 720 /16*9 - (2+2 resized)). Another acceptable compromise...
    Quote Quote  
  24. There's one simple way to always get the right square pixel dimensions. DVD only comes in two display aspect ratios 4:3 and 16:9. So if you resize to a 4:3 or 16:9 frame size first (whichever is correct for that DVD), then crop away any black borders, you will have a square pixel video where the frame size matches the display aspect ratio of the content. You may have to leave a line or two of black, or crop away a line or two of the picture because codecs generally don't allow odd frame sizes. I'd even stick with mod 4 (integer multiples of 4) or even mod 8 when possible.

    You can also do the opposite if you're confident your players support aspect ratio flags. Don't resize the DVD frame, just crop it and flag the display aspect ratio or pixel aspect ratio. Most modern players support AR flags at the container or codec level.
    Last edited by jagabo; 27th Aug 2014 at 10:50.
    Quote Quote  
  25. XVID an x264 are chalk and cheese. Even at maximum quality (default h263 matrix) xvid tends to be blocky and throws away a lot of detail.
    x264 at CRF23 would probably be as good as xvid. Actually, probably better.

    Xvid doesn't have a true quality based, single pass encoding mode, but it's single pass, quantiser encoding method is similar. Pick a quantiser value (2 is maximum quality) and encode a few videos. The bitrates will vary all over the place just as they do for x264's CRF encoding. How that'd fit into your bitrate theories, I'm not sure....

    For those at 2,35:1, I simply crop about 75 pixel on top and bottom (the typical black bands) and then I resize to 720x304, that is the multiple of 16 closest to 306,38 (= 720 / 2,35). In my point of view, an acceptable compromise...
    I haven't checked your math but assuming the resizing to 720x304 is correct......

    When you crop 75 pixels from the top and bottom you're left with 576 - 75 - 75 = 426.
    720/304 = 2.368
    426 x 2.368 = 1008

    How could 1008x426 look any different to 720x304 in respect to the aspect ratio?

    Actually that shows you might be distorting the picture a bit, assuming you're cropping nothing from the sides. A 16:9 PAL DVD stretched to exactly 16:9 is 1024x576 in square pixels dimensions. Crop 75 pixels from the top and bottom and you're left with 1024x426.

    Forget the mod16 thing. That's something from the dark ages. For x264 encoding it matters not. If you want to be completely safe use a mod4 width. The height doesn't matter. I've got a reasonable amount of mod2 video and I've never had a problem playing it. My Bluray player and my TV's media player don't care.
    Quote Quote  
  26. Member
    Join Date: Aug 2014
    Location: Italy
    Search PM
    Originally Posted by jagabo View Post
    If you resize to a 4:3 or 16:9 frame size first (whichever is correct for that DVD), then crop away any black borders, you will have a square pixel video where the frame size matches the display aspect ratio of the content.
    You're right, but I think it's a question of... school of thought. I did as you told for a long time but now I prefer to conform my videos to a kind of standard resolutions that are, indeed, 720x304 in case of 1:2,35 and 720x400 in case of 16:9. From my point of view my method is more accurate, but it is subjective. Anyway I still use your method in the few cases where the source DVD has an "unconventional" aspect ratio. Fortunately it rarely happens.
    Quote Quote  
  27. Originally Posted by Marco Bux View Post
    You're right, but I think it's a question of... school of thought. I did as you told for a long time but now I prefer to conform my videos to a kind of standard resolutions that are, indeed, 720x304 in case of 1:2,35 and 720x400 in case of 16:9. From my point of view my method is more accurate, but it is subjective.
    I'd have to disagree with that one. The only thing standard about resolutions such as 720x304 or 720x400 etc is their use for compatibility's sake with hardware players. 720 was the maximum width, and the width and height needed to be mod16. These days 1920 is the maximum width and mod16 doesn't matter, unless you're still playing encodes with an old AVI capable DVD player.
    Even the "scene" encoders have moved away from old Xvid habits and now use resolutions such as 854x480 or 720x404.

    To me, resizing "up" (ie 1024x576) is better than resizing "down" (ie 720x400) because it should retain more picture detail.

    There's really nothing subjective about the accuracy of resizing.

    An exact formula for calculating resizing (assuming square pixels) could be:
    (original height / original width) x new width = new height.
    ie (720 / 1280) x 704 = 396. Therefore 1280x720 and 704x396 are the same aspect ratio.

    When the pixels aren't square, the pixel aspect ratio needs to be added to the formula. For resizing a 16:9 PAL DVD to exact 16:9 dimensions, the DVD pixel aspect ratio is 64/45, so.... (although there's probably a better way to express the equation)

    (576 / 720) x 1024 / (64 x 45) = 576
    So a 16:9 PAL DVD could be resized to 1024x576 or
    (576 / 720) x 720 / (64 x 45) = 405
    You could resize to either 720x404 or 720x406 or
    (576 / 720) x 704 / (64 x 45) = 396
    704x396 is exactly 16:9.

    Trim 75 pixels top and bottom:
    (476 / 720) x 1024 / (64 x 45) = 476 (1024x476) or
    (476 / 720) x 720 / (64 x 45) = 334 (720x334) etc
    The same formula applies whether you crop from the height, the width, or both.

    Possibly the only thing subjective about resizing is the choice of pixel aspect ratio. There's a list of pixel aspect ratios here.

    My rule of thumb.... pretty much all 4:3 DVDs use an ITU aspect ratio. I think most encoding programs would use the "commonly used ITU-PAR" when calculating resizing for ITU DVDs.
    Most newer 16:9 DVDs use the generic PAR. If a 16:9 DVD has around 8 pixels or more of black down each side, the pixel aspect ratio is probably ITU instead.

    As I said, that's my rule of thumb, but it's not guaranteed to always be right.
    Last edited by hello_hello; 27th Aug 2014 at 18:20.
    Quote Quote  
  28. Member Ethlred's Avatar
    Join Date: Feb 2008
    Location: United States
    Search Comp PM
    I don't get the fixation with square pixels. I did that with X-Vid because it never handled aspect ratios correctly and mostly not at all. But with x264 the is no need for square pixels. I try to stick to the original which is NEVER more than 720 wide.

    I use Megui with anamorphic settings just like the original has though I do crop to the image. Nothing is lost that way. Nothing is added. I try to avoid resizing as that is an unneeded change. I have thought about no cropping as well but I wasn't satisfied with the results the last time I played around with it.

    A good thing to test with is trailers. Of course it does have a problem with the scenes being shorter than the standard GOP.
    Quote Quote  
  29. There is no reason for square pixel or against it, unless your playback device/player can't handle anamorphic pixels.
    users currently on my ignore list: deadrats, Stears555
    Quote Quote  
  30. Member
    Join Date: Aug 2014
    Location: Italy
    Search PM
    Originally Posted by hello_hello View Post
    The only thing standard about resolutions such as 720x304 or 720x400 etc is their use for compatibility's sake with hardware players.
    For "standard" I meant "16:9" and "2,35:1". I know you want me to convince at any cost to resize "up" my videos but I don't like that solution. And about the aspect ratio, honestly, I do not think worth doing a religion war for a pixel, also because the theme of this thread would be the bitrate.

    Originally Posted by hello_hello View Post
    Forget the mod16 thing. That's something from the dark ages. For x264 encoding it matters not. If you want to be completely safe use a mod4 width.
    This, is a very good news! Thanks!
    Quote Quote