Skip to main content
Version: v5.9.0

Sequence change

Sequence change is a feature that allows on-the-fly resolution change in the input stream.  

Decoder ​

The Quadra decoder handles the sequence change automatically. The decoder detects the resolution change and reports the new resolution to upper layer (libxcoder).

The libxcoder handles this change by reallocating a data buffer based on the new picture size, it receives YUV data at the new resolution accordingly. 

Encoder ​

When receiving YUV frames at different resolutions within the sequence change scenario, the default behavior of all FFmpeg versions is to auto-scale to the original resolution and then pass them on to the encoder. In this case, the Quadra encoder would proceed as normal since the received picture size does not change. 

FFmpeg autoscale  ​

An output option autoscale is available (enabled by default), as a NETINT and FFmpeg patch (see References for details). If autoscale is disabled, FFmpeg won’t auto insert a scale filter in the filter graph to force scaling the whole decoded stream into the same size as that of the first frame. If noautoscale is used, then when a sequence change is detected nienc will close the current Quadra encoding session, and will then start a new one at the new resolution.

An example of disabling auto scaling is as follows: 

ffmpeg –hide_banner -vsync 0 -c:v h265_ni_quadra_dec -i sc.265 -noautoscale -c:v h264_ni_quadra_enc sc-265-no-autoscale.264 

The autoscale option is enabled by default so there is no need to specify it on the command line if its required to be enabled. If autoscale however needs to be disabled, then specify it as

-noautoscale

on the command line.

FFmpeg reinit_filter​

This option only applies to FFmpeg 7.1 or later

-reinit_filter is an FFmpeg input option that controls whether FFmpeg will reconfigure the filtergraph when a sequence change is detected. In FFmpeg 7.1, a known issue occurs when an input stream changes color_space or color_range while using HW frames: FFmpeg 7.1 detects these changes as sequence changes and attempts to reinitialize the filtergraph. Because HW frames cannot be reconfigured this way, the process fails. Since -reinit_filter defaults to 1, FFmpeg 7.1 automatically inserts filters even for color‑related changes, triggering the issue.

In earlier versions than FFmpeg 7.1, changes in color_space and color_range are not treated as sequence changes, so HW frame pipelines do not encounter this problem.

To avoid the issue in FFmpeg 7.1, it is needed to disable sequence‑change reinitialization for color‑space and color‑range changes by setting: -reinit_filter 0

An example of using this option is as follows: 

ffmpeg -force_nidec quadra -xcoder-params out=hw -reinit_filter 0 -i input_with_color_seq_change.mp4 -c:v h264_ni_quadra_enc -f null -

Given that the default value of this option is 1, it is recommended to use -reinit_filter 0 in FFmpeg 7.1 or later when processing with HW frames.

warning

When setting -reinit_filter 0, all sequence‑change reinitialization is disabled. This includes cases where the input resolution changes. Use this option only when such behavior is explicitly desired.

Reconfig Decoder PPU Output Resolution​

Quadra support reconfig ppu output resolution by adding new packet side data with a new header packet. This side data type is AV_PKT_DATA_PPU_CONFIG. When you want to reconfig the ppu output resolution, you can add the side data to the first packet which the input stream has a new resolution. And then the decoder can output the new resolution which you reconfiged.

This has a struct to reconfig the ppu resolution. It is AVNIPpuConfig.

Parameters:

The following are the AVNIPpuConfig parameters:

out_enabled:

This is enable ppu reconfig. It default to 0. If enabled, it must be set 1.

Default: 0

ppu_w ppu_h:

This is for reconfig the ppu output resolution. You can set the ppu_w to reconfig ppu output width, and ppu_h to reconfig ppu output height.

note

This feature only supports h264/h265.