-
Notifications
You must be signed in to change notification settings - Fork 176
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
Non Integer Frame Rate Support #1474
Comments
I'd like to put in a vote on the webhook spec for representing the fraction as a two-element tuple rather than an additional {
"profiles": [
{
"name": "test_stream_29.97fps",
"width": 1280,
"height": 720,
"bitrate": 4000000,
"fps": [30000, 1001]
},
{
"name": "test_stream_30fps",
"width": 1280,
"height": 720,
"bitrate": 4000000,
"fps": 30
}
]
} Bit more terse and readable IMO. |
The trouble is, this makes it more difficult to statically define the JSON schema to generate de/serializers. In googling around how to do this for golang, the consensus is basically "this is bad practice; don't do it." Eg: https://medium.com/@nate510/dynamic-json-umarshalling-in-go-88095561d6a0 |
AbstractCurrently go-livepeer supports transcoding videos to integer framerates. This is a proposal to add support for arbitrary non-integer framerates in the output video profiles. MotivationSome broadcasting standards (NTSC/ATSC) work on esoteric non-int framerates like 29.97 etc. As these standards are still widely used, users want the ability to transcode videos to non-int framerates through go-livepeer. Proposed Solution
Implementation Tasks and ConsiderationsLPMS ChangesCgoFFmpeg uses a custom rolled rational datatype (AVRational) to support non-integer framerates. The Cgo code in LPMS represents fps as an AVRational output parameter, so no changes needed here. VideoProfileThe VideoProfile struct uses a TranscodingThe transcoder module initializes the FPS ffmpeg filter using a filtergraph string with a hardcoded denominator. We can change it to use the denominator field we added in VideoProfile. Here we also set the output parameters passed to the Cgo module which represent fps as a rational datatype. Currently we're hardcoding the denominator, but can trivially fix it to use our new field. ProtobufModify the VideoProfile protobuf struct to add a new unsigned int field for the FPS denominator. The changes will mirror those done in the LPMS VideoProfile struct. Webhook ConfigurabilityWe want to configure the output videoprofile using auth webhook as well. To accomplish this we can modify the webhook json response to send the FPS denominator as a separate field. Pixel calculations and other usesThe FPS value is used at some other places like counting the output pixels and cost calcuations. We can find all such uses and ensure the correct value (num/den) is used everywhere. We'll also need to find all the places the VideoProfile structure is converted between the Go/Json/Protobuf types and ensure that the denominator is being moved as well. Testing Tasks and ConsiderationsAdd unit tests to fully cover the new code paths added to support non-integer framerates. Known UnknownsAlternativesWe could've modified the VideoProfile structure by extending the existing It might look much cleaner but we would've lost backwards compatibility, needed changes almost everywhere the structure is used and also would have had a hard time supporting the protobuf/json variants. Additional Context |
This is great.
Yep. Perhaps this only needs to occur at the very last step prior to invoking the Cgo transcoder, eg somewhere in ffmpeg.go . This allows us to safely propagate an uninitialized / zero-value
This PR might make things easier, since it will accommodate standalone T and combined OT with the same code: 0e1902b . Will wrap it up soon so you can build off it. For the webhook: here is the response struct and the conversion procedure from JSON to VideoProfile.
Technically, since the Related, another concern that wasn't discussed here is back compatibility. At the outset, most orchestrators will not update immediately. So it's worth considering this: identify whether fractional framerates are required for the current job, and to identify (or error out on) orchestrators that haven't yet upgraded to support the feature. This allows us to use older orchestrators for jobs that don't require fractional framerates (which will be the majority of jobs). Ideally, this is something that's taken care of by a capability discovery scheme, but it is possible that capability discovery won't be ready by the time this is complete. An interim solution could follow the pattern in #1439 ; eg adding a |
TODO:
Notes:
fps_den
field (rational number representation)The text was updated successfully, but these errors were encountered: