The following is a natural way to code the start & stop time (or duration) options to specify the exact frame time:
from_frame = 0
to_frame = 100
fps = ff.probe.video_streams_basic(infile)[0]["frame_rate"]
ff.transcode(
infile,
outfile,
ss=from_frame / fps,
to=to_frame / fps,
overwrite=True,
show_log=True,
)
The frame_rate attribute is often returned as a fraction for video (e.g., 30000/1001), resulting in ss and to values to be in fractions as well. Stringifying a Fraction object yields a string of a format: f'{numerator}/{denominator}'. This format is not understood by FFmpeg.
The following is a natural way to code the start & stop time (or duration) options to specify the exact frame time:
The
frame_rateattribute is often returned as a fraction for video (e.g.,30000/1001), resulting inssandtovalues to be in fractions as well. Stringifying a Fraction object yields a string of a format:f'{numerator}/{denominator}'. This format is not understood by FFmpeg.