cutcutcodec.core.io.read_ffmpeg.frame_dates
- cutcutcodec.core.io.read_ffmpeg.frame_dates(frame: Frame) tuple[Fraction, None | Fraction][source]
Return the accurate time interval of the given frame.
Parameters
- frameav.frame.Frame
The audio or video frame witch we extract the timing information.
Returns
- t_startFraction
The display time of the frame. for audio frame, it corressponds to the time of the first sample.
- t_endFraction or None
For audio frame only, the time to switch off the last sample. Return None for video frame.
Examples
>>> import av >>> from cutcutcodec.core.io.read_ffmpeg import frame_dates >>> with av.open("cutcutcodec/examples/video.mp4") as av_container: ... frame_dates(next(av_container.decode(av_container.streams.video[0]))) ... frame_dates(next(av_container.decode(av_container.streams.video[0]))) ... (Fraction(0, 1), None) (Fraction(1, 25), None) >>> with av.open("cutcutcodec/examples/audio_5.1_narration.oga") as av_container: ... frame_dates(next(av_container.decode(av_container.streams.audio[0]))) ... frame_dates(next(av_container.decode(av_container.streams.audio[0]))) ... (Fraction(0, 1), Fraction(4, 125)) (Fraction(4, 125), Fraction(8, 125)) >>>
Notes
For audio frame, include the duration of the last sample. For video frame, the duration of the frame is unknown.