PyAV icon indicating copy to clipboard operation
PyAV copied to clipboard

Added __set__ for duration property of Packet

Open idkosilov opened this issue 2 years ago • 2 comments

Overview

Currently, PyAV does not provide a straightforward way to modify the duration of packets in media files. This feature request proposes to add support for modifying duration of packets in PyAV.

Desired Behavior

PyAV should provide methods to modify duration of packets. Specifically:

A method to modify duration of packets, which can be useful for adjusting the playback speed of a video or audio file. A method to modify packet duration can be useful for adjusting timing or frame rate in a media file.

Example API

Here is an example API that demonstrates how PyAV could support modifying duration of packets:

for packet in input.demux(input_stream):
      packet.duration = int(packet.duration * packet.time_base / output_stream.time_base)
      packet.time_base = output_stream.time_base
      packet.dts = last_dts + packet.duration
      packet.pts = last_pts + packet.duration
      last_pts, last_dts = packet.pts, packet.dts
      packet.stream = output_stream
      output_container.mux(packet)

Additional context

Adding support for modifying duration in PyAV would make it easier for users to adjust the timing, playback speed, and other aspects of media files using Python.

idkosilov avatar Apr 27 '23 11:04 idkosilov

I would like for this to be tested before merging.

WyattBlue avatar Nov 06 '23 02:11 WyattBlue

Do you have a recommended way you'd like to test this? I didn't see any existing tests that would cover this well

daveisfera avatar Dec 07 '23 14:12 daveisfera

Too old.

WyattBlue avatar Mar 05 '24 06:03 WyattBlue

I still need this so if I rebase then can it be merged? Do you have a recommended way to test this?

daveisfera avatar Mar 05 '24 15:03 daveisfera

I'm carrying this patch and would like to be able to upgrade to 12.0 so can this be merged? Do you have a recommended way to test this?

daveisfera avatar Apr 26 '24 23:04 daveisfera