Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to change packet.duration. Why this property is read-only? #1121

Closed
idkosilov opened this issue Apr 27, 2023 · 1 comment · Fixed by #1399
Closed

Allow to change packet.duration. Why this property is read-only? #1121

idkosilov opened this issue Apr 27, 2023 · 1 comment · Fixed by #1399

Comments

@idkosilov
Copy link

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.

@lim1942
Copy link

lim1942 commented May 2, 2023

I wan`t to modify duration too. But the attribute of packet is not writable ....

@github-actions github-actions bot added the stale label Aug 31, 2023
@WyattBlue WyattBlue removed the stale label May 9, 2024
@WyattBlue WyattBlue reopened this May 9, 2024
@PyAV-Org PyAV-Org deleted a comment from github-actions bot May 9, 2024
@WyattBlue WyattBlue linked a pull request May 9, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants