Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > High Efficiency Video Coding (HEVC)

Reply
 
Thread Tools Search this Thread Display Modes
Old 18th January 2022, 15:29   #1  |  Link
jriker1
Registered User
 
Join Date: Dec 2003
Posts: 485
Video stuttering when skipping ahead (converted with ffmpeg)

I have been encoding 4K HDR10 video with similar ffmpeg settings as below, just tweaked in theory for 1080p for some older footage I need to convert. I play most of my content thru the NVidia Shield and never have issues. Until now. I have a H.264 AVC video that I am converting to H.265 and it plays fine on VLC on Windows, but when I play this one and a couple other similar videos that are 1080p on the Shield, they seem to play OK, until I jump ahead. The audio keeps working, but the video will either not move for a while or will but the video will stutter. And keep doing that. If I jump back 10 seconds or so it will start playing normally again. Never saw this before. Below is the command I'm running essentially:

ffmpeg.exe -i <input_video>.mkv -c:v libx265 -x265-params level=51:high-tier=1:repeat-headers=1:colorprim=bt709:transfer=bt709:colormatrix=bt709:crf=13:chromaloc=0:no-sao=1:info=0:range=limited:vbv-maxrate=17500:vbv-bufsize=17500 -vf crop=1920:816:0:0 -preset slower -pix_fmt yuv420p10le -sn -an <output_video>.hevc

So when that had this issue tried extracting all the frames as images and then ran the below but same deal:

ffmpeg.exe -framerate 24000/1001 -f image2 -i img%09d.bmp -c:v libx265 -x265-params level=51:high-tier=1:repeat-headers=1:colorprim=bt709:transfer=bt709:colormatrix=bt709:crf=13:chromaloc=0:no-sao=1:info=0:range=limited:vbv-maxrate=17500:vbv-bufsize=17500 -vf crop=1920:816:0:0 -preset slower -pix_fmt yuv420p10le -sn -an <output_video>.hevc

Any thoughts on what's going on?

Thanks.

JR
jriker1 is offline   Reply With Quote
Old 18th January 2022, 17:56   #2  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,346
What are you using to multiplex streams into the container ?

Shorter max keyframe interval might help with seeking
poisondeathray is offline   Reply With Quote
Old 18th January 2022, 20:44   #3  |  Link
jriker1
Registered User
 
Join Date: Dec 2003
Posts: 485
Quote:
Originally Posted by poisondeathray View Post
What are you using to multiplex streams into the container ?

Shorter max keyframe interval might help with seeking
Thanks for the reply. Will try a shorter max keyframe interval. With multiplexing using mkvtoolnix latest version.
jriker1 is offline   Reply With Quote
Old 22nd January 2022, 01:21   #4  |  Link
jriker1
Registered User
 
Join Date: Dec 2003
Posts: 485
By the way, my source was 8 bit so changed the pix_fmt but that didn't help but still makes sense to do. What would the thought be if...

1. The converted video put in an mkv container plays super fast and no hickups by itself. I can't even fast forward thru the footage with it immediately playing. No audio of course.
2. If I add in the DTS audio file untouched, and the ass subtitles which are text and always make them, it starts up again.

Should I assume something is wrong with the DTS file?
jriker1 is offline   Reply With Quote
Old 22nd January 2022, 02:23   #5  |  Link
benwaggoner
Moderator
 
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,752
If using x265, --no-open-gop can improve random access with some players.

--repeat-headers and maybe --aud could potentially help as well.
__________________
Ben Waggoner
Principal Video Specialist, Amazon Prime Video

My Compression Book
benwaggoner is offline   Reply With Quote
Old 22nd January 2022, 03:13   #6  |  Link
jriker1
Registered User
 
Join Date: Dec 2003
Posts: 485
OK I have --repeat-headers but will try your other suggestions. See you in a couple days when it's done.

Note the video is fine as encoded when I have no audio in the MKV. When I add the audio then it starts playing odd various times when I jump around. Audio is DTS XLL on these issue items if that helps at all. Not sure if the NVidia Shield has issue with this audio file though it plays fine. Even while the video is stuttering the audio keeps chugging along.
jriker1 is offline   Reply With Quote
Old 23rd January 2022, 03:28   #7  |  Link
benwaggoner
Moderator
 
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,752
Quote:
Originally Posted by jriker1 View Post
OK I have --repeat-headers but will try your other suggestions. See you in a couple days when it's done.

Note the video is fine as encoded when I have no audio in the MKV. When I add the audio then it starts playing odd various times when I jump around. Audio is DTS XLL on these issue items if that helps at all. Not sure if the NVidia Shield has issue with this audio file though it plays fine. Even while the video is stuttering the audio keeps chugging along.
If you use AAC audio, do you have the same problems?
__________________
Ben Waggoner
Principal Video Specialist, Amazon Prime Video

My Compression Book
benwaggoner is offline   Reply With Quote
Old 23rd January 2022, 22:04   #8  |  Link
jriker1
Registered User
 
Join Date: Dec 2003
Posts: 485
Quote:
Originally Posted by benwaggoner View Post
If you use AAC audio, do you have the same problems?
I switched the DTS Master to AAC. Obviously not the same bitrate but no the stuttering couldn't be reproduced. Still had the lag in the video starting at times when jumping ahead a bunch but no stuttering playback. Thinking this must be the player. On a PC with VLC it's fine. One a NVidia Shield Pro 2019 on VLC it's fine. On Emby this happens. All are direct playing, no transcoding.

Last edited by jriker1; 23rd January 2022 at 22:18.
jriker1 is offline   Reply With Quote
Old 24th January 2022, 03:17   #9  |  Link
benwaggoner
Moderator
 
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,752
Quote:
Originally Posted by jriker1 View Post
I switched the DTS Master to AAC. Obviously not the same bitrate but no the stuttering couldn't be reproduced. Still had the lag in the video starting at times when jumping ahead a bunch but no stuttering playback. Thinking this must be the player. On a PC with VLC it's fine. One a NVidia Shield Pro 2019 on VLC it's fine. On Emby this happens. All are direct playing, no transcoding.
Could well be a player-specific issue with DTS, or a muxing issue.

Lag in random access is most common with very long GOP sizes. The default --keyint 250 can require decoding a lot of frames to be able to display an arbitrary one near the end of the GOP, as all frames that frame references need to be decodes, and all the frames those frames reference.

If that's it, lowering --keyint should proportionally reduce worst-case random access time.
__________________
Ben Waggoner
Principal Video Specialist, Amazon Prime Video

My Compression Book
benwaggoner is offline   Reply With Quote
Old 24th January 2022, 16:54   #10  |  Link
jriker1
Registered User
 
Join Date: Dec 2003
Posts: 485
Got derailed with my other testing so running now. Added in keyint=24:min-keyint=24.

Do we think this would help the playback issue when jumping around though pretty convinced it's due to the audio. Also there was a mention about how it was multiplexed. Would mkvtoolnix be an issue multiplexing the content?
jriker1 is offline   Reply With Quote
Old 24th January 2022, 17:27   #11  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,346
You can try a transport stream instead of mkv to see if it makes a difference
poisondeathray is offline   Reply With Quote
Old 25th January 2022, 02:32   #12  |  Link
benwaggoner
Moderator
 
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,752
Quote:
Originally Posted by jriker1 View Post
Got derailed with my other testing so running now. Added in keyint=24:min-keyint=24.

Do we think this would help the playback issue when jumping around though pretty convinced it's due to the audio. Also there was a mention about how it was multiplexed. Would mkvtoolnix be an issue multiplexing the content?
Raising min-keyint could hurt average seek time a little, and definitely can impact quality, as keyframes take a lot more bits for a given quality. I suggest leaving min-keyint alone, so it can adaptively put the keyframes in their optimal place (like hard edits).
__________________
Ben Waggoner
Principal Video Specialist, Amazon Prime Video

My Compression Book
benwaggoner is offline   Reply With Quote
Old 25th January 2022, 12:54   #13  |  Link
excellentswordfight
Lost my old account :(
 
Join Date: Jul 2017
Posts: 322
Quote:
Originally Posted by benwaggoner View Post
Raising min-keyint could hurt average seek time a little, and definitely can impact quality, as keyframes take a lot more bits for a given quality. I suggest leaving min-keyint alone, so it can adaptively put the keyframes in their optimal place (like hard edits).
min-keyint is set to 23 automatically for 23,976 content by default so he is not really changing anything. And I-slices can still be placed more frequent, they will just not be IDR-frames.

Last edited by excellentswordfight; 25th January 2022 at 14:00.
excellentswordfight is offline   Reply With Quote
Old 25th January 2022, 22:15   #14  |  Link
jriker1
Registered User
 
Join Date: Dec 2003
Posts: 485
Quote:
Originally Posted by poisondeathray View Post
You can try a transport stream instead of mkv to see if it makes a difference
Encoding with the change however transport stream was a total bust. With or without the audio the video was hanging so long between jumps thru the footage I gave up. Audio would play but 30 seconds later video was still sitting (when there was audio included). Going back to the MKV version with no audio everything worked fine or seemed to. What's funny is my 4k HDR content all loads fast, no lag, no video taking forever to start and the file size is huge compared to this. Below is an example of what I do with my 4K HDR content:

ffmpeg.exe -i "<source>.mkv" -c:v libx265 -x265-params level=51:hdr10=1:hdr-opt=1:high-tier=1:repeat-headers=1:colorprim=bt2020:transfer=smpte2084:colormatrix=bt2020nc:master-display=G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,0):crf=13:chromaloc=2:no-sao=1:info=0:range=limited:vbv-maxrate=17500:vbv-bufsize=17500 -vf crop=3840:1600:0:280 -preset slower -pix_fmt yuv420p10le -sn -an "<output>.hevc"

Last edited by jriker1; 25th January 2022 at 22:18.
jriker1 is offline   Reply With Quote
Old 26th January 2022, 01:39   #15  |  Link
benwaggoner
Moderator
 
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,752
OH! I bet High-tier is the problem. Lots of consumer decoders don't handle it well, and may go into a weird mode just from that flag. Your bitrates caps are well below the Main Tier thresholds, so just use Main. With a CRF of 13 and a 17.5 Mbps max bitrate, you're probably getting something pretty close to CBR.

Level 5.1, which you are using, can go up to 40 Mbps, so there's no reason to use High Tier unless you want to go above that. For 17.5 Mbps, you might as well use Level 5.0 (max of 25 Mbps), which might boost compatibility or performance on some older devices.
__________________
Ben Waggoner
Principal Video Specialist, Amazon Prime Video

My Compression Book
benwaggoner is offline   Reply With Quote
Old 26th January 2022, 09:29   #16  |  Link
excellentswordfight
Lost my old account :(
 
Join Date: Jul 2017
Posts: 322
Quote:
Originally Posted by benwaggoner View Post
OH! I bet High-tier is the problem. Lots of consumer decoders don't handle it well, and may go into a weird mode just from that flag. Your bitrates caps are well below the Main Tier thresholds, so just use Main. With a CRF of 13 and a 17.5 Mbps max bitrate, you're probably getting something pretty close to CBR.

Level 5.1, which you are using, can go up to 40 Mbps, so there's no reason to use High Tier unless you want to go above that. For 17.5 Mbps, you might as well use Level 5.0 (max of 25 Mbps), which might boost compatibility or performance on some older devices.
I noticed high tier as well, but it feels a bit odd that it would create issues if 2160p works with lvl5.1 flagged as high tier, and especially since rather low vbv limits are set.

But yes having that low crf value and vbv doesnt seems like that great, but that should be more in terms of encoding quality then decoding compat, right?

Was thinking that it was related to ref-frames, as you are using a low resolution for that level, with a low preset I thought that x265 would behave like x264 and use ref 16. But it doesnt looks like x265 go above 5 with that command line...

But it might be something to try out. What happens if you remove the vbv settings and set high-tier=0, and use level 4.1 (that would automatically set vbv to 20Mbps)?

Last edited by excellentswordfight; 26th January 2022 at 09:32.
excellentswordfight is offline   Reply With Quote
Old 26th January 2022, 18:16   #17  |  Link
benwaggoner
Moderator
 
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,752
Quote:
Originally Posted by excellentswordfight View Post
I noticed high tier as well, but it feels a bit odd that it would create issues if 2160p works with lvl5.1 flagged as high tier, and especially since rather low vbv limits are set.
I'd hope it wouldn't, but some devices have pretty prescriptive decoders to reduce risk of playback errors and security threats. There's certainly no reason to use High Tier 5.1 with Main Tier 5.0 VBV limits.

Quote:
But yes having that low crf value and vbv doesnt seems like that great, but that should be more in terms of encoding quality then decoding compat, right?
Correct.

Quote:
Was thinking that it was related to ref-frames, as you are using a low resolution for that level, with a low preset I thought that x265 would behave like x264 and use ref 16. But it doesnt looks like x265 go above 5 with that command line...
Default --ref is based on --preset, with a maximum of 5 for --preset veryslow. HEVC itself has an 8 ref max IIRC.

It's been a big problem that x264 historically didn't enforce Profile and Level constraints, resulting in out of spec files that had big playback issues with hardware decoders. x265 did the right thing here, where you have to use an override to violate spec compliance.

Quote:
But it might be something to try out. What happens if you remove the vbv settings and set high-tier=0, and use level 4.1 (that would automatically set vbv to 20Mbps)?
Level 4.1 can't do 2160p, so it would just error out. Main Tier Level 5.0 is the lowest that can support 2160p, and then only up to 32 fps IIRC. If you set --level 5.0, vbv-bufsize and vbv-maxrate should be automatically set to 25000 unless otherwise specified.

Unlike classic x264, where setting --level would just set that flag in the bitstream but not change any defaults or validate that settings were legal.
__________________
Ben Waggoner
Principal Video Specialist, Amazon Prime Video

My Compression Book
benwaggoner is offline   Reply With Quote
Old 26th January 2022, 19:59   #18  |  Link
excellentswordfight
Lost my old account :(
 
Join Date: Jul 2017
Posts: 322
Quote:
Originally Posted by benwaggoner View Post
Level 4.1 can't do 2160p, so it would just error out. Main Tier Level 5.0 is the lowest that can support 2160p, and then only up to 32 fps IIRC. If you set --level 5.0, vbv-bufsize and vbv-maxrate should be automatically set to 25000 unless otherwise specified..
TS has issues when trying to encode 1080p, 2160p works fine apperently. Or did i miss something?
excellentswordfight is offline   Reply With Quote
Old 26th January 2022, 22:09   #19  |  Link
jriker1
Registered User
 
Join Date: Dec 2003
Posts: 485
Not done encoding yet, however I think ffmpeg is ignoring the high tier setting. At least this is part of the output I copied from the screen:

Press [q] to stop, [?] for help
x265 [info]: HEVC encoder version 3.5+21-8a15ef537
x265 [info]: build info [Windows][GCC 11.2.0][64 bit] 8bit+10bit+12bit
x265 [info]: using cpu capabilities: MMX2 SSE2Fast LZCNT SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
x265 [info]: Main profile, Level-5.1 (Main tier)
x265 [info]: Thread pool created using 8 threads
x265 [info]: Slices
jriker1 is offline   Reply With Quote
Old 27th January 2022, 01:31   #20  |  Link
benwaggoner
Moderator
 
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,752
Quote:
Originally Posted by excellentswordfight View Post
TS has issues when trying to encode 1080p, 2160p works fine apperently. Or did i miss something?
TS? Transport stream?
__________________
Ben Waggoner
Principal Video Specialist, Amazon Prime Video

My Compression Book
benwaggoner is offline   Reply With Quote
Reply

Tags
ffmpeg, h.265

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:04.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.