Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to encode 59.94fps y4m video? #252

Closed
birdie-github opened this issue Mar 14, 2023 · 31 comments · Fixed by #255
Closed

How to encode 59.94fps y4m video? #252

birdie-github opened this issue Mar 14, 2023 · 31 comments · Fixed by #255
Labels
inprogress The issue is already being worked on. library Concerns the VVenC library question Further information is requested

Comments

@birdie-github
Copy link

I don't understand how to encode 59.94fps y4m file:

Input #0, yuv4mpegpipe, from 'output.y4m':
  Duration: 00:03:26.41, start: 0.000000, bitrate: 1491503 kb/s
  Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p(tv, progressive), 1920x1080, SAR 1:1 DAR 16:9, 59.94 fps, 59.94 tbr, 59.94 tbn
$ vvencapp --preset slower --qp 24 --tickspersec 11771760 -i output.y4m --output=bit.266
vvencapp: Fraunhofer VVC Encoder ver. 1.7.0 [Linux][GCC 11.3.0][64 bit][SIMD=AVX2]
Parameter Check Error: TicksPerSecond should be a multiple of FrameRate/Framescale. Use 27000000 for NTSC content
@adamjw24
Copy link
Member

Don't use y4m, its a bad format and the world would be better off without it ;)

But jokes aside. How is 59.94 represented in a Y4M header? And what is this strange tickspersec? Why are you using 11771760?

@birdie-github
Copy link
Author

Don't use y4m, its a bad format and the world would be better off without it ;)

What should I pipe to vvenc then?

But jokes aside. How is 59.94 represented in a Y4M header? And what is this strange tickspersec? Why are you using 11771760?

I've shown you ffprobe output, I've no idea how to get this info for you. As for this huge number I found it here: facebookarchive/Flicks#3

@birdie-github
Copy link
Author

It would be great if https://github.com/fraunhoferhhi/vvenc/wiki/Usage contained an example how to prepare a video for transcoding in vvenc.

AFAIK y4m and yuv are the same format except the former includes a header with video parameters, while yuv is simply a raw format where you need to specify all the video parameters manually which is prone to errors.

@adamjw24
Copy link
Member

Don't use y4m, its a bad format and the world would be better off without it ;)

What should I pipe to vvenc then?

Just use raw yuv and specify the metadata manually using our syntax (i.e. --fps 60000/1001).

Or use proper transcoding:

But jokes aside. How is 59.94 represented in a Y4M header? And what is this strange tickspersec? Why are you using 11771760?

I've shown you ffprobe output, I've no idea how to get this info for you. As for this huge number I found it here: facebookarchive/Flicks#3

Lol, this doesn't mean nothing. For what I know, this might be ffmpeg using a default value. Try head -n 1 your_file.y4m or pipe_with_y4m | head -n 1.

@birdie-github
Copy link
Author

birdie-github commented Mar 14, 2023

The header for y4m is:

YUV4MPEG2 W1920 H1080 F19001:317 Ip A1:1 C420jpeg XYSCSS=420JPEG XCOLORRANGE=LIMITED
FRAME

@adamjw24
Copy link
Member

adamjw24 commented Mar 14, 2023

I see. 19001:317 is not the standard framerate used for 59.54. Please change it to 60000:1001. Than it should work just fine.

@birdie-github
Copy link
Author

Here's the last question: the source video is yuv420p. vvenc works with yuv420, right?

How should I go about converting yuv420p to yuv420?

@adamjw24
Copy link
Member

adamjw24 commented Mar 14, 2023

VVenCs yuv420 is FFmpegs yuv420p (and VVenC yuv420_10 is FFmpegs yuv420p10le). Don't worry about that, you're good here.

@birdie-github
Copy link
Author

I see. 19001:317 is not the standard framerate used for 59.54. Please change it to 60000:1001. Than it should work just fine.

Maybe you could fix this, please? Mustn't be too difficult. Lots of videos on the Internet use this frame rate.

It's up to you to decide :-)

@adamjw24
Copy link
Member

adamjw24 commented Mar 14, 2023

I've shown you ffprobe output, I've no idea how to get this info for you. As for this huge number I found it here: facebookarchive/Flicks#3

That's why you have an error. Because in your file 59.94 is represented as 19001:317, the 11771760 is not the common multiple for those. You have to fine the lowest common nominator for 19001 and 317 and use this as tickspersec. The 11771760 was designed for 60000:1001 as you can see in the link you provided.

@adamjw24
Copy link
Member

I see. 19001:317 is not the standard framerate used for 59.54. Please change it to 60000:1001. Than it should work just fine.

Maybe you could fix this, please? Mustn't be too difficult. Lots of videos on the Internet use this frame rate.

It's up to you to decide :-)

I actually think VVenC works just right here. If you are using funny (i.e. non-standard) frame rate representations, it's up to you to find proper parametrization. We might just look into letting the encoder find the lowest common nominator tho.

@adamjw24
Copy link
Member

Wait... no. Forget the lowest common nominator. I need to research more how the tickspersec works. For now, just use standard time representations...

@birdie-github
Copy link
Author

Meanwhile:

https://www.wolframalpha.com/input/?i=LCM%2819001%2C317%29

6023317

19001 is prime
317 is prime

@adamjw24
Copy link
Member

adamjw24 commented Mar 14, 2023

Did you try encoding with --tickspersec 6023317? Should work. Otherwise --tickspersec 19001 should also work.

@birdie-github
Copy link
Author

birdie-github commented Mar 14, 2023

vvencapp --preset slower --qp 24 --tickspersec 6023317 -i output.yuv --output=bit.266-test
vvencapp: Fraunhofer VVC Encoder ver. 1.7.0 [Linux][GCC 11.3.0][64 bit][SIMD=AVX2]
Parameter Check Error: TicksPerSecond should be a multiple of FrameRate/Framescale. Use 27000000 for NTSC content

The same error with 19001.

@adamjw24
Copy link
Member

And --tickspersec -1?

@birdie-github
Copy link
Author

-1 worked:

vvencapp --preset slower --qp 24 --tickspersec -1 -i output.yuv --output=bit.266-test
vvencapp: Fraunhofer VVC Encoder ver. 1.7.0 [Linux][GCC 11.3.0][64 bit][SIMD=AVX2]
Input     File : output.yuv
Bitstream File : bit.266-test
Real Format    : 1920x1080  yuv420p  60 Hz  SDR  12372 frames
               : encode 12372 frames 
Rate Control   : QP 24
CODING TOOL CFG: CTU128 QT44BTT3333332 IBD:1 SAO:1 ALF:1 (NonLinLuma:1 NonLinChr:1) CCALF:1 Tiles:1x1 Slices:1 WPP:0 WPP-Substreams:1 TMVP:1 DQ:1 SDH:0 CST:1 BDOF:1 DMVR:1 MTSImplicit:0 SBT:1 JCbCr:1 CabacInitPresent:0 AMVR:1 SMVD:1 LMCS:2 (Signal:SDR Opt:0) CIIP:1 MIP:1 AFFINE:1 (PROF:1, Type:1) MMVD:1 DisFracMMVD:1 SbTMVP:1 GPM:1 LFNST:1 MTS:1 (IntraCand:3) ISP:1 TS:2 TSLog2MaxSize:5 useChromaTS:0 BDPCM:2 IBC:2 BCW:2 
ENC. ALG. CFG: QPA:1 HAD:1 RDQ:1 RDQTS:1 ASR:1 MinSearchWindow:96 EDO:2 MCTF:2 BIM:1 
PRE-ANALYSIS CFG: STA:1 LeadFrames:0 TrailFrames:0 
FAST TOOL CFG: ECU:0 FEN:3 FDM:1 FastSearch:1 (SCC:2) LCTUFast:1 FastMrg:1 PBIntraFast:1 AMaxBT:0 FastQtBtEnc:1 ContentBasedFastQtbt:0 FastMIP:0 FastIntraTools:0 IntraEstDecBit:1 FastLocalDualTree:1 IntegerET:0 FastSubPel:0 ReduceFilterME:2 QtbttExtraFast:1 FastTTSplit:1 IBCFastMethod:1 FIM:0 ALFSpeed:0 QuantThr: 4 
RATE CONTROL CFG: RateControl:0 QP:24 LookAhead:0 
PARALLEL PROCESSING CFG: NumThreads:8 MaxParallelFrames:4 WppBitEqual:1 WF:0 

started @ Tue Mar 14 08:51:43 2023
Ctrl+C

@adamjw24
Copy link
Member

I see what happens. Apparently our y4m parses ignores fractional frame rates (thats why you see 60Hz). We'll fix that. Thanks.

@adamjw24
Copy link
Member

While we are at it, the informational header doesn't include framerate - would be great if you showed/included it.

It does. See the 60 Hz info.

@birdie-github
Copy link
Author

I hoped I'd deleted my comment fast enough you wouldn't see it. Sorry :-) Yeah, I noticed it a few seconds later.

@birdie-github birdie-github changed the title How to encode 59.94fps video? vvenc's y4m parses ignores fractional frame rates (Originally: How to encode 59.94fps video?) Mar 14, 2023
@lehmann-c
Copy link
Collaborator

lehmann-c commented Mar 14, 2023

Please don´t use '--tickspersec -1' as it will internally produce 60Hz, as -1 will use ticksPerFrame=1
Both suggestions from @adamjw24 are working properly:
--tickspersec 6023317
--tickspersec 19001

You wrote that it did not work for:
vvencapp --preset slower --qp 24 --tickspersec 6023317 -i output.yuv --output=bit.266-test

That failure is correct, as you didn´t use the y4m input file.
You used -i output.yuv without setting a framerate that fits your tickspersec.
Try:
vvencapp --preset slower --qp 24 --tickspersec 6023317 --fps 19001/317 -i output.yuv --output=bit.266-test

@birdie-github
Copy link
Author

vvencapp --preset slower --qp 24 --tickspersec 6023317 --fps 19001/317 -i output.yuv --output=bit.266-test

This works.

@adamjw24
Copy link
Member

Great. So that's resolved? Can the issue be closed?

@adamjw24 adamjw24 changed the title vvenc's y4m parses ignores fractional frame rates (Originally: How to encode 59.94fps video?) How to encode 59.94fps y4m video? Mar 14, 2023
@birdie-github
Copy link
Author

But the y4m parser doesn't work for this use case :-(

@adamjw24
Copy link
Member

adamjw24 commented Mar 14, 2023

It does. I was wrong, I misinterpreted the evidence you were presenting. Or does it not? Christian corrected me, saying that the y4m parser does indeed read fractional frame rates.

@birdie-github
Copy link
Author

Well,

vvencapp --preset slower --qp 24 -i output.y4m --output=bit.266-test
vvencapp: Fraunhofer VVC Encoder ver. 1.7.0 [Linux][GCC 11.3.0][64 bit][SIMD=AVX2]
Parameter Check Error: TicksPerSecond should be a multiple of FrameRate/Framescale. Use 27000000 for NTSC content

@adamjw24
Copy link
Member

And with --tickspersec 19001?

@birdie-github
Copy link
Author

This works

vvencapp --preset slower --qp 24 -i output.y4m --tickspersec 19001 --output=bit.266-test

But vvenc could really automate this, no? Since the file contains all the required info.

@adamjw24
Copy link
Member

We'll talk about that internally. Tickspersec is like a systems level setting that people might care about beyond the scope of the encoder internals - that why its an external option in the simple encoder. Our default value handles all standard non-integer frame rates, as uses eg in NTSC. If you are not using standard non-integer fps, you should really not be using fraction fps at all. So from my perspective the issue here is a non-standard fps you selected and we found a solution for that. The encoder might handle that better but that's really a very exotic use case, that we might just as well choose to ignore. In that sense I think the issue could be closed.

But stay tuned. The simple solution would be to set the tickspersec to the nominator of the fps value, but it would produce bitstreams possibly incompatible with many systems. I need to talk this through with someone who understands this.

@birdie-github
Copy link
Author

birdie-github commented Mar 14, 2023

Speaking of non-standard: this is what ESL CSGO shoots at. Hundreds of clips and videos.

@adamjw24 adamjw24 added question Further information is requested inprogress The issue is already being worked on. library Concerns the VVenC library labels Mar 14, 2023
lehmann-c added a commit to lehmann-c/vvenc that referenced this issue Mar 15, 2023
auto set ticks per second for non-standard frame rates
adamjw24 pushed a commit that referenced this issue Mar 15, 2023
…255)

* fixes #252
auto set ticks per second for non-standard frame rates

* using error instead of warning for wrong ticks/sec
@adamjw24
Copy link
Member

So we meet in the middle. It's still an error, but the verbose error message will tell you how to configure it properly for your data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
inprogress The issue is already being worked on. library Concerns the VVenC library question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants