Skip to content
This repository was archived by the owner on Jun 10, 2024. It is now read-only.
This repository was archived by the owner on Jun 10, 2024. It is now read-only.

Incorrect encoding bit rate #409

@Renzzauw

Description

@Renzzauw

Hi!

I'm initializing the VPF encoder as follows:

output_width, output_height = output_resolution
enc_args = {
    'codec': 'h264',
    'preset': 'P4',
    's': f"{str(output_width)}x{str(output_height)}",
    'tuning_info': 'high_quality',
    'bitrate': '10M',
    'profile': 'high',
    'cbr': '1',
    'fps': fps,
}

video_encoder = nvc.PyNvEncoder(enc_args,
                                gpu_id=gpu_device,
                                format=nvc.PixelFormat.NV12)

After some experimenting with FFmpeg & hwaccel CUDA I came to the encoding presets as defined above to be suitable for my application. However, when I encode a video using these settings & mux to an .mp4 container, I noticed when I use a tool like mediainfo the bit rate is far from the one I defined:

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L3.1
Format settings                          : CABAC / 3 Ref Frames
Format settings, CABAC                   : Yes
Format settings, Reference frames        : 3 frames
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 7 s 942 ms
Bit rate                                 : 2 233 kb/s <------------------
Width                                    : 1 280 pixels
Height                                   : 720 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 29.970 (29970/1000) FPS
Original frame rate                      : 29.970 (30000/1001) FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.081
Stream size                              : 2.11 MiB (87%)
Codec configuration box                  : avcC

I was wondering, does my specified bit rate get overwritten when using a preset? Is this intended behavior? I also tried passing default as preset, and the bit rate of the output video is around (but not exactly) the 10 I provided. So is this a bug or am I using the encoder incorrectly?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions