I'm trying to cut out a fragment from video with the given start and end frames indexes or theirs timestamps (preferably frame indexes). So far I've found this Q but it takes floats and convert them to integers hence the output video has inaccurate frames
this is a sample of what I've tried which gives me inaccurate output video
def extract_fragment(input_path, output_path):
start_time = 3.453453
end_time = 6.8768678
ffmpeg_extract_subclip(
filename=input_path,
t1=start_time,
t2=end_time,
targetname=output_path,
)
And I also tried to use ffmpeg directly
with duration
subprocess.call(
[
"ffmpeg",
"-start_at_zero",
"-copyts",
"-ss",
start_time,
"-t",
end_time - start_time,
"-i",
f"{path_to_video}",
"-c",
"copy",
f"{output_video_path}",
]
)
subprocess.call(
[
"ffmpeg",
"-y",
"-ss",
str(start_time),
"-i",
path_to_video,
"-t",
str(end_time),
"-map",
"0",
"-vcodec",
"copy",
"-acodec",
"copy",
output_video_path,
]
)