Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while extracting the frames for some videos #16

Open
aminebdj opened this issue Jul 15, 2024 · 3 comments
Open

Error while extracting the frames for some videos #16

aminebdj opened this issue Jul 15, 2024 · 3 comments

Comments

@aminebdj
Copy link

Dear authors,

Thanks a lot for your work,

I am facing some issues while extracting some videos that are downloaded. I am getting the following error.

File "<path>/DriveAGI/opendv/utils/frame_extraction.py", line 41, in extract_frames
    cv2_extract_frames(video_path, output_dir, fps, discard_begin, discard_end, exception_file)
  File "<path>/DriveAGI/opendv/utils/frame_extraction.py", line 145, in cv2_extract_frames
    num_frames = int( fps * (video.get(7) // video_fps - discard_begin - discard_end) )
ZeroDivisionError: float floor division by zero
Traceback (most recent call last):
  File "<path>/DriveAGI/opendv/utils/frame_extraction.py", line 41, in extract_frames
    cv2_extract_frames(video_path, output_dir, fps, discard_begin, discard_end, exception_file)
  File "<path>/DriveAGI/opendv/utils/frame_extraction.py", line 145, in cv2_extract_frames
    num_frames = int( fps * (video.get(7) // video_fps - discard_begin - discard_end) )
ZeroDivisionError: float floor division by zero

There are the videos saved in the exception file

{
    "video_path": "OpenDV-YouTube/videos/Road_Therapy/-G92wLAhsWk.mp4",
    "problem": "float floor division by zero",
    "action": "skipped",
    "details": "Traceback (most recent call last):\n  File \"<path>/DriveAGI/opendv/utils/frame_extraction.py\", line 41, in extract_frames\n    cv2_extract_frames(video_path, output_dir, fps, discard_begin, discard_end, exception_file)\n  File \"<path>/DriveAGI/opendv/utils/frame_extraction.py\", line 145, in cv2_extract_frames\n    num_frames = int( fps * (video.get(7) // video_fps - discard_begin - discard_end) )\nZeroDivisionError: float floor division by zero\n"
},
{
    "video_path": "OpenDV-YouTube/videos/takemytripdotcom/-GrFwuiFqbc.mp4",
    "problem": "float floor division by zero",
    "action": "skipped",
    "details": "Traceback (most recent call last):\n  File \"<path>/DriveAGI/opendv/utils/frame_extraction.py\", line 41, in extract_frames\n    cv2_extract_frames(video_path, output_dir, fps, discard_begin, discard_end, exception_file)\n  File \"<path>/DriveAGI/opendv/utils/frame_extraction.py\", line 145, in cv2_extract_frames\n    num_frames = int( fps * (video.get(7) // video_fps - discard_begin - discard_end) )\nZeroDivisionError: float floor division by zero\n"
},
{
    "video_path": "OpenDV-YouTube/videos/Walk_East/-X_lyIV76Ek.mp4",
    "problem": "float floor division by zero",
    "action": "skipped",
    "details": "Traceback (most recent call last):\n  File \"<path>/DriveAGI/opendv/utils/frame_extraction.py\", line 41, in extract_frames\n    cv2_extract_frames(video_path, output_dir, fps, discard_begin, discard_end, exception_file)\n  File \"<path>/DriveAGI/opendv/utils/frame_extraction.py\", line 145, in cv2_extract_frames\n    num_frames = int( fps * (video.get(7) // video_fps - discard_begin - discard_end) )\nZeroDivisionError: float floor division by zero\n"
},
.
.
.

All videos seem to have the .mp4 format, did you face this issue while extracting as well?

Many thanks

@GihhArwtw
Copy link
Contributor

GihhArwtw commented Sep 7, 2024

hi @aminebdj
sorry for the late response.
Could you please check whether these videos you mentioned truly exist? You may refer to the download_exceptions.txt that will be automatically generated in the opendv root of the codebase.
opencv-python will return 0 if the video does not exist.
I am also working on a script to check whether the downloading is truly successful or not. I'll keep you updated.

@GihhArwtw
Copy link
Contributor

hi @aminebdj
A possible cause for the issue is that the metadata of these mp4 files are fragmented. You may refer to error reading header in FFMPEG and OPENCV for solutions. I am currently working on a update based on the solution above.

@GihhArwtw
Copy link
Contributor

GihhArwtw commented Sep 8, 2024

hi @aminebdj
We just updated a version to get the frame rate from ffmpeg when cv2 is not working.
For details, you can refer to implementation details.

NOTE: You are recommended to use ffmpeg<=3.4.9, otherwise fragmented metadata may not be handled successfully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants