PySceneDetect icon indicating copy to clipboard operation
PySceneDetect copied to clipboard

can`t save_images in scenedetect

Open Vsevosemnog opened this issue 2 years ago • 6 comments

I have a scene list

[(00:18:17.467 [frame=32924, fps=30.000], 00:19:17.467 [frame=34724, fps=30.000]), (00:47:14.200 [frame=85026, fps=30.000], 00:48:14.200 [frame=86826, fps=30.000]), (00:48:14.200 [frame=86826, fps=30.000], 00:49:14.200 [frame=88626, fps=30.000]), (00:49:14.200 [frame=88626, fps=30.000], 00:50:14.200 [frame=90426, fps=30.000]), (00:50:14.200 [frame=90426, fps=30.000], 00:51:14.200 [frame=92226, fps=30.000]), (00:51:43.333 [frame=93100, fps=30.000], 00:52:43.333 [frame=94900, fps=30.000]), (00:52:43.333 [frame=94900, fps=30.000], 00:52:48.533 [frame=95056, fps=30.000]), (00:59:41.667 [frame=107450, fps=30.000], 01:00:36.467 [frame=109094, fps=30.000]), (01:00:36.467 [frame=109094, fps=30.000], 01:01:36.467 [frame=110894, fps=30.000]), (01:01:36.467 [frame=110894, fps=30.000], 01:02:36.467 [frame=112694, fps=30.000]), (01:02:52.933 [frame=113188, fps=30.000], 01:03:52.933 [frame=114988, fps=30.000]), (01:04:17.067 [frame=115712, fps=30.000], 01:05:17.067 [frame=117512, fps=30.000]), (01:05:17.067 [frame=117512, fps=30.000], 01:06:17.067 [frame=119312, fps=30.000])]

I try to save some screenshots from scenes to file but i get error

help_vid = open_video(clip_path)
write_scene_list_html(output_html_filename="%s_before_concat_list.html" % clip_path, scene_list=output_scene)
save_images(video=help_vid,scene_list=output_scene, num_images = 5, image_name_template="%s_help_$SCENE_NUMBER-$IMAGE_NUMBER.mp4"%clip_path , width=200, height=200)

image Could you please help, cant understand what ive done wrong

If this is just a warning how to ignore it and continue my script?

Vsevosemnog avatar Aug 21 '23 20:08 Vsevosemnog

This error is indicating that decoding the desired frame of the video was not successful. The save_images function seeks to the desired frame to pull as an image here and then calls the read function to decode the desired frame in the next line. It's not clear which backend you are using, but you can see the docstring for the read function when using the OpenCV backend (the default backend) that it is supposed to return a decoded numpy array and a boolean. In cases in which the decoding is not successful, then just a boolean is returned. This would cause the error that you see here.

Does this happen with other videos, or is it specific to one video?

wjs018 avatar Aug 21 '23 21:08 wjs018

yes, this happens to other videos as well

is there any way to skip corrupted frame during image_saving (working of function save_images)? in order to save all other "good" frames

Vsevosemnog avatar Aug 22 '23 02:08 Vsevosemnog

Does the issue still happen once you re-encode (or re-mux) the input video? The OpenCV backend tries to recover from this gracefully, so I assume seeking isn't happening correctly for this video.

As in #345, do the other videos this happens with also have trouble seeking?

Breakthrough avatar Aug 22 '23 22:08 Breakthrough

Could you please help me with this error FrameTimecode instances require equal framerate for addition

Vsevosemnog avatar Aug 28 '23 10:08 Vsevosemnog

Could anyone give me the solution? I faced the same error

KerolosAtef avatar Sep 03 '23 23:09 KerolosAtef

@KerolosAtef Can you try the PyAV backend (or MoviePy)? Otherwise you may have to re-encode / re-mux the source material first. Can you provide a sample of a clip that causes this error?

If anyone can provide a reproduction of the issue, that would be very helpful.


@Vsevosemnog can you provide some more context in a new issue/discussion? Thanks!

Breakthrough avatar Sep 04 '23 01:09 Breakthrough

Closing this issue due to lack of context, feel free to re-open or file a new one if this still occurs.

Breakthrough avatar Apr 20 '24 01:04 Breakthrough