EDIT: I changed the title of this thread as it moved on beyond the initial preset parameters to other items so made the title more generic.
This is NOT a plex question however I’m hoping someone in the community will be able to help me with my question.
For years now I downgrade high quality video to 480p. Reasons are for comparability with browers, low end devices, file size and to not require transcoding for all media on my server.
I use two pass encoding to help with file size. The commands I use are below:
Anyhow, this has worked pretty well. Quality is good enough (I know this is always subjective) but its certainly okay for my small number of users. However, the encode time I’d really like to slim down so I’ve been playing around with changing the -preset parameter.
Been doing some tests with a 25 minute video. On my hardware using veryslow it takes approx 15 minutes to complete and using “medium” it takes approx 9 minutes.
This is a significant improvement. The file size of the output is exactly the same and quality appears identical. Information online regarding the impacts of preset is pretty sparse when using 1) two pass encoding and 2) a constant video bitrate.
So to my question ? Am I missing something important changing the preset down to medium ? I know its important for compression / file size but as I use two pass encoding that shouldn’t be a factor. And, as I say quality appears identical. So, want to make sure I’m not missing something before I roll this change into my workflow.
my emphasis.
It’s very possible that it is not identical if you use the right scenes and measuring methods. It is also very likely that you won’t notice a difference in the majority of cases. Just that the encoding quality may be lower in some edge cases, where the required bitrate is higher (high amount of noise/grain, fast movement/panning/zooming of large screen areas).
That being said, I think reducing everything to SD is quite harsh. Sure, it will play fluidly on every potato-powered hardware, but on a larger screen the result is not very pleasing.
So this got me thinking and I’ve been tinkering with ffmpeg settings. Generally we’ve been happy enough with SD quality for TV shows (we use HD 1080p for movies) however I’m now considering switching TV from SD to 720p instead and wanted to ask your opinion from a plex perspective.
Two-Pass Encoding:
I’ve been using two pass encoding for years mainly related to this comment and crf “The downside is that you can’t tell it to get a specific filesize or not go over a specific size or bitrate, which means that this method is not recommended for encoding videos for streaming.” → Encode/H.264 – FFmpeg. So I get the file size but that is probably less of a concern now but does the “not recommended for encoding videos for streaming” really matter when it comes to plex ? If it doesn’t then I may just move to crf (18 or 20).
Going for a target Bitrate gives you a file which is better suited for streaming. Simply because it has a predictable and relatively constant bandwidth requirement. But the visual quality of the encoded video will vary a bit – no matter the number of encoding passes.
Going for a target quality will result in a constant quality, but sometimes wildly varying bitrate. This is however what I am using. I prefer quality and I can’t stand the thought of storing more data than what would be required.
(With animation content, I’ve usually observed differences in the average bitrate to the peak bitrate requirements of 3x to 5x. Enabling the deep Bitrate Analysis in Plex is therefore more important.)
I use 720p for TV shows as well. Movies go to 1080p H.264, level 4.0.
Using level 4.0 has the advantage that it has a bandwidth limit of 25mbps.
I don’t know if something comparable exists for H.265.
Lately I’ve also enabled the chroma smoothing filter at “very light”. This helps saving some bandwidth with just a very minor quality penalty.
Thanks. I’m certainly coming to that conclusion with all the messing around I’ve been doing the last week. Its always somewhat scary changing something which you know has worked for years.
Follow on question. Do you have any thoughts on maxrate and bufsize in this regard ? I’m thinking its doesn’t really add much benefit but wanted to ask in case I’m missing something.
I use libx264 and think I’ll stick with that. ATM I’m thinking 720p (using scale=1280:-2), crf 18, profile high and level 31 for TV. File size of output is not all that different to what I have today at SD, its just encode time to redo I’ve a few other parameters to play around with and this has been an educational discussion. THANK YOU.
In which context? As an encoder parameter? I don’t mess with that. I select Level 4.0 and that was it. Maybe change the encoder tuning from “None” to “Animation” (or “still image” for local extras) if the content is suitable. But no other.
Over the years on here I’ve encountered so many people messing with the detailed encoder parameters, without knowing what they’re doing. Only to end up with an encode that usually plays fine on computers, but fails on embedded systems, like smart TV, media player sticks, or tablets etc.
So no, don’t mess with that.
That’s just the name of the open source library for the H.264 encoder, which is used both in Handbrake and ffmpeg.
This can prove too high a quality if you go to higher resolutions. Whereas previously the downscaling to SD would have removed much of the noise and grain (as a side effect), some of this noise can survive at 720p and thus will take up a significant amount of bandwidth if you encode with such a high fidelity setting.
At 1080p, I default to CRF 20. Only if I have cleaned the video previously of noise I go to CRF 19.
If you have a very clean animation movie, you can go down to CRF 17. (“animation” refers to traditional cel animation with hard contour lines and flat colors inbetween. Not the CG created stuff you get nowadays from Pixar, et al.)
Oh and if you go with constant quality, the encoding speed influences the encoding efficiency and thus the resulting file size (and bitrate). Although the gains are getting smaller with every “slower” step, I use always “very slow”. I simply don’t care about that. I’ll let it run overnight if I have to.
I don’t know if you find value in this at all, but I figured it could help (in case you didn’t already know this) to know that the current defaults in Handbrake (and hence “safe/good” settings) are the same as you two are discussing towards:
CRF: 20
Preset: medium (suggesting veryslow is probably overkill as you said)
Level: auto (which usually ends up being 4.0)
I personally think it says a lot, and I trust the Handbrake team knowing an optimal baseline here, so this is what I use. Just something to consider if you’re on the fence.
Thanks again. I’m currently testing this with various different types of series (live action & animation). I’ve steered away from crf in the past as I wanted two pass encoding so I can target a specific output file size. I’m still on the fence as I really like being able to get specific file size.
I can see that there are some things why that is desirable.
On the other hand: video compression doesn’t work like that. If there are many details and/or much and fast movement, you will require more bandwidth. It is therefore not sensible to go for uniform file sizes. Because you can end up with videos which lack bitrate and therefore have lackluster quality, or you will get videos where bandwidth is wasted on.
Again, want to thank you both @OttoKerner and @d2freak for your comments on this thread. For conclusion and incase anyone else comes across this thread I wanted to update with what I decided.
After many encodes using crf vrs 2pass and testing various outputs (local & remote) on pc, tablets, mobile and tv I’ve decided to stick with Two-Pass encoding but change from SD to 720p quality for TV series.
Really, this post and this comment within … “When I’ve compared CRF and 2 pass, the only time there’s been perceivable differences in quality is in extreme situations”
… sums up the same findings I’m seeing.
For reference here is the encoding commands I’m going with and I’ve switched to a medium preset.
Otto, you say you default to crf 20 for 1080p but can I ask what you default to for 720p ? Been playing around again and crf 22 at 720p seems pretty good using the slow preset to help with compression.
Do either of you use -tuneEncode/H.264 – FFmpeg or have an opinion on it with settings film (tv live action content) or animation (for cartoons / anime etc…) in regard to TV series ?
No, because that’s too small of an impact in my opinion. I like consistency personally, and to tinker with that for every file would drive me up the wall
Edit: And also, you are already downsizing shows to 720p so I would assume this would have even less of an impact, because of the smaller resolution.
Have either of you ever adjusted the “scaling algorithm” away from the default bicubic ? Been reading a number of opinions from other forums saying that lanczos is better and wanted to ask your thoughts.
I usually use Handbrake, and that one defaults to Lanczos (at least for downscaling, AFAIK).
Never upscale during encoding. It won’t improve anything, except making the resulting files larger.
If you absolutely have to upscale, consider using a far more advanced method like Topaz Video AI 4
As an FYI and for anyone else who manages to come across this thread. I created a thread over at the ffmpeg subreddit → Reddit - Dive into anything and the couple of responses so far seem to indicate lanczos is preferred.
I’ve done a bit of testing this evening with stuff I seen as a little glossy and using "scale=1280:-2:flags=lanczos+accurate_rnd,format=yuv420p" appears to have done the job nicely and so far is producing good quality content when viewed on TV via nvidia shield.
… and you may notice, I’ve switched over to using crf 20 instead of 2-pass and using slow preset mainly for output compression as its better than medium. You guys converted me