PyAV icon indicating copy to clipboard operation
PyAV copied to clipboard

Add rate and framerate properties to VideoStream (fixes: #1005)

Open uvjustin opened this issue 3 years ago • 3 comments

Fixes the regression introduced by #910

This PR fixes the issue by adding properties that point directly to the underlying AVStream's avg_frame_rate. It doesn't set the rate on the new codec_context, but that doesn't appear to be necessary.

uvjustin avatar Jul 07 '22 05:07 uvjustin

I'm having another look at this, and I'm really confused. We already have Stream.average_rate, which does the exact same thing but with a more explicit name. Why do we need two additional accessors?

If the only reason is due to the historic confusion between stream and codec_context properties I'd actually favor going in the opposite direction and make both Stream.__getattr__ and Stream.__setattr__ raise an AttributeError for rate and framerate.

PyAV 10.0 is going to have some breaking changes, might as well start cleaning up..

jlaine avatar Jul 18 '22 15:07 jlaine

I see your point and that makes sense. We should just probably remove these accessors, but we should be explicit that it is a breaking change.

uvjustin avatar Jul 18 '22 16:07 uvjustin

I guess a follow on question is what to do with AudioStream. The actual rate field for an audio stream is stored in sample_rate of the AVCodecParameters. We should probably get rid of the rate passthrough and enforce sample_rate since it is a more explicit name as well.

uvjustin avatar Jul 18 '22 16:07 uvjustin

Closing in favour of #1036

jlaine avatar Oct 17 '22 12:10 jlaine