Skip to content

Is it possible to create a REMUX with exact frame count output. #1165

@apiszcz

Description

@apiszcz

In the remuxing documentation example packets are used and skipped if no dts is available in the packet. Is it possible to create an output with the same number of frames as the input using the decode to frame method?

This produces a different size output file much smaller (50%) from the input.

fps = src_stream.average_rate
codec_name = src_stream.codec_context.name
out_stream = ovideo_container.add_stream(codec_name, rate=fps)
out_stream.width = src_stream.codec_context.width  # Set frame width to be the same as the width of the input stream
out_stream.height = src_stream.codec_context.height  # Set frame height to be the same as the height of the input
out_stream.pix_fmt = src_stream.codec_context.pix_fmt

for frame container.decode(video=0):
   .. other processing then
   output_encoded = out_stream.encode(out_frame)
   ovideo_container.mux(output_encoded)

Trying the following to set the parameters produces the following error.

out_stream = ovideo_container.add_stream(template=src_stream)

.
.
.
    out_packet = out_stream.encode(out_frame)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "av/stream.pyx", line 153, in av.stream.Stream.encode
  File "av/codec/context.pyx", line 490, in av.codec.context.CodecContext.encode
  File "av/frame.pyx", line 52, in av.frame.Frame._rebase_time

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