{
  "id": 126211,
  "title": "cv2.VideoCapture() returns false for some videos",
  "url": "/competitions/deepfake-detection-challenge/discussion/126211",
  "author_name": "",
  "post_date": "2020-01-16T09:45:15.918325400Z",
  "votes": 2,
  "comment_count": 5,
  "views": 0,
  "content": "<p>Hey Guys!\nI have been trying to extract frames from videos using OpenCV. The routine that i am following goes like : </p>\n\n<pre><code>capture = cv.VideoCapture(video_path)\nprint(capture.isOpened())\n</code></pre>\n\n<p>For some video <strong>capture.isOpened()</strong> returns <strong>False</strong>. Does it means that some of the videos are corrupt ? Or does it have to do something with OpenCV / Anaconda settings.</p>\n\n<p>Awaiting a reply\nThanks in advance :)</p>",
  "messages": [
    {
      "id": "720285",
      "postDate": "01/16/2020 09:45:15",
      "content": "<p>Hey Guys!\nI have been trying to extract frames from videos using OpenCV. The routine that i am following goes like : </p>\n\n<pre><code>capture = cv.VideoCapture(video_path)\nprint(capture.isOpened())\n</code></pre>\n\n<p>For some video <strong>capture.isOpened()</strong> returns <strong>False</strong>. Does it means that some of the videos are corrupt ? Or does it have to do something with OpenCV / Anaconda settings.</p>\n\n<p>Awaiting a reply\nThanks in advance :)</p>",
      "rawMarkdown": "Hey Guys!\nI have been trying to extract frames from videos using OpenCV. The routine that i am following goes like : \n\n    capture = cv.VideoCapture(video_path)\n    print(capture.isOpened())\n\nFor some video **capture.isOpened()** returns **False**. Does it means that some of the videos are corrupt ? Or does it have to do something with OpenCV / Anaconda settings.\n\nAwaiting a reply\nThanks in advance :)",
      "votes": null
    },
    {
      "id": "720833",
      "postDate": "01/16/2020 19:49:17",
      "content": "<p>Yes, it is normal, happens rarely. To combat it try using exception handling.</p>",
      "rawMarkdown": "Yes, it is normal, happens rarely. To combat it try using exception handling.",
      "votes": null
    },
    {
      "id": "720869",
      "postDate": "01/16/2020 20:25:15",
      "content": "<p>Thanks, i will try that :)</p>",
      "rawMarkdown": "Thanks, i will try that :)",
      "votes": null
    },
    {
      "id": "721871",
      "postDate": "01/17/2020 19:53:33",
      "content": "<p>I noticed that in subdir 49 there are some videos that have fewer frames than what OpenCV reports them as having. Perhaps it is these videos that are giving your problems? I don't recall getting errors on any other videos.</p>",
      "rawMarkdown": "I noticed that in subdir 49 there are some videos that have fewer frames than what OpenCV reports them as having. Perhaps it is these videos that are giving your problems? I don't recall getting errors on any other videos.",
      "votes": null
    },
    {
      "id": "722107",
      "postDate": "01/18/2020 05:40:54",
      "content": "<p>I have come accross a few videos(only a 3 or 4 of them) in subdir 0 wherein VideoCapture() returns false.</p>",
      "rawMarkdown": "I have come accross a few videos(only a 3 or 4 of them) in subdir 0 wherein VideoCapture() returns false.",
      "votes": null
    },
    {
      "id": "722327",
      "postDate": "01/18/2020 11:52:44",
      "content": "<p>Just tried this on my machine and all the videos in subdir 0 work fine. Not sure why they would give errors for you...</p>",
      "rawMarkdown": "Just tried this on my machine and all the videos in subdir 0 work fine. Not sure why they would give errors for you...",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 720833,
      "author_name": "mrunalnkshirsagar",
      "author_url": "",
      "post_date": "01/16/2020 19:49:17",
      "content": "<p>Yes, it is normal, happens rarely. To combat it try using exception handling.</p>",
      "votes": null,
      "replies": [
        {
          "id": 720869,
          "author_name": "mrunalnasery",
          "author_url": "",
          "post_date": "01/16/2020 20:25:15",
          "content": "<p>Thanks, i will try that :)</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 721871,
      "author_name": "humananalog",
      "author_url": "",
      "post_date": "01/17/2020 19:53:33",
      "content": "<p>I noticed that in subdir 49 there are some videos that have fewer frames than what OpenCV reports them as having. Perhaps it is these videos that are giving your problems? I don't recall getting errors on any other videos.</p>",
      "votes": null,
      "replies": [
        {
          "id": 722107,
          "author_name": "mrunalnasery",
          "author_url": "",
          "post_date": "01/18/2020 05:40:54",
          "content": "<p>I have come accross a few videos(only a 3 or 4 of them) in subdir 0 wherein VideoCapture() returns false.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 722327,
          "author_name": "humananalog",
          "author_url": "",
          "post_date": "01/18/2020 11:52:44",
          "content": "<p>Just tried this on my machine and all the videos in subdir 0 work fine. Not sure why they would give errors for you...</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "720285": "Hey Guys!\nI have been trying to extract frames from videos using OpenCV. The routine that i am following goes like : \n\n    capture = cv.VideoCapture(video_path)\n    print(capture.isOpened())\n\nFor some video **capture.isOpened()** returns **False**. Does it means that some of the videos are corrupt ? Or does it have to do something with OpenCV / Anaconda settings.\n\nAwaiting a reply\nThanks in advance :)",
    "720833": "Yes, it is normal, happens rarely. To combat it try using exception handling.",
    "720869": "Thanks, i will try that :)",
    "721871": "I noticed that in subdir 49 there are some videos that have fewer frames than what OpenCV reports them as having. Perhaps it is these videos that are giving your problems? I don't recall getting errors on any other videos.",
    "722107": "I have come accross a few videos(only a 3 or 4 of them) in subdir 0 wherein VideoCapture() returns false.",
    "722327": "Just tried this on my machine and all the videos in subdir 0 work fine. Not sure why they would give errors for you..."
  },
  "source": "meta"
}