April 22, 2020

Handling fuzzy FPS to get proper bitrate output

Nimble Live Transcoder allows creating transcoding scenarios with various transformations, including control over output bitrate. Usually you have some input stream with expected parameters like frame rate (FPS) and resolution and want to create one or more output with certain bitrate.

Normally you can define output bitrate using various parameters of encoder libraries, like it's described for x264 bitrate, constant x264 bitrate, NVENC bitrate and QuickSync bitrate setup in respective articles.

However, some sources may produce streams with uncertain frame rate. For example, mobile encoders may produce variable bitrate so when your users are streaming with apps like Larix Broadcaster you may get streams with unexpected FPS. As a result, if you ingest such fuzzy stream into a transcoding scenario, the encoder may produce the unexpected bitrate - higher or lower than you've defined in encoder settings.

You can use two approaches to handle this: by adding FPS filter or by defining FPS numerator and denominator parameters for encoder.

Option A: Add FPS filter

The best way to handle this is to set some definite value for FPS using a custom "fps" filter.
If you expect your users to stream with framerate around 25-30 FPS, you can set filter to 30 FPS. If you need a better framerate, just set it to proper value like 60 FPS. This filter uses optimized algorithm to insert extra duplicate frames, and encoders are optimized to process such repeating frames, so this will not add any processing overhead.

A.1 Add video_filter_reset_by_pts_enabled parameter to config

Before setting a filter, add video_filter_reset_by_pts_enabled = true parameter into your nimble.conf. With FPS filter, if you have MPEG-TS input (e.g. if you use SRT) and if input gets time gap, the output may hang up, so this parameter avoids that.

A.2 Add filter

Here's how you add the filter into transcoding scenario. Open your scenario and drag a Custom filter onto a pipeline. 

Then connect it to other filters and the encoder.

Now if you have your bitrate set up in the encoder element, you'll get the output bitrate which you've defined there after you save the scenario.

Option B: Using FPS numerator and denominator

Another option is to set output FPS numerator and denominator. All Transcoder encoders' libraries support them, so just set them as part of parameters: fps_n for numerator and fps_d for denominator. These parameters will "introduce" the encoder to the numbers which it will use for further bitrate calculation.

If you need 30 FPS, use fps_n=30 and fps_d=1, as shown below. The same formula applies to 60 FPS: use fps_n=60 and fps_d=1.

In this example, once you save encoder setting and then save scenario, the encoder will be likely to produce 1Mbps output based on expected frame rate of 30 FPS.

Let us know if you have any questions about these approaches.

Related documentation

Nimble Live Transcoder, Live Transcoder documentation reference,

No comments:

Post a Comment

If you face any specific issue or want to ask some question to our team,

This will give much faster and precise response.
Thank you.

Note: Only a member of this blog may post a comment.