fraunhoferhhi / vvenc

VVenC, the Fraunhofer Versatile Video Encoder
https://www.hhi.fraunhofer.de/en/departments/vca/technologies-and-solutions/h266-vvc.html
BSD 3-Clause Clear License
942 stars 170 forks source link

Buffer underflow when muxing #384

Closed thx4ever closed 4 months ago

thx4ever commented 4 months ago

Hi, i encoded a file and when mux to MPEG-TS container it have many buffer underflows

examples 0 - Multiplexing access unit 500 message OK M104:Video EB underflow at pack 4945 by 18234 bytes message ERROR buffer underflow

0 - Multiplexing access unit 500 0 - Multiplexing access unit 1000 M104:Video EB underflow at pack 4945 by 18234 bytes M104:Video EB underflow at pack 5049 by 47364 bytes 0 - Multiplexing access unit 9000 M104:Video EB underflow at pack 5318 by 17199 bytes M104:Video EB underflow at pack 5682 by 558 bytes M104:Video EB underflow at pack 5706 by 2437 bytes 0 - Multiplexing access unit 9500 M104:Video EB underflow at pack 5919 by 1751 bytes M104:Video EB underflow at pack 5949 by 11102 bytes M104:Video EB underflow at pack 6013 by 13293 bytes M104:Video EB underflow at pack 6089 by 11910 bytes M104:Video EB underflow at pack 6157 by 1358 bytes M104:Video EB underflow at pack 6166 by 622 bytes M104:Video EB underflow at pack 6173 by 312 bytes M104:Video EB underflow at pack 6176 by 1570 bytes M104:Video EB underflow at pack 6186 by 352 bytes M104:Video EB underflow at pack 6223 by 3568 bytes M104:Video EB underflow at pack 6254 by 1554 bytes 0 - Multiplexing access unit 10000

The content is encode with TargetBitrate 2 pass VBR, when encoding with CQP or CQF no buffer underflows

1pass cmd

ffmpeg -hide_banner -v error -i 02125.m2ts -f yuv4mpegpipe - | vvencFFapp --y4m 1 --TargetBitrate 1M --CTUSize 64 --Threads 36 --Tiles 2x2 -i - -b C:\Users\thx4ever\Desktop\teste.266 --Verbosity verbose --Sdr sdr_709 --IntraPeriod 240 --Passes 2 --Pass 1 --RCStatsFile teste_1pass.json --MTProfile 0

2pass cmd

ffmpeg -hide_banner -v error -i 02125.m2ts -f yuv4mpegpipe - | vvencFFapp --y4m 1 --TargetBitrate 1M --CTUSize 64 --Threads 36 --Tiles 2x2 -i - -b C:\Users\thx4ever\Desktop\teste.266 --Verbosity info --Sdr sdr_709 --IntraPeriod 240 --Passes 2 --Pass 2 --RCStatsFile teste_1pass.json --MTProfile 0

jungleboynx commented 4 months ago

Edit out a sample and upload it somewhere and send a link to it.

Donald Graft has a DGSplit tool for editing video files under Windows. Scroll down to the section "Tools and Utilities" and you'll find DGSplit just below. https://www.rationalqm.us/mine.html#tools You only need to edit maybe the first 10 seconds at most.

I've not read of any tools that support VVC in a TS container - maybe I'm wrong. This could be a similar problem to the other day where someone was using ffmpeg to create VVC inside a mkv container but it didn't work as mkv doesn't support VVC yet. The only muxing tool that supports VVC is currently mp4box and ffmpeg (creating mp4).

thx4ever commented 4 months ago

Edit out a sample and upload it somewhere and send a link to it.

Donald Graft has a DGSplit tool for editing video files under Windows. Scroll down to the section "Tools and Utilities" and you'll find DGSplit just below. https://www.rationalqm.us/mine.html#tools You only need to edit maybe the first 10 seconds at most.

I've not read of any tools that support VVC in a TS container - maybe I'm wrong. This could be a similar problem to the other day where someone was using ffmpeg to create VVC inside a mkv container but it didn't work as mkv doesn't support VVC yet. The only muxing tool that supports VVC is currently mp4box and ffmpeg (creating mp4).

Made another sample with 11sec video and here its the output

0 - Multiplexing access unit 500 0 - Multiplexing access unit 1000 0 - Multiplexing access unit 1500 0 - Multiplexing access unit 2000 0 - Multiplexing access unit 2500 0 - Multiplexing access unit 3000 0 - Multiplexing access unit 3500 0 - Multiplexing access unit 4000 0 - Multiplexing access unit 4500 0 - Multiplexing access unit 5000 M104:Video EB underflow at pack 3771 by 37764 bytes M104:Video EB underflow at pack 3984 by 20778 bytes 0 - Multiplexing access unit 5500 M104:Video EB underflow at pack 4103 by 12586 bytes M104:Video EB underflow at pack 4175 by 6669 bytes M104:Video EB underflow at pack 4213 by 3524 bytes M104:Video EB underflow at pack 4236 by 1478 bytes M104:Video EB underflow at pack 4246 by 1513 bytes M104:Video EB underflow at pack 4256 by 3378 bytes M104:Video EB underflow at pack 4276 by 1433 bytes M104:Video EB underflow at pack 4285 by 1376 bytes M104:Video EB underflow at pack 4294 by 5671 bytes M104:Video EB underflow at pack 4328 by 2848 bytes M104:Video EB underflow at pack 4345 by 1203 bytes M104:Video EB underflow at pack 4353 by 1059 bytes M104:Video EB underflow at pack 4360 by 2600 bytes M104:Video EB underflow at pack 4380 by 976 bytes M104:Video EB underflow at pack 4387 by 864 bytes M104:Video EB underflow at pack 4393 by 9087 bytes M104:Video EB underflow at pack 4444 by 4978 bytes M104:Video EB underflow at pack 4475 by 2214 bytes M104:Video EB underflow at pack 4489 by 744 bytes M104:Video EB underflow at pack 4495 by 733 bytes M104:Video EB underflow at pack 4500 by 2306 bytes M104:Video EB underflow at pack 4514 by 707 bytes M104:Video EB underflow at pack 4519 by 674 bytes M104:Video EB underflow at pack 4530 by 2975 bytes 0 - Multiplexing access unit 6000 M104:Video EB underflow at pack 4743 by 43444 bytes M104:Video EB underflow at pack 4987 by 13095 bytes 0 - Multiplexing access unit 6500 M104:Video EB underflow at pack 5062 by 10574 bytes M104:Video EB underflow at pack 5123 by 6044 bytes M104:Video EB underflow at pack 5157 by 1524 bytes M104:Video EB underflow at pack 5167 by 409 bytes M104:Video EB underflow at pack 5173 by 499 bytes M104:Video EB underflow at pack 5177 by 1528 bytes M104:Video EB underflow at pack 5187 by 445 bytes M104:Video EB underflow at pack 5191 by 448 bytes M104:Video EB underflow at pack 5195 by 4724 bytes M104:Video EB underflow at pack 5222 by 1094 bytes M104:Video EB underflow at pack 5229 by 345 bytes M104:Video EB underflow at pack 5232 by 273 bytes M104:Video EB underflow at pack 5235 by 812 bytes M104:Video EB underflow at pack 5242 by 203 bytes M104:Video EB underflow at pack 5246 by 240 bytes M104:Video EB underflow at pack 5259 by 1952 bytes 0 - Multiplexing access unit 7000 0 - Multiplexing access unit 7500

I dont have used ffmpeg to mux i have retail tool to mux the bitstreams, it fully support the MPEG-TS container format, i can mux with mp4box but in MPEG-TS i get buffer underflow, it mux successfully but when play it stuttering

samples.zip

When used QP or CQF it works normal

0 - Multiplexing access unit 500 0 - Multiplexing access unit 1000 0 - Multiplexing access unit 1500 0 - Multiplexing access unit 2000 0 - Multiplexing access unit 2500 0 - Multiplexing access unit 3000 0 - Multiplexing access unit 3500 0 - Multiplexing access unit 4000 0 - Multiplexing access unit 4500 0 - Multiplexing access unit 5000 0 - Multiplexing access unit 5500 0 - Multiplexing access unit 6000 0 - Multiplexing access unit 6500 0 - Multiplexing access unit 7000 0 - Multiplexing access unit 7500 0 - Multiplexing access unit 8000 0 - Multiplexing access unit 8500 0 - Multiplexing access unit 9000 0 - Multiplexing access unit 9500 0 - Multiplexing access unit 10000 0 - Multiplexing access unit 10500 0 - Multiplexing access unit 11000 0 - Multiplexing access unit 11500 0 - Multiplexing access unit 12000 0 - Multiplexing access unit 12500 0 - Multiplexing access unit 13000 0 - Multiplexing access unit 13500 0 - Multiplexing access unit 14000 0 - Multiplexing access unit 14500 0 - Multiplexing access unit 15000 0 - Multiplexing access unit 15500 0 - Multiplexing access unit 16000 0 - Multiplexing access unit 16500 0 - Multiplexing access unit 17000 0 - Multiplexing access unit 17500 0 - Multiplexing access unit 18000 0 - Multiplexing access unit 18500 0 - Multiplexing access unit 19000 0 - Multiplexing access unit 19500 0 - Multiplexing access unit 20000 0 - Multiplexing access unit 20500 0 - Multiplexing access unit 21000 0 - Multiplexing access unit 21500 0 - Multiplexing access unit 22000 0 - Multiplexing access unit 22500 0 - Multiplexing access unit 23000 0 - Multiplexing access unit 23500 0 - Multiplexing access unit 24000 0 - Multiplexing access unit 24500 0 - Multiplexing access unit 25000 0 - Multiplexing access unit 25500 0 - Multiplexing access unit 26000 0 - Multiplexing access unit 26500 0 - Multiplexing access unit 27000 0 - Multiplexing access unit 27500 0 - Multiplexing access unit 28000 0 - Multiplexing access unit 28500 0 - Multiplexing access unit 29000 0 - Multiplexing access unit 29500 0 - Multiplexing access unit 30000 0 - Multiplexing access unit 30500 0 - Multiplexing access unit 31000 0 - Multiplexing access unit 31500 0 - Multiplexing access unit 32000 0 - Multiplexing access unit 32500 0 - Multiplexing access unit 33000 0 - Multiplexing access unit 33500 0 - Multiplexing access unit 34000 0 - Multiplexing access unit 34500 0 - Multiplexing access unit 35000 0 - Multiplexing access unit 35500 0 - Multiplexing access unit 36000 0 - Multiplexing access unit 36500 0 - Multiplexing access unit 37000 0 - Multiplexing access unit 37500 0 - Multiplexing access unit 38000 0 - Multiplexing access unit 38500 0 - Multiplexing access unit 39000 0 - Multiplexing access unit 39500 0 - Multiplexing access unit 40000 0 - Multiplexing access unit 40500 0 - Multiplexing access unit 41000 0 - Multiplexing access unit 41500 0 - Multiplexing access unit 42000 0 - Multiplexing access unit 42500 0 - Multiplexing access unit 43000 0 - Multiplexing access unit 43500 0 - Multiplexing access unit 44000 0 - Multiplexing access unit 44500 0 - Multiplexing access unit 45000 0 - Multiplexing access unit 45500 0 - Multiplexing access unit 46000 0 - Multiplexing access unit 46500 0 - Multiplexing access unit 47000 0 - Multiplexing access unit 47500 0 - Multiplexing access unit 48000 0 - Multiplexing access unit 48500 0 - Multiplexing access unit 49000 0 - Multiplexing access unit 49500 0 - Multiplexing access unit 50000 0 - Multiplexing access unit 50500 0 - Multiplexing access unit 51000 0 - Multiplexing access unit 51500 0 - Multiplexing access unit 52000 0 - Multiplexing access unit 52500 0 - Multiplexing access unit 53000 0 - Multiplexing access unit 53500 0 - Multiplexing access unit 54000 0 - Multiplexing access unit 54500 0 - Multiplexing access unit 55000 0 - Multiplexing access unit 55500 0 - Multiplexing access unit 56000 0 - Multiplexing access unit 56500 0 - Multiplexing access unit 57000 0 - Multiplexing access unit 57500 0 - Multiplexing access unit 58000 0 - Multiplexing access unit 58500 0 - Multiplexing access unit 59000 0 - Multiplexing access unit 59500 0 - Multiplexing access unit 60000 0 - Multiplexing access unit 60500 0 - Multiplexing access unit 61000 0 - Multiplexing access unit 61500 0 - Multiplexing access unit 62000 0 - Multiplexing access unit 62500 0 - Multiplexing access unit 63000 0 - Multiplexing access unit 63500 0 - Multiplexing access unit 64000 0 - Multiplexing access unit 64500 0 - Multiplexing access unit 65000 0 - Multiplexing access unit 65500 0 - Multiplexing access unit 66000 0 - Multiplexing access unit 66500 0 - Multiplexing access unit 67000 0 - Multiplexing access unit 67500 0 - Multiplexing access unit 68000 0 - Multiplexing access unit 68500 0 - Multiplexing access unit 69000 0 - Multiplexing access unit 69500 0 - Multiplexing access unit 70000 0 - Multiplexing access unit 70500 0 - Multiplexing access unit 71000 0 - Multiplexing access unit 71500 0 - Multiplexing access unit 72000 0 - Multiplexing access unit 72500 0 - Multiplexing access unit 73000 0 - Multiplexing access unit 73500 0 - Multiplexing access unit 74000 0 - Multiplexing access unit 74500 0 - Multiplexing access unit 75000 0 - Multiplexing access unit 75500 0 - Multiplexing access unit 76000 0 - Multiplexing access unit 76500 0 - Multiplexing access unit 77000 0 - Multiplexing access unit 77500 0 - Multiplexing access unit 78000 0 - Multiplexing access unit 78500 0 - Multiplexing access unit 79000 0 - Multiplexing access unit 79500 0 - Multiplexing access unit 80000 0 - Multiplexing access unit 80500 0 - Multiplexing access unit 81000 0 - Multiplexing access unit 81500 0 - Multiplexing access unit 82000 0 - Multiplexing access unit 82500 0 - Multiplexing access unit 83000 0 - Multiplexing access unit 83500 0 - Multiplexing access unit 84000 0 - Multiplexing access unit 84500 0 - Multiplexing access unit 85000 0 - Multiplexing access unit 85500 0 - Multiplexing access unit 86000 0 - Multiplexing access unit 86500 0 - Multiplexing access unit 87000 0 - Multiplexing access unit 87500 0 - Multiplexing access unit 88000 0 - Multiplexing access unit 88500 0 - Multiplexing access unit 89000 0 - Multiplexing access unit 89500 0 - Multiplexing access unit 90000 0 - Multiplexing access unit 90500 0 - Multiplexing access unit 91000 0 - Multiplexing access unit 91500 0 - Multiplexing access unit 92000 0 - Multiplexing access unit 92500 0 - Multiplexing access unit 93000 0 - Multiplexing access unit 93500 0 - Multiplexing access unit 94000 0 - Multiplexing access unit 94500

Done successfully!

samples_mux_QP.zip

adamjw24 commented 4 months ago

I think the issue is that VVenC does not support CBR, non of the RC modes does it. 1pRC probably gives the most stable rate, but still no hard on constraints on producing something resembling CBR are there.

The fact that it works with CQ and CQF is just a coincidence specific to your content, but would fail on other content.

TLDR: VVenC does not support CBR.

jungleboynx commented 4 months ago

Your teste,266 sample plays ok once it's muxed into mp4 Obviously the teste.ts sample plays back staggered fashion. It's best to ask the author of tsMuxer when or if he intends to support h266/VVC https://www.videohelp.com/software/tsMuxeR

jungleboynx commented 4 months ago

It's possible to create ts format using the gpac tool. The old mp42ts tools is now deprecated. First mux the 266 file into mp4 using mp4box mp4box -add teste.266 teste.mp4

Then use gpac to create ts using gpac -i teste.mp4 -o res/live.m3u8:profile=live:muxtype=ts A sub folder res is created containing teste_dash1.ts and live.m3u8 and live_1.m3u8

gpac displays this message: [Dasher] First CTS 15015 in segment 1 drifting by 0.625625 (more than half a segment duration) from segment time, consider reencoding or using segment timeline [Dasher] Changing HLS target duration from 1 to 10, either increase the segment duration or re-encode the content

The teste_dash1.ts plays ok with mpv (with Fraunhofer's VVdeC enabled) without stuttering.

Gpac information: https://github.com/gpac/gpac/wiki/hls