{
  "id": 131695,
  "title": "frame counts",
  "url": "/competitions/deepfake-detection-challenge/discussion/131695",
  "author_name": "",
  "post_date": "2020-02-21T04:55:14.739372Z",
  "votes": 5,
  "comment_count": 8,
  "views": 0,
  "content": "<p>Has anyone experienced any problems with frame counts?</p>\n\n<p>In my case, I sometimes get different framecounts for the same video using different ways to calculate the number of frames in a file. </p>\n\n<p>The first method is</p>\n\n<p><code>\nvid = cv2.VideoCapture(source_video_full_file_name)\nframe_count = vid.get(cv2.CAP_PROP_FRAME_COUNT) \n</code></p>\n\n<p>The second method is </p>\n\n<p><code>\nframes = []\ncap = cv2.VideoCapture(source_video_full_file_name)\nwhile True:\n    (ret, frame) = cap.read()\n    if not ret:\n        break\n    frames.append(frame)\nframe_count = len(frames)\n</code>\nMost of the time both methods return the same results (as they are supposed to). However, for some files (e.g.  ttnajmkchw.mp4 or  bphdxnykou.mp4) they produce different outcomes.  </p>\n\n<p>Any thoughts?</p>",
  "messages": [
    {
      "id": "752506",
      "postDate": "02/21/2020 04:55:14",
      "content": "<p>Has anyone experienced any problems with frame counts?</p>\n\n<p>In my case, I sometimes get different framecounts for the same video using different ways to calculate the number of frames in a file. </p>\n\n<p>The first method is</p>\n\n<p><code>\nvid = cv2.VideoCapture(source_video_full_file_name)\nframe_count = vid.get(cv2.CAP_PROP_FRAME_COUNT) \n</code></p>\n\n<p>The second method is </p>\n\n<p><code>\nframes = []\ncap = cv2.VideoCapture(source_video_full_file_name)\nwhile True:\n    (ret, frame) = cap.read()\n    if not ret:\n        break\n    frames.append(frame)\nframe_count = len(frames)\n</code>\nMost of the time both methods return the same results (as they are supposed to). However, for some files (e.g.  ttnajmkchw.mp4 or  bphdxnykou.mp4) they produce different outcomes.  </p>\n\n<p>Any thoughts?</p>",
      "rawMarkdown": "Has anyone experienced any problems with frame counts?\n\nIn my case, I sometimes get different framecounts for the same video using different ways to calculate the number of frames in a file. \n\nThe first method is\n\n```\nvid = cv2.VideoCapture(source_video_full_file_name)\nframe_count = vid.get(cv2.CAP_PROP_FRAME_COUNT) \n```\n\nThe second method is \n\n```\nframes = []\ncap = cv2.VideoCapture(source_video_full_file_name)\nwhile True:\n    (ret, frame) = cap.read()\n    if not ret:\n        break\n    frames.append(frame)\nframe_count = len(frames)\n```\nMost of the time both methods return the same results (as they are supposed to). However, for some files (e.g.  ttnajmkchw.mp4 or  bphdxnykou.mp4) they produce different outcomes.  \n\nAny thoughts?",
      "votes": null
    },
    {
      "id": "752535",
      "postDate": "02/21/2020 05:58:42",
      "content": "<p>Some (~1/5) of the fake samples error when trying to get the last ~5 frames.</p>",
      "rawMarkdown": "Some (~1/5) of the fake samples error when trying to get the last ~5 frames.",
      "votes": null
    },
    {
      "id": "752550",
      "postDate": "02/21/2020 06:30:35",
      "content": "<p>Interesting, thank you for sharing .... do people consider it to be a data leakage or a legitimate feature? ;-)</p>",
      "rawMarkdown": "Interesting, thank you for sharing .... do people consider it to be a data leakage or a legitimate feature? ;-)",
      "votes": null
    },
    {
      "id": "752667",
      "postDate": "02/21/2020 09:26:04",
      "content": "<p>I encountered the same issue and found <a href=\"https://stackoverflow.com/questions/31472155/python-opencv-cv2-cv-cv-cap-prop-frame-count-get-wrong-numbers/47796468\">here someone mentions</a>:</p>\n\n<blockquote>\n  <p>The get() for <code>CAP_PROP_FRAME_COUNT</code> is never supposed to be accurate!</p>\n</blockquote>",
      "rawMarkdown": "I encountered the same issue and found [here someone mentions](https://stackoverflow.com/questions/31472155/python-opencv-cv2-cv-cv-cap-prop-frame-count-get-wrong-numbers/47796468):\n\n&gt; The get() for `CAP_PROP_FRAME_COUNT` is never supposed to be accurate!",
      "votes": null
    },
    {
      "id": "752695",
      "postDate": "02/21/2020 10:05:31",
      "content": "<p>I found videos in chunks 45 to 49 were particularly malformed and typically gave frame errors ~frame 120 (if I recall correctly). It's 1 reason why I've started using those videos as my validation rather than training set.</p>",
      "rawMarkdown": "I found videos in chunks 45 to 49 were particularly malformed and typically gave frame errors ~frame 120 (if I recall correctly). It's 1 reason why I've started using those videos as my validation rather than training set.",
      "votes": null
    },
    {
      "id": "752780",
      "postDate": "02/21/2020 11:46:27",
      "content": "<p>It especially happens in videos with a low FPS. Most videos have 300 frames and last 10 seconds. But videos in folder 49 often have fewer video frames (but are still 10 seconds). If you watch these videos, they are very choppy.</p>",
      "rawMarkdown": "It especially happens in videos with a low FPS. Most videos have 300 frames and last 10 seconds. But videos in folder 49 often have fewer video frames (but are still 10 seconds). If you watch these videos, they are very choppy.",
      "votes": null
    },
    {
      "id": "753072",
      "postDate": "02/21/2020 17:20:37",
      "content": "<p>I created a submission where any sample with missing frames was set to 1.0, all the rest where set to 0.5. It scored 0.68829 vs 0.69314 where everything is set to 0.5 . So I think it is a leak but a minor one and might not effect the private LB. </p>\n\n<p>My guess is this was a bigger leak at the start of the competition but was fixed by the hosts. </p>",
      "rawMarkdown": "I created a submission where any sample with missing frames was set to 1.0, all the rest where set to 0.5. It scored 0.68829 vs 0.69314 where everything is set to 0.5 . So I think it is a leak but a minor one and might not effect the private LB. \n\nMy guess is this was a bigger leak at the start of the competition but was fixed by the hosts.",
      "votes": null
    },
    {
      "id": "755869",
      "postDate": "02/25/2020 07:58:08",
      "content": "<p>Yes some videos are under sampled to 15fps on purpose ... the dataset preview paper describes this <a href=\"https://arxiv.org/pdf/1910.08854.pdf\">https://arxiv.org/pdf/1910.08854.pdf</a></p>",
      "rawMarkdown": "Yes some videos are under sampled to 15fps on purpose ... the dataset preview paper describes this https://arxiv.org/pdf/1910.08854.pdf",
      "votes": null
    },
    {
      "id": "756022",
      "postDate": "02/25/2020 10:59:29",
      "content": "<p>Oh I get it now, Thanks, that is why there are some problems grabbing frames from folder 49 of our face detector code, btw, the kernel has been prepared and we might be posting the face detector tommorow.</p>",
      "rawMarkdown": "Oh I get it now, Thanks, that is why there are some problems grabbing frames from folder 49 of our face detector code, btw, the kernel has been prepared and we might be posting the face detector tommorow.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 752535,
      "author_name": "jackvial",
      "author_url": "",
      "post_date": "02/21/2020 05:58:42",
      "content": "<p>Some (~1/5) of the fake samples error when trying to get the last ~5 frames.</p>",
      "votes": null,
      "replies": [
        {
          "id": 752550,
          "author_name": "vlpavlov",
          "author_url": "",
          "post_date": "02/21/2020 06:30:35",
          "content": "<p>Interesting, thank you for sharing .... do people consider it to be a data leakage or a legitimate feature? ;-)</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 753072,
          "author_name": "jackvial",
          "author_url": "",
          "post_date": "02/21/2020 17:20:37",
          "content": "<p>I created a submission where any sample with missing frames was set to 1.0, all the rest where set to 0.5. It scored 0.68829 vs 0.69314 where everything is set to 0.5 . So I think it is a leak but a minor one and might not effect the private LB. </p>\n\n<p>My guess is this was a bigger leak at the start of the competition but was fixed by the hosts. </p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 752667,
      "author_name": "zaharch",
      "author_url": "",
      "post_date": "02/21/2020 09:26:04",
      "content": "<p>I encountered the same issue and found <a href=\"https://stackoverflow.com/questions/31472155/python-opencv-cv2-cv-cv-cap-prop-frame-count-get-wrong-numbers/47796468\">here someone mentions</a>:</p>\n\n<blockquote>\n  <p>The get() for <code>CAP_PROP_FRAME_COUNT</code> is never supposed to be accurate!</p>\n</blockquote>",
      "votes": null,
      "replies": []
    },
    {
      "id": 752695,
      "author_name": "jamesphoward",
      "author_url": "",
      "post_date": "02/21/2020 10:05:31",
      "content": "<p>I found videos in chunks 45 to 49 were particularly malformed and typically gave frame errors ~frame 120 (if I recall correctly). It's 1 reason why I've started using those videos as my validation rather than training set.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 752780,
      "author_name": "humananalog",
      "author_url": "",
      "post_date": "02/21/2020 11:46:27",
      "content": "<p>It especially happens in videos with a low FPS. Most videos have 300 frames and last 10 seconds. But videos in folder 49 often have fewer video frames (but are still 10 seconds). If you watch these videos, they are very choppy.</p>",
      "votes": null,
      "replies": [
        {
          "id": 756022,
          "author_name": "harshitsheoran",
          "author_url": "",
          "post_date": "02/25/2020 10:59:29",
          "content": "<p>Oh I get it now, Thanks, that is why there are some problems grabbing frames from folder 49 of our face detector code, btw, the kernel has been prepared and we might be posting the face detector tommorow.</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 755869,
      "author_name": "ma7moud",
      "author_url": "",
      "post_date": "02/25/2020 07:58:08",
      "content": "<p>Yes some videos are under sampled to 15fps on purpose ... the dataset preview paper describes this <a href=\"https://arxiv.org/pdf/1910.08854.pdf\">https://arxiv.org/pdf/1910.08854.pdf</a></p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "752506": "Has anyone experienced any problems with frame counts?\n\nIn my case, I sometimes get different framecounts for the same video using different ways to calculate the number of frames in a file. \n\nThe first method is\n\n```\nvid = cv2.VideoCapture(source_video_full_file_name)\nframe_count = vid.get(cv2.CAP_PROP_FRAME_COUNT) \n```\n\nThe second method is \n\n```\nframes = []\ncap = cv2.VideoCapture(source_video_full_file_name)\nwhile True:\n    (ret, frame) = cap.read()\n    if not ret:\n        break\n    frames.append(frame)\nframe_count = len(frames)\n```\nMost of the time both methods return the same results (as they are supposed to). However, for some files (e.g.  ttnajmkchw.mp4 or  bphdxnykou.mp4) they produce different outcomes.  \n\nAny thoughts?",
    "752535": "Some (~1/5) of the fake samples error when trying to get the last ~5 frames.",
    "752550": "Interesting, thank you for sharing .... do people consider it to be a data leakage or a legitimate feature? ;-)",
    "752667": "I encountered the same issue and found [here someone mentions](https://stackoverflow.com/questions/31472155/python-opencv-cv2-cv-cv-cap-prop-frame-count-get-wrong-numbers/47796468):\n\n&gt; The get() for `CAP_PROP_FRAME_COUNT` is never supposed to be accurate!",
    "752695": "I found videos in chunks 45 to 49 were particularly malformed and typically gave frame errors ~frame 120 (if I recall correctly). It's 1 reason why I've started using those videos as my validation rather than training set.",
    "752780": "It especially happens in videos with a low FPS. Most videos have 300 frames and last 10 seconds. But videos in folder 49 often have fewer video frames (but are still 10 seconds). If you watch these videos, they are very choppy.",
    "753072": "I created a submission where any sample with missing frames was set to 1.0, all the rest where set to 0.5. It scored 0.68829 vs 0.69314 where everything is set to 0.5 . So I think it is a leak but a minor one and might not effect the private LB. \n\nMy guess is this was a bigger leak at the start of the competition but was fixed by the hosts.",
    "755869": "Yes some videos are under sampled to 15fps on purpose ... the dataset preview paper describes this https://arxiv.org/pdf/1910.08854.pdf",
    "756022": "Oh I get it now, Thanks, that is why there are some problems grabbing frames from folder 49 of our face detector code, btw, the kernel has been prepared and we might be posting the face detector tommorow."
  },
  "source": "meta"
}