Skip to content

Default GOPSize of -1 means only one keyframe is ever published #54

@playertr

Description

@playertr

I think I've been affected by a bug that recently landed in Humble, during the upgrade from 1.0.1 to 3.0.2. This bug has resulted in only one keyframe being written by the FFMPEG transport plugin. As a result, if I instantiate a camera with:

    <param name="camera.image_raw.ffmpeg.encoder" value="hevc_nvenc" />
    <param name="camera.image_raw.ffmpeg.encoder_av_options" value="preset:ll,profile:main,crf:0" />

and then record two bags with:

ros2 bag record /camera_0/image_raw/ffmpeg -o bag1

# CTRL-C the first process

ros2 bag record /camera_0/image_raw/ffmpeg -o bag2

# CTRL-C the second process

Then the second bag will be impossible to decode because it consists only of P-frames, with no I-frames.

As far as I can tell, this is because the initialization of the encoder via parameters has recently changed as follows.

In ffmpeg_image_transport, the encoder's setGOPSize function is only called if the parameter is explicitly passed by the user:

encoder_.setGOPSize(v.get<int>());

In ffmpeg_encoder_decoder, GOPSize_ is initialized to -1:

https://github.com/ros-misc-utilities/ffmpeg_encoder_decoder/blob/f784f6d9eac4bf3302b66e11f38bc7ccb40a4a6c/include/ffmpeg_encoder_decoder/encoder.hpp#L384

Thus, the README is incorrect:

- ``gop_size``: The number of frames between keyframes. Default: 10.

Can you advise on whether this is a legit bug, or am I misreading the documentation?

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