PyAV
PyAV copied to clipboard
Allow setting ticks_per_frame
CodecContext.ticks_per_frame is a read-only property, hardcoded to 1 when adding a new stream:
>>> output = av.open("out.mp4", 'w')
>>> stream = output.add_stream('h264', 24)
>>> stream.ticks_per_frame
1
>>> stream.ticks_per_frame = 2
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
...
AttributeError: attribute 'ticks_per_frame' of 'av.codec.context.CodecContext' objects is not writable
It should be settable, most notably H.264/MPEG-2 set it to 2.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
We seem to have two contradictory requests here. PR #790 advocates changing the way this member is set, but not exposing it.
@rawler would making ticks_per_frame writable solve your issue too?
Writeable would solve, but it would require a user of PyAV to be intimately familiar with these settings or one might get surprising results. libvpx-vp9, for example, seem to use this value in the bandwidth-calculations (how much time has passed between frames), so not explicitly setting ticks_per_frame might break bandwidth-control quite badly. (IIRC, this is how we discovered the need to set it)
I'd argue that setting ticks_per_frame automatically qualifies the user as an "advanced" user. I've never once done this myself :)
Another thing that worries me is that I can't find any code in the FFmpeg CLI that sets "ticks_per_frame" outside the codecs and avformat_transfer_internal_stream_timing_info. Try grepping for "ticks_per_frame = ".
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.