{
  "id": 382018,
  "title": "Making videos playable in kaggle notebooks",
  "url": "/competitions/nfl-player-contact-detection/discussion/382018",
  "author_name": "",
  "post_date": "2023-01-29T06:59:04.675413700Z",
  "votes": 2,
  "comment_count": 1,
  "views": 0,
  "content": "<p>Here is a function that converts the codec of the videos so that it is more broadly readable.</p>\n<pre><code>import os\nimport subprocess\n\ntmp_video_path = 'path_to_cv_processed_output'\noutput_path = 'path_to_final_output_file'\n\ndef convert_codec(tmp_video_path, output_path):\n  # Not all browsers support the codec, we will re-load the file at tmp_output_path\n  # and convert to a codec that is more broadly readable using ffmpeg\n  if os.path.exists(output_path):\n          os.remove(output_path)\n  subprocess.run(\n          [\n              \"ffmpeg\",\n              \"-i\",\n              tmp_output_path,\n              \"-crf\",\n              \"18\",\n              \"-preset\",\n              \"veryfast\",\n              \"-hide_banner\",\n              \"-loglevel\",\n              \"error\",\n              \"-vcodec\",\n              \"libx264\",\n              output_path,\n          ]\n      )\n  os.remove(tmp_output_path)\n\n  return output_path\n</code></pre>\n<p>References: </p>\n<ul>\n<li><a href=\"https://www.kaggle.com/code/robikscube/nfl-player-contact-detection-getting-started\" target=\"_blank\">NFL Player Contact Detection - Getting Started</a></li>\n<li><a href=\"https://www.kaggle.com/code/dariussingh/player-contact-detection-eda\" target=\"_blank\">Player Contact Detection - EDA</a></li>\n</ul>",
  "messages": [
    {
      "id": "2119868",
      "postDate": "01/29/2023 06:59:04",
      "content": "<p>Here is a function that converts the codec of the videos so that it is more broadly readable.</p>\n<pre><code>import os\nimport subprocess\n\ntmp_video_path = 'path_to_cv_processed_output'\noutput_path = 'path_to_final_output_file'\n\ndef convert_codec(tmp_video_path, output_path):\n  # Not all browsers support the codec, we will re-load the file at tmp_output_path\n  # and convert to a codec that is more broadly readable using ffmpeg\n  if os.path.exists(output_path):\n          os.remove(output_path)\n  subprocess.run(\n          [\n              \"ffmpeg\",\n              \"-i\",\n              tmp_output_path,\n              \"-crf\",\n              \"18\",\n              \"-preset\",\n              \"veryfast\",\n              \"-hide_banner\",\n              \"-loglevel\",\n              \"error\",\n              \"-vcodec\",\n              \"libx264\",\n              output_path,\n          ]\n      )\n  os.remove(tmp_output_path)\n\n  return output_path\n</code></pre>\n<p>References: </p>\n<ul>\n<li><a href=\"https://www.kaggle.com/code/robikscube/nfl-player-contact-detection-getting-started\" target=\"_blank\">NFL Player Contact Detection - Getting Started</a></li>\n<li><a href=\"https://www.kaggle.com/code/dariussingh/player-contact-detection-eda\" target=\"_blank\">Player Contact Detection - EDA</a></li>\n</ul>",
      "rawMarkdown": "Here is a function that converts the codec of the videos so that it is more broadly readable.\n\n```\nimport os\nimport subprocess\n\ntmp_video_path = 'path_to_cv_processed_output'\noutput_path = 'path_to_final_output_file'\n\ndef convert_codec(tmp_video_path, output_path):\n  # Not all browsers support the codec, we will re-load the file at tmp_output_path\n  # and convert to a codec that is more broadly readable using ffmpeg\n  if os.path.exists(output_path):\n          os.remove(output_path)\n  subprocess.run(\n          [\n              \"ffmpeg\",\n              \"-i\",\n              tmp_output_path,\n              \"-crf\",\n              \"18\",\n              \"-preset\",\n              \"veryfast\",\n              \"-hide_banner\",\n              \"-loglevel\",\n              \"error\",\n              \"-vcodec\",\n              \"libx264\",\n              output_path,\n          ]\n      )\n  os.remove(tmp_output_path)\n    \n  return output_path\n```\n\nReferences: \n- [NFL Player Contact Detection - Getting Started](https://www.kaggle.com/code/robikscube/nfl-player-contact-detection-getting-started)\n- [Player Contact Detection - EDA](https://www.kaggle.com/code/dariussingh/player-contact-detection-eda)",
      "votes": null
    },
    {
      "id": "2120272",
      "postDate": "01/29/2023 13:26:22",
      "content": "<p>Helpful topic. Maybe I'm gonna try your snippet soon.<br>\nBeen already on the references above.</p>",
      "rawMarkdown": "Helpful topic. Maybe I'm gonna try your snippet soon.\nBeen already on the references above.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 2120272,
      "author_name": "mpwolke",
      "author_url": "",
      "post_date": "01/29/2023 13:26:22",
      "content": "<p>Helpful topic. Maybe I'm gonna try your snippet soon.<br>\nBeen already on the references above.</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "2119868": "Here is a function that converts the codec of the videos so that it is more broadly readable.\n\n```\nimport os\nimport subprocess\n\ntmp_video_path = 'path_to_cv_processed_output'\noutput_path = 'path_to_final_output_file'\n\ndef convert_codec(tmp_video_path, output_path):\n  # Not all browsers support the codec, we will re-load the file at tmp_output_path\n  # and convert to a codec that is more broadly readable using ffmpeg\n  if os.path.exists(output_path):\n          os.remove(output_path)\n  subprocess.run(\n          [\n              \"ffmpeg\",\n              \"-i\",\n              tmp_output_path,\n              \"-crf\",\n              \"18\",\n              \"-preset\",\n              \"veryfast\",\n              \"-hide_banner\",\n              \"-loglevel\",\n              \"error\",\n              \"-vcodec\",\n              \"libx264\",\n              output_path,\n          ]\n      )\n  os.remove(tmp_output_path)\n    \n  return output_path\n```\n\nReferences: \n- [NFL Player Contact Detection - Getting Started](https://www.kaggle.com/code/robikscube/nfl-player-contact-detection-getting-started)\n- [Player Contact Detection - EDA](https://www.kaggle.com/code/dariussingh/player-contact-detection-eda)",
    "2120272": "Helpful topic. Maybe I'm gonna try your snippet soon.\nBeen already on the references above."
  },
  "source": "meta"
}