[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-meta-pytorch--torchcodec":3,"tool-meta-pytorch--torchcodec":64},[4,17,27,35,43,56],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":16},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,3,"2026-04-05T11:01:52",[13,14,15],"开发框架","图像","Agent","ready",{"id":18,"name":19,"github_repo":20,"description_zh":21,"stars":22,"difficulty_score":23,"last_commit_at":24,"category_tags":25,"status":16},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",138956,2,"2026-04-05T11:33:21",[13,15,26],"语言模型",{"id":28,"name":29,"github_repo":30,"description_zh":31,"stars":32,"difficulty_score":23,"last_commit_at":33,"category_tags":34,"status":16},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",107662,"2026-04-03T11:11:01",[13,14,15],{"id":36,"name":37,"github_repo":38,"description_zh":39,"stars":40,"difficulty_score":23,"last_commit_at":41,"category_tags":42,"status":16},3704,"NextChat","ChatGPTNextWeb\u002FNextChat","NextChat 是一款轻量且极速的 AI 助手，旨在为用户提供流畅、跨平台的大模型交互体验。它完美解决了用户在多设备间切换时难以保持对话连续性，以及面对众多 AI 模型不知如何统一管理的痛点。无论是日常办公、学习辅助还是创意激发，NextChat 都能让用户随时随地通过网页、iOS、Android、Windows、MacOS 或 Linux 端无缝接入智能服务。\n\n这款工具非常适合普通用户、学生、职场人士以及需要私有化部署的企业团队使用。对于开发者而言，它也提供了便捷的自托管方案，支持一键部署到 Vercel 或 Zeabur 等平台。\n\nNextChat 的核心亮点在于其广泛的模型兼容性，原生支持 Claude、DeepSeek、GPT-4 及 Gemini Pro 等主流大模型，让用户在一个界面即可自由切换不同 AI 能力。此外，它还率先支持 MCP（Model Context Protocol）协议，增强了上下文处理能力。针对企业用户，NextChat 提供专业版解决方案，具备品牌定制、细粒度权限控制、内部知识库整合及安全审计等功能，满足公司对数据隐私和个性化管理的高标准要求。",87618,"2026-04-05T07:20:52",[13,26],{"id":44,"name":45,"github_repo":46,"description_zh":47,"stars":48,"difficulty_score":23,"last_commit_at":49,"category_tags":50,"status":16},2268,"ML-For-Beginners","microsoft\u002FML-For-Beginners","ML-For-Beginners 是由微软推出的一套系统化机器学习入门课程，旨在帮助零基础用户轻松掌握经典机器学习知识。这套课程将学习路径规划为 12 周，包含 26 节精炼课程和 52 道配套测验，内容涵盖从基础概念到实际应用的完整流程，有效解决了初学者面对庞大知识体系时无从下手、缺乏结构化指导的痛点。\n\n无论是希望转型的开发者、需要补充算法背景的研究人员，还是对人工智能充满好奇的普通爱好者，都能从中受益。课程不仅提供了清晰的理论讲解，还强调动手实践，让用户在循序渐进中建立扎实的技能基础。其独特的亮点在于强大的多语言支持，通过自动化机制提供了包括简体中文在内的 50 多种语言版本，极大地降低了全球不同背景用户的学习门槛。此外，项目采用开源协作模式，社区活跃且内容持续更新，确保学习者能获取前沿且准确的技术资讯。如果你正寻找一条清晰、友好且专业的机器学习入门之路，ML-For-Beginners 将是理想的起点。",84991,"2026-04-05T10:45:23",[14,51,52,53,15,54,26,13,55],"数据工具","视频","插件","其他","音频",{"id":57,"name":58,"github_repo":59,"description_zh":60,"stars":61,"difficulty_score":10,"last_commit_at":62,"category_tags":63,"status":16},3128,"ragflow","infiniflow\u002Fragflow","RAGFlow 是一款领先的开源检索增强生成（RAG）引擎，旨在为大语言模型构建更精准、可靠的上下文层。它巧妙地将前沿的 RAG 技术与智能体（Agent）能力相结合，不仅支持从各类文档中高效提取知识，还能让模型基于这些知识进行逻辑推理和任务执行。\n\n在大模型应用中，幻觉问题和知识滞后是常见痛点。RAGFlow 通过深度解析复杂文档结构（如表格、图表及混合排版），显著提升了信息检索的准确度，从而有效减少模型“胡编乱造”的现象，确保回答既有据可依又具备时效性。其内置的智能体机制更进一步，使系统不仅能回答问题，还能自主规划步骤解决复杂问题。\n\n这款工具特别适合开发者、企业技术团队以及 AI 研究人员使用。无论是希望快速搭建私有知识库问答系统，还是致力于探索大模型在垂直领域落地的创新者，都能从中受益。RAGFlow 提供了可视化的工作流编排界面和灵活的 API 接口，既降低了非算法背景用户的上手门槛，也满足了专业开发者对系统深度定制的需求。作为基于 Apache 2.0 协议开源的项目，它正成为连接通用大模型与行业专有知识之间的重要桥梁。",77062,"2026-04-04T04:44:48",[15,14,13,26,54],{"id":65,"github_repo":66,"name":67,"description_en":68,"description_zh":69,"ai_summary_zh":70,"readme_en":71,"readme_zh":72,"quickstart_zh":73,"use_case_zh":74,"hero_image_url":75,"owner_login":76,"owner_name":77,"owner_avatar_url":78,"owner_bio":79,"owner_company":80,"owner_location":80,"owner_email":80,"owner_twitter":80,"owner_website":81,"owner_url":82,"languages":83,"stars":108,"forks":109,"last_commit_at":110,"license":111,"difficulty_score":23,"env_os":112,"env_gpu":113,"env_ram":114,"env_deps":115,"category_tags":121,"github_topics":80,"view_count":122,"oss_zip_url":80,"oss_zip_packed_at":80,"status":16,"created_at":123,"updated_at":124,"faqs":125,"releases":155},918,"meta-pytorch\u002Ftorchcodec","torchcodec","PyTorch media decoding and encoding","TorchCodec 是一个基于 PyTorch 的媒体解码与编码库，能够将视频和音频数据快速转换为 PyTorch 张量，支持 CPU 和 CUDA GPU 加速，同时也提供编码功能。它主要面向使用 PyTorch 进行机器学习模型训练的开发者与研究人员，特别是那些需要处理视频或音频数据作为输入的任务。\n\n该库解决了在 PyTorch 生态中直接、高效处理媒体数据的难题。传统上，开发者需要依赖 FFmpeg 等复杂工具进行解码，再手动转换为张量，过程繁琐且易出错。TorchCodec 通过封装 FFmpeg 的功能，提供了直观的 Python API，让用户能够像操作 PyTorch 张量一样轻松读取视频帧或音频片段，大幅简化了数据预处理流程。\n\n其技术亮点在于深度集成 PyTorch，支持直接返回张量，并可指定设备（如 GPU），便于后续模型训练。同时，它提供了灵活的数据访问方式，包括按帧索引、按时间点采样以及批量提取视频片段，方便用户构建自定义的数据加载流程。\n\n如果你正在使用 PyTorch 开发计算机视觉或音频相关的 AI 模型，并且需要处理视频或音频文件，TorchCode","TorchCodec 是一个基于 PyTorch 的媒体解码与编码库，能够将视频和音频数据快速转换为 PyTorch 张量，支持 CPU 和 CUDA GPU 加速，同时也提供编码功能。它主要面向使用 PyTorch 进行机器学习模型训练的开发者与研究人员，特别是那些需要处理视频或音频数据作为输入的任务。\n\n该库解决了在 PyTorch 生态中直接、高效处理媒体数据的难题。传统上，开发者需要依赖 FFmpeg 等复杂工具进行解码，再手动转换为张量，过程繁琐且易出错。TorchCodec 通过封装 FFmpeg 的功能，提供了直观的 Python API，让用户能够像操作 PyTorch 张量一样轻松读取视频帧或音频片段，大幅简化了数据预处理流程。\n\n其技术亮点在于深度集成 PyTorch，支持直接返回张量，并可指定设备（如 GPU），便于后续模型训练。同时，它提供了灵活的数据访问方式，包括按帧索引、按时间点采样以及批量提取视频片段，方便用户构建自定义的数据加载流程。\n\n如果你正在使用 PyTorch 开发计算机视觉或音频相关的 AI 模型，并且需要处理视频或音频文件，TorchCodec 可以成为一个高效、易用的数据加载工具，帮助你专注于模型本身而非底层数据处理。","[**Installation**](#installing-torchcodec) | [**Simple Example**](#using-torchcodec) | [**Detailed Example**](https:\u002F\u002Fmeta-pytorch.org\u002Ftorchcodec\u002Fstable\u002Fgenerated_examples\u002F) | [**Documentation**](https:\u002F\u002Fmeta-pytorch.org\u002Ftorchcodec) | [**Contributing**](CONTRIBUTING.md) | [**License**](#license)\n\n# TorchCodec\n\nTorchCodec is a Python library for decoding video and audio data into PyTorch\ntensors, on CPU and CUDA GPU. It also supports video and audio encoding on CPU!\nIt aims to be fast, easy to use, and well integrated\ninto the PyTorch ecosystem.  If you want to use PyTorch to train ML models on\nvideos and audio, TorchCodec is how you turn these into data.\n\nWe achieve these capabilities through:\n\n* Pythonic APIs that mirror Python and PyTorch conventions.\n* Relying on [FFmpeg](https:\u002F\u002Fwww.ffmpeg.org\u002F) to do the decoding and encoding.\n  TorchCodec uses the version of FFmpeg you already have installed. FFmpeg is a\n  mature library with broad coverage available on most systems. It is, however,\n  not easy to use. TorchCodec abstracts FFmpeg's complexity to ensure it is used\n  correctly and efficiently.\n* Returning data as PyTorch tensors, ready to be fed into PyTorch transforms\n  or used directly to train models.\n\n## Using TorchCodec\n\nHere's a condensed summary of what you can do with TorchCodec. For more detailed\nexamples, [check out our\ndocumentation](https:\u002F\u002Fmeta-pytorch.org\u002Ftorchcodec\u002Fstable\u002Fgenerated_examples\u002F)!\n\n#### Decoding\n\n```python\nfrom torchcodec.decoders import VideoDecoder\n\ndevice = \"cpu\"  # or e.g. \"cuda\" !\ndecoder = VideoDecoder(\"path\u002Fto\u002Fvideo.mp4\", device=device)\n\ndecoder.metadata\n# VideoStreamMetadata:\n#   num_frames: 250\n#   duration_seconds: 10.0\n#   bit_rate: 31315.0\n#   codec: h264\n#   average_fps: 25.0\n#   ... (truncated output)\n\n# Simple Indexing API\ndecoder[0]  # uint8 tensor of shape [C, H, W]\ndecoder[0 : -1 : 20]  # uint8 stacked tensor of shape [N, C, H, W]\n\n# Indexing, with PTS and duration info:\ndecoder.get_frames_at(indices=[2, 100])\n# FrameBatch:\n#   data (shape): torch.Size([2, 3, 270, 480])\n#   pts_seconds: tensor([0.0667, 3.3367], dtype=torch.float64)\n#   duration_seconds: tensor([0.0334, 0.0334], dtype=torch.float64)\n\n# Time-based indexing with PTS and duration info\ndecoder.get_frames_played_at(seconds=[0.5, 10.4])\n# FrameBatch:\n#   data (shape): torch.Size([2, 3, 270, 480])\n#   pts_seconds: tensor([ 0.4671, 10.3770], dtype=torch.float64)\n#   duration_seconds: tensor([0.0334, 0.0334], dtype=torch.float64)\n```\n\n#### Clip sampling\n\n```python\n\nfrom torchcodec.samplers import clips_at_regular_timestamps\n\nclips_at_regular_timestamps(\n    decoder,\n    seconds_between_clip_starts=1.5,\n    num_frames_per_clip=4,\n    seconds_between_frames=0.1\n)\n# FrameBatch:\n#   data (shape): torch.Size([9, 4, 3, 270, 480])\n#   pts_seconds: tensor([[ 0.0000,  0.0667,  0.1668,  0.2669],\n#         [ 1.4681,  1.5682,  1.6683,  1.7684],\n#         [ 2.9696,  3.0697,  3.1698,  3.2699],\n#         ... (truncated), dtype=torch.float64)\n#   duration_seconds: tensor([[0.0334, 0.0334, 0.0334, 0.0334],\n#         [0.0334, 0.0334, 0.0334, 0.0334],\n#         [0.0334, 0.0334, 0.0334, 0.0334],\n#         ... (truncated), dtype=torch.float64)\n```\n\nYou can use the following snippet to generate a video with FFmpeg and tryout\nTorchCodec:\n\n```bash\nfontfile=\u002Fusr\u002Fshare\u002Ffonts\u002Fdejavu-sans-mono-fonts\u002FDejaVuSansMono-Bold.ttf\noutput_video_file=\u002Ftmp\u002Foutput_video.mp4\n\nffmpeg -f lavfi -i \\\n    color=size=640x400:duration=10:rate=25:color=blue \\\n    -vf \"drawtext=fontfile=${fontfile}:fontsize=30:fontcolor=white:x=(w-text_w)\u002F2:y=(h-text_h)\u002F2:text='Frame %{frame_num}'\" \\\n    ${output_video_file}\n```\n\n## Installing TorchCodec\n### Installing CPU-only TorchCodec\n\n1. Install the latest stable version of PyTorch following the\n   [official instructions](https:\u002F\u002Fpytorch.org\u002Fget-started\u002Flocally\u002F). For other\n   versions, refer to the table below for compatibility between versions of\n   `torch` and `torchcodec`.\n\n2. Install FFmpeg, if it's not already installed. TorchCodec supports\n   all major FFmpeg versions in [4, 8].\n   Linux distributions usually come with FFmpeg pre-installed. You'll need\n   FFmpeg that comes with separate shared libraries. This is especially relevant\n   for Windows users: these are usually called the \"shared\" releases.\n\n   If FFmpeg is not already installed, or you need a more recent version, an\n   easy way to install it is to use `conda`:\n\n   ```bash\n   conda install \"ffmpeg\"\n   # or\n   conda install \"ffmpeg\" -c conda-forge\n   ```\n\n3. Install TorchCodec:\n\n   ```bash\n   pip install torchcodec --index-url=https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fcpu\n   ```\n\nThe following table indicates the compatibility between versions of\n`torchcodec`, `torch` and Python.\n\n| `torchcodec`       | `torch`            | Python              |\n| ------------------ | ------------------ | ------------------- |\n| `main` \u002F `nightly` | `main` \u002F `nightly` | `>=3.10`, `\u003C=3.14`   |\n| `0.11`             | `2.11`             | `>=3.10`, `\u003C=3.14`   |\n| `0.10`             | `2.10`             | `>=3.10`, `\u003C=3.14`   |\n| `0.9`              | `2.9`              | `>=3.10`, `\u003C=3.14`   |\n| `0.8`              | `2.9`              | `>=3.10`, `\u003C=3.13`   |\n| `0.7`              | `2.8`              | `>=3.9`, `\u003C=3.13`   |\n| `0.6`              | `2.8`              | `>=3.9`, `\u003C=3.13`   |\n| `0.5`              | `2.7`              | `>=3.9`, `\u003C=3.13`   |\n| `0.4`              | `2.7`              | `>=3.9`, `\u003C=3.13`   |\n| `0.3`              | `2.7`              | `>=3.9`, `\u003C=3.13`   |\n| `0.2`              | `2.6`              | `>=3.9`, `\u003C=3.13`   |\n| `0.1`              | `2.5`              | `>=3.9`, `\u003C=3.12`   |\n| `0.0.3`            | `2.4`              | `>=3.8`, `\u003C=3.12`   |\n\n### Installing CUDA-enabled TorchCodec\n\nFirst, make sure you have a GPU that has NVDEC hardware that can decode the\nformat you want. Refer to Nvidia's GPU support matrix for more details\n[here](https:\u002F\u002Fdeveloper.nvidia.com\u002Fvideo-encode-and-decode-gpu-support-matrix-new).\n\n1. Install FFmpeg with NVDEC support.\n   TorchCodec with CUDA should work with FFmpeg versions in [4, 8].\n\n   If FFmpeg is not already installed, or you need a more recent version, an\n   easy way to install it is to use `conda`:\n\n   ```bash\n   conda install \"ffmpeg\"\n   # or\n   conda install \"ffmpeg\" -c conda-forge\n   ```\n\n   After installing FFmpeg make sure it has NVDEC support when you list the supported\n   decoders:\n\n   ```bash\n   ffmpeg -decoders | grep -i nvidia\n   # This should show a line like this:\n   # V..... h264_cuvid           Nvidia CUVID H264 decoder (codec h264)\n   ```\n\n   To check that FFmpeg libraries work with NVDEC correctly you can decode a sample video:\n\n   ```bash\n   ffmpeg -hwaccel cuda -hwaccel_output_format cuda -i test\u002Fresources\u002Fnasa_13013.mp4 -f null -\n   ```\n\n#### Linux\n\n2. Install Pytorch corresponding to your CUDA Toolkit using the\n   [official instructions](https:\u002F\u002Fpytorch.org\u002Fget-started\u002Flocally\u002F). You'll\n   need the `libnpp` and `libnvrtc` CUDA libraries, which are usually part of\n   the CUDA Toolkit.\n\n3. Install TorchCodec\n\n   On Linux, `pip install torchcodec` defaults to a CUDA wheel,\n   matching the default behavior of `pip install torch`.\n\n   ```bash\n   pip install torchcodec\n   ```\n   Use `--index-url` to select a different CUDA Toolkit version:\n\n   ```bash\n   # This corresponds to CUDA Toolkit version 13.0. It should be the same one\n   # you used when you installed PyTorch (If you installed PyTorch with pip).\n   pip install torchcodec --index-url=https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fcu130\n   ```\n\n#### Windows\n\n2. On Windows (experimental support), you'll need to rely on `conda` to install\n   both pytorch and TorchCodec:\n\n   ```bash\n   conda install -c conda-forge \"torchcodec=*=*cuda*\"\n   ```\n\n## Benchmark Results\n\nThe following was generated by running [our benchmark script](.\u002Fbenchmarks\u002Fdecoders\u002Fgenerate_readme_data.py) on a lightly loaded 22-core machine with an Nvidia A100 with\n5 [NVDEC decoders](https:\u002F\u002Fdocs.nvidia.com\u002Fvideo-technologies\u002Fvideo-codec-sdk\u002F12.1\u002Fnvdec-application-note\u002Findex.html#).\n\n![benchmark_results](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmeta-pytorch_torchcodec_readme_a416799c3486.png)\n\nThe top row is a [Mandelbrot](https:\u002F\u002Fffmpeg.org\u002Fffmpeg-filters.html#mandelbrot) video\ngenerated from FFmpeg that has a resolution of 1280x720 at 60 fps and is 120 seconds long.\nThe bottom row is [promotional video from NASA](https:\u002F\u002Fdownload.pytorch.org\u002Ftorchaudio\u002Ftutorial-assets\u002Fstream-api\u002FNASAs_Most_Scientifically_Complex_Space_Observatory_Requires_Precision-MP4_small.mp4)\nthat has a resolution of 960x540 at 29.7 fps and is 206 seconds long. Both videos were\nencoded with libx264 and yuv420p pixel format. All decoders, except for TorchVision, used FFmpeg 6.1.2. TorchVision used FFmpeg 4.2.2.\n\nFor TorchCodec, the \"approx\" label means that it was using [approximate mode](https:\u002F\u002Fmeta-pytorch.org\u002Ftorchcodec\u002Fstable\u002Fgenerated_examples\u002Fdecoding\u002Fapproximate_mode.html)\nfor seeking.\n\n## Contributing\n\nWe welcome contributions to TorchCodec! Please see our [contributing\nguide](CONTRIBUTING.md) for more details.\n\n## License\n\nTorchCodec is released under the [BSD 3 license](.\u002FLICENSE).\n\nHowever, TorchCodec may be used with code not written by Meta which may be\ndistributed under different licenses.\n\nFor example, if you build TorchCodec with ENABLE_CUDA=1 or use the CUDA-enabled\nrelease of torchcodec, please review CUDA's license here:\n[Nvidia licenses](https:\u002F\u002Fdocs.nvidia.com\u002Fcuda\u002Feula\u002Findex.html).\n","[**安装**](#installing-torchcodec) | [**简单示例**](#using-torchcodec) | [**详细示例**](https:\u002F\u002Fmeta-pytorch.org\u002Ftorchcodec\u002Fstable\u002Fgenerated_examples\u002F) | [**文档**](https:\u002F\u002Fmeta-pytorch.org\u002Ftorchcodec) | [**贡献指南**](CONTRIBUTING.md) | [**许可证**](#license)\n\n# TorchCodec\n\nTorchCodec 是一个用于将视频和音频数据解码为 PyTorch 张量的 Python 库，支持 CPU 和 CUDA GPU。它同时支持在 CPU 上进行视频和音频编码！其目标是快速、易用，并与 PyTorch 生态系统良好集成。如果你想使用 PyTorch 在视频和音频上训练机器学习模型，TorchCodec 就是你将其转换为数据的方式。\n\n我们通过以下方式实现这些功能：\n\n*   遵循 Python 和 PyTorch 惯例的 Pythonic API。\n*   依赖 [FFmpeg](https:\u002F\u002Fwww.ffmpeg.org\u002F) 进行解码和编码。TorchCodec 使用你系统上已安装的 FFmpeg 版本。FFmpeg 是一个成熟且覆盖广泛的库，在大多数系统上都可用。然而，它并不易用。TorchCodec 抽象了 FFmpeg 的复杂性，确保其被正确且高效地使用。\n*   将数据作为 PyTorch 张量返回，可以直接输入到 PyTorch 转换中或直接用于训练模型。\n\n## 使用 TorchCodec\n\n以下是 TorchCodec 功能的简要总结。更多详细示例，请[查看我们的文档](https:\u002F\u002Fmeta-pytorch.org\u002Ftorchcodec\u002Fstable\u002Fgenerated_examples\u002F)！\n\n#### 解码\n\n```python\nfrom torchcodec.decoders import VideoDecoder\n\ndevice = \"cpu\"  # 或者例如 \"cuda\" !\ndecoder = VideoDecoder(\"path\u002Fto\u002Fvideo.mp4\", device=device)\n\ndecoder.metadata\n# VideoStreamMetadata:\n#   num_frames: 250\n#   duration_seconds: 10.0\n#   bit_rate: 31315.0\n#   codec: h264\n#   average_fps: 25.0\n#   ... (输出已截断)\n\n# 简单的索引 API\ndecoder[0]  # 形状为 [C, H, W] 的 uint8 张量\ndecoder[0 : -1 : 20]  # 形状为 [N, C, H, W] 的 uint8 堆叠张量\n\n# 索引，附带 PTS（显示时间戳）和时长信息：\ndecoder.get_frames_at(indices=[2, 100])\n# FrameBatch:\n#   data (shape): torch.Size([2, 3, 270, 480])\n#   pts_seconds: tensor([0.0667, 3.3367], dtype=torch.float64)\n#   duration_seconds: tensor([0.0334, 0.0334], dtype=torch.float64)\n\n# 基于时间的索引，附带 PTS 和时长信息\ndecoder.get_frames_played_at(seconds=[0.5, 10.4])\n# FrameBatch:\n#   data (shape): torch.Size([2, 3, 270, 480])\n#   pts_seconds: tensor([ 0.4671, 10.3770], dtype=torch.float64)\n#   duration_seconds: tensor([0.0334, 0.0334], dtype=torch.float64)\n```\n\n#### 片段采样\n\n```python\n\nfrom torchcodec.samplers import clips_at_regular_timestamps\n\nclips_at_regular_timestamps(\n    decoder,\n    seconds_between_clip_starts=1.5,\n    num_frames_per_clip=4,\n    seconds_between_frames=0.1\n)\n# FrameBatch:\n#   data (shape): torch.Size([9, 4, 3, 270, 480])\n#   pts_seconds: tensor([[ 0.0000,  0.0667,  0.1668,  0.2669],\n#         [ 1.4681,  1.5682,  1.6683,  1.7684],\n#         [ 2.9696,  3.0697,  3.1698,  3.2699],\n#         ... (输出已截断), dtype=torch.float64)\n#   duration_seconds: tensor([[0.0334, 0.0334, 0.0334, 0.0334],\n#         [0.0334, 0.0334, 0.0334, 0.0334],\n#         [0.0334, 0.0334, 0.0334, 0.0334],\n#         ... (输出已截断), dtype=torch.float64)\n```\n\n你可以使用以下代码片段通过 FFmpeg 生成一个视频并试用 TorchCodec：\n\n```bash\nfontfile=\u002Fusr\u002Fshare\u002Ffonts\u002Fdejavu-sans-mono-fonts\u002FDejaVuSansMono-Bold.ttf\noutput_video_file=\u002Ftmp\u002Foutput_video.mp4\n\nffmpeg -f lavfi -i \\\n    color=size=640x400:duration=10:rate=25:color=blue \\\n    -vf \"drawtext=fontfile=${fontfile}:fontsize=30:fontcolor=white:x=(w-text_w)\u002F2:y=(h-text_h)\u002F2:text='Frame %{frame_num}'\" \\\n    ${output_video_file}\n```\n\n## 安装 TorchCodec\n### 安装仅支持 CPU 的 TorchCodec\n\n1.  按照[官方说明](https:\u002F\u002Fpytorch.org\u002Fget-started\u002Flocally\u002F)安装最新稳定版本的 PyTorch。对于其他版本，请参考下表了解 `torch` 和 `torchcodec` 版本之间的兼容性。\n\n2.  安装 FFmpeg（如果尚未安装）。TorchCodec 支持 [4, 8] 范围内的所有主要 FFmpeg 版本。\n    Linux 发行版通常预装了 FFmpeg。你需要附带独立共享库的 FFmpeg。这对于 Windows 用户尤其重要：这些版本通常被称为 \"shared\" 发行版。\n\n    如果尚未安装 FFmpeg，或者你需要更新的版本，一个简单的方法是使用 `conda`：\n\n    ```bash\n    conda install \"ffmpeg\"\n    # 或者\n    conda install \"ffmpeg\" -c conda-forge\n    ```\n\n3.  安装 TorchCodec：\n\n    ```bash\n    pip install torchcodec --index-url=https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fcpu\n    ```\n\n下表说明了 `torchcodec`、`torch` 和 Python 版本之间的兼容性。\n\n| `torchcodec`       | `torch`            | Python              |\n| ------------------ | ------------------ | ------------------- |\n| `main` \u002F `nightly` | `main` \u002F `nightly` | `>=3.10`, `\u003C=3.14`   |\n| `0.11`             | `2.11`             | `>=3.10`, `\u003C=3.14`   |\n| `0.10`             | `2.10`             | `>=3.10`, `\u003C=3.14`   |\n| `0.9`              | `2.9`              | `>=3.10`, `\u003C=3.14`   |\n| `0.8`              | `2.9`              | `>=3.10`, `\u003C=3.13`   |\n| `0.7`              | `2.8`              | `>=3.9`, `\u003C=3.13`   |\n| `0.6`              | `2.8`              | `>=3.9`, `\u003C=3.13`   |\n| `0.5`              | `2.7`              | `>=3.9`, `\u003C=3.13`   |\n| `0.4`              | `2.7`              | `>=3.9`, `\u003C=3.13`   |\n| `0.3`              | `2.7`              | `>=3.9`, `\u003C=3.13`   |\n| `0.2`              | `2.6`              | `>=3.9`, `\u003C=3.13`   |\n| `0.1`              | `2.5`              | `>=3.9`, `\u003C=3.12`   |\n| `0.0.3`            | `2.4`              | `>=3.8`, `\u003C=3.12`   |\n\n### 安装支持 CUDA 的 TorchCodec\n\n首先，请确保您的 GPU 具备 NVDEC 硬件，能够解码您所需的格式。更多详情请参考 Nvidia 的 GPU 支持矩阵 [此处](https:\u002F\u002Fdeveloper.nvidia.com\u002Fvideo-encode-and-decode-gpu-support-matrix-new)。\n\n1.  安装支持 NVDEC 的 FFmpeg。\n    支持 CUDA 的 TorchCodec 应与 FFmpeg 版本 [4, 8] 兼容。\n\n    如果尚未安装 FFmpeg，或者您需要更新的版本，一个简单的安装方法是使用 `conda`：\n\n    ```bash\n    conda install \"ffmpeg\"\n    # 或者\n    conda install \"ffmpeg\" -c conda-forge\n    ```\n\n    安装 FFmpeg 后，请确保在列出支持的解码器时显示其具备 NVDEC 支持：\n\n    ```bash\n    ffmpeg -decoders | grep -i nvidia\n    # 这应该显示类似这样的一行：\n    # V..... h264_cuvid           Nvidia CUVID H264 decoder (codec h264)\n    ```\n\n    要检查 FFmpeg 库是否正确支持 NVDEC，您可以解码一个示例视频：\n\n    ```bash\n    ffmpeg -hwaccel cuda -hwaccel_output_format cuda -i test\u002Fresources\u002Fnasa_13013.mp4 -f null -\n    ```\n\n#### Linux\n\n2.  使用 [官方说明](https:\u002F\u002Fpytorch.org\u002Fget-started\u002Flocally\u002F) 安装与您的 CUDA 工具包对应的 PyTorch。您将需要 `libnpp` 和 `libnvrtc` CUDA 库，这些通常是 CUDA 工具包的一部分。\n\n3.  安装 TorchCodec\n\n    在 Linux 上，`pip install torchcodec` 默认安装 CUDA 版本的 wheel 包，这与 `pip install torch` 的默认行为一致。\n\n    ```bash\n    pip install torchcodec\n    ```\n    使用 `--index-url` 来选择不同的 CUDA 工具包版本：\n\n    ```bash\n    # 这对应 CUDA 工具包版本 13.0。它应该与您安装 PyTorch 时使用的版本相同（如果您使用 pip 安装 PyTorch）。\n    pip install torchcodec --index-url=https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fcu130\n    ```\n\n#### Windows\n\n2.  在 Windows 上（实验性支持），您需要依赖 `conda` 来安装 PyTorch 和 TorchCodec：\n\n    ```bash\n    conda install -c conda-forge \"torchcodec=*=*cuda*\"\n    ```\n\n## 基准测试结果\n\n以下结果是在一台负载较轻的 22 核机器上运行 [我们的基准测试脚本](.\u002Fbenchmarks\u002Fdecoders\u002Fgenerate_readme_data.py) 生成的，该机器配备了具有 5 个 [NVDEC 解码器](https:\u002F\u002Fdocs.nvidia.com\u002Fvideo-technologies\u002Fvideo-codec-sdk\u002F12.1\u002Fnvdec-application-note\u002Findex.html#) 的 Nvidia A100 GPU。\n\n![benchmark_results](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmeta-pytorch_torchcodec_readme_a416799c3486.png)\n\n顶行是使用 FFmpeg 生成的 [曼德博集合](https:\u002F\u002Fffmpeg.org\u002Fffmpeg-filters.html#mandelbrot) 视频，分辨率为 1280x720，60 fps，时长为 120 秒。\n底行是 [NASA 的宣传视频](https:\u002F\u002Fdownload.pytorch.org\u002Ftorchaudio\u002Ftutorial-assets\u002Fstream-api\u002FNASAs_Most_Scientifically_Complex_Space_Observatory_Requires_Precision-MP4_small.mp4)，分辨率为 960x540，29.7 fps，时长为 206 秒。两个视频均使用 libx264 编码和 yuv420p 像素格式。除 TorchVision 外，所有解码器均使用 FFmpeg 6.1.2。TorchVision 使用 FFmpeg 4.2.2。\n\n对于 TorchCodec，\"approx\" 标签表示其使用了 [近似模式](https:\u002F\u002Fmeta-pytorch.org\u002Ftorchcodec\u002Fstable\u002Fgenerated_examples\u002Fdecoding\u002Fapproximate_mode.html) 进行跳转。\n\n## 贡献\n\n我们欢迎对 TorchCodec 做出贡献！详情请参阅我们的 [贡献指南](CONTRIBUTING.md)。\n\n## 许可证\n\nTorchCodec 在 [BSD 3 许可证](.\u002FLICENSE) 下发布。\n\n但是，TorchCodec 可能与并非由 Meta 编写的代码一起使用，这些代码可能根据不同的许可证分发。\n\n例如，如果您使用 ENABLE_CUDA=1 构建 TorchCodec 或使用支持 CUDA 的 torchcodec 版本，请在此处查看 CUDA 的许可证：\n[Nvidia 许可证](https:\u002F\u002Fdocs.nvidia.com\u002Fcuda\u002Feula\u002Findex.html)。","# TorchCodec 快速上手指南\n\nTorchCodec 是一个用于将视频和音频数据解码为 PyTorch 张量的 Python 库，支持 CPU 和 CUDA GPU。它同样支持在 CPU 上进行视频和音频编码！其目标是快速、易用，并与 PyTorch 生态系统深度集成。如果你希望使用 PyTorch 训练视频和音频的机器学习模型，TorchCodec 就是你处理数据的关键工具。\n\n## 环境准备\n\n### 系统要求\n- **Python**: 版本要求取决于你选择的 TorchCodec 版本，请参考下方兼容性表格。\n- **PyTorch**: 需要预先安装与 TorchCodec 版本兼容的 PyTorch。\n- **FFmpeg**: TorchCodec 依赖 FFmpeg（版本 4.x 至 8.x）进行编解码。请确保系统中已安装 FFmpeg 并包含共享库。\n\n### 版本兼容性\n| `torchcodec` 版本 | 兼容的 `torch` 版本 | 兼容的 Python 版本 |\n| :--- | :--- | :--- |\n| `main` \u002F `nightly` | `main` \u002F `nightly` | `>=3.10`, `\u003C=3.14` |\n| `0.11` | `2.11` | `>=3.10`, `\u003C=3.14` |\n| `0.10` | `2.10` | `>=3.10`, `\u003C=3.14` |\n| `0.9` | `2.9` | `>=3.10`, `\u003C=3.14` |\n| `0.8` | `2.9` | `>=3.10`, `\u003C=3.13` |\n| `0.7` | `2.8` | `>=3.9`, `\u003C=3.13` |\n| `0.6` | `2.8` | `>=3.9`, `\u003C=3.13` |\n| `0.5` | `2.7` | `>=3.9`, `\u003C=3.13` |\n| `0.4` | `2.7` | `>=3.9`, `\u003C=3.13` |\n| `0.3` | `2.7` | `>=3.9`, `\u003C=3.13` |\n| `0.2` | `2.6` | `>=3.9`, `\u003C=3.13` |\n| `0.1` | `2.5` | `>=3.9`, `\u003C=3.12` |\n| `0.0.3` | `2.4` | `>=3.8`, `\u003C=3.12` |\n\n## 安装步骤\n\n### 1. 安装 PyTorch\n请根据你的系统环境（CPU\u002FCUDA）和 TorchCodec 版本要求，前往 [PyTorch 官网](https:\u002F\u002Fpytorch.org\u002Fget-started\u002Flocally\u002F) 获取安装命令。\n\n### 2. 安装 FFmpeg\n如果你的系统尚未安装 FFmpeg，推荐使用 Conda 安装：\n```bash\nconda install \"ffmpeg\"\n# 或使用 conda-forge 频道\nconda install \"ffmpeg\" -c conda-forge\n```\n\n**对于 Windows 用户**：请确保安装的是包含共享库（通常标记为 “shared”）的 FFmpeg 版本。\n\n### 3. 安装 TorchCodec\n\n#### CPU 版本安装\n```bash\npip install torchcodec --index-url=https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fcpu\n```\n\n#### CUDA 版本安装（Linux）\n首先，请确认你的 GPU 支持 NVDEC 硬件解码，并已安装对应版本的 CUDA Toolkit。\n```bash\n# 默认安装（通常对应最新的 CUDA 版本）\npip install torchcodec\n# 或指定 CUDA Toolkit 版本（例如 CUDA 13.0）\npip install torchcodec --index-url=https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fcu130\n```\n\n#### CUDA 版本安装（Windows，实验性支持）\nWindows 用户建议通过 Conda 安装：\n```bash\nconda install -c conda-forge \"torchcodec=*=*cuda*\"\n```\n\n**安装后验证**：对于 CUDA 版本，可运行以下命令检查 FFmpeg 的 NVDEC 解码器是否可用：\n```bash\nffmpeg -decoders | grep -i nvidia\n# 预期输出类似： V..... h264_cuvid           Nvidia CUVID H264 decoder (codec h264)\n```\n\n## 基本使用\n\n以下是一个最简单的视频解码示例，展示如何加载视频并获取帧数据。\n\n```python\nfrom torchcodec.decoders import VideoDecoder\n\n# 初始化解码器，可指定设备为 \"cpu\" 或 \"cuda\"\ndevice = \"cpu\"\ndecoder = VideoDecoder(\"path\u002Fto\u002Fyour\u002Fvideo.mp4\", device=device)\n\n# 查看视频元数据\nprint(decoder.metadata)\n# 输出示例：\n# VideoStreamMetadata:\n#   num_frames: 250\n#   duration_seconds: 10.0\n#   bit_rate: 31315.0\n#   codec: h264\n#   average_fps: 25.0\n\n# 使用简单的索引 API 获取单帧（返回 uint8 张量，形状为 [C, H, W]）\nframe_tensor = decoder[0]\n\n# 使用切片获取多帧（返回 uint8 张量，形状为 [N, C, H, W]）\nframes_tensor = decoder[0:-1:20]\n\n# 获取指定索引的帧，并包含时间戳信息\nframe_batch = decoder.get_frames_at(indices=[2, 100])\nprint(frame_batch.data.shape)  # 例如：torch.Size([2, 3, 270, 480])\n```\n\n### 剪辑采样示例\n```python\nfrom torchcodec.samplers import clips_at_regular_timestamps\n\n# 从视频中按固定时间间隔采样剪辑\nclips = clips_at_regular_timestamps(\n    decoder,\n    seconds_between_clip_starts=1.5,  # 剪辑起始点间隔（秒）\n    num_frames_per_clip=4,            # 每个剪辑包含的帧数\n    seconds_between_frames=0.1        # 剪辑内帧间隔（秒）\n)\nprint(clips.data.shape)  # 例如：torch.Size([9, 4, 3, 270, 480])\n```","一家初创公司的 AI 研究员正在开发一个视频动作识别模型，需要从大量短视频中高效提取帧序列作为训练数据。\n\n### 没有 torchcodec 时\n- **流程繁琐**：需要先用 `OpenCV` 或 `ffmpeg-python` 等库读取视频，再将得到的 `numpy` 数组手动转换为 PyTorch 张量，代码冗长且容易出错。\n- **内存与速度瓶颈**：一次性加载整个视频到内存容易导致 OOM，而逐帧读取和解码的循环操作在 CPU 上非常缓慢，严重拖慢数据预处理流程。\n- **时间戳信息缺失**：常规方法很难精确获取每一帧的呈现时间戳（PTS）和持续时间，这对于需要基于时间进行采样（如等间隔抽取片段）的任务很不方便。\n- **GPU 数据加载效率低**：数据预处理在 CPU 上完成，生成的张量需要额外显式地传输到 GPU，增加了数据加载的延迟，无法充分利用 GPU 进行端到端加速。\n\n### 使用 torchcodec 后\n- **API 简洁直观**：直接使用 `VideoDecoder` 创建解码器，通过类似列表索引（如 `decoder[0:100:5]`）或专用方法（如 `get_frames_at`）即可获取张量，代码简洁且符合 PyTorch 生态习惯。\n- **高效灵活的读取**：支持灵活的张量切片和基于时间的精准帧查询，底层调用高效的 FFmpeg，解码速度快，并且能轻松处理超出内存的大视频文件。\n- **自带丰富元数据**：每次解码返回的 `FrameBatch` 对象不仅包含帧数据张量，还自动附带了精确的 `pts_seconds` 和 `duration_seconds`，方便进行基于时间的分析和采样。\n- **无缝 GPU 支持**：初始化时指定 `device=\"cuda\"` 即可直接在 GPU 内存中生成张量，避免了 CPU 到 GPU 的数据拷贝开销，使得从数据加载到模型训练形成高效的 GPU 流水线。\n\nTorchCodec 通过提供与 PyTorch 无缝集成的视频解码接口，将开发者从繁琐、低效的多媒体数据处理中解放出来，使其能专注于模型本身的开发与迭代。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmeta-pytorch_torchcodec_435d38ee.png","meta-pytorch","Meta PyTorch","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fmeta-pytorch_1dfd3f76.jpg","",null,"https:\u002F\u002Fpytorch.org","https:\u002F\u002Fgithub.com\u002Fmeta-pytorch",[84,88,92,96,100,104],{"name":85,"color":86,"percentage":87},"Python","#3572A5",49.1,{"name":89,"color":90,"percentage":91},"C++","#f34b7d",39.3,{"name":93,"color":94,"percentage":95},"C","#555555",7.6,{"name":97,"color":98,"percentage":99},"CMake","#DA3434",2.5,{"name":101,"color":102,"percentage":103},"Shell","#89e051",1.2,{"name":105,"color":106,"percentage":107},"Batchfile","#C1F12E",0.2,1036,98,"2026-04-02T19:48:41","BSD-3-Clause","Linux, Windows","支持 CPU 和 CUDA GPU。CUDA 版本需与 PyTorch 安装版本匹配，GPU 需支持 NVDEC 硬件解码（如 NVIDIA A100）。具体版本参考官方安装指南。","未说明",{"notes":116,"python":117,"dependencies":118},"1. 必须安装 FFmpeg，Linux 系统通常已预装，Windows 需安装 'shared' 版本。\n2. 使用 CUDA 功能需确保 FFmpeg 包含 NVDEC 支持（可通过 'ffmpeg -decoders | grep -i nvidia' 验证）。\n3. Windows 对 CUDA 支持为实验性，建议通过 conda 安装（'conda install -c conda-forge \"torchcodec=*=*cuda*\"'）。\n4. 安装时需通过 --index-url 指定 PyTorch 仓库（CPU 或对应 CUDA 版本）。\n5. 使用 CUDA 功能需遵守 NVIDIA 许可协议。",">=3.8, \u003C=3.14 (具体版本取决于 torchcodec 版本，详见兼容性表格)",[119,120],"torch (版本兼容性见表格)","ffmpeg (版本 4-8，需包含共享库，建议通过 conda 安装)",[52,13],4,"2026-03-27T02:49:30.150509","2026-04-06T05:16:53.511753",[126,131,136,141,146,151],{"id":127,"question_zh":128,"answer_zh":129,"source_url":130},4021,"TorchCodec 是否支持 Windows 系统？","是的，TorchCodec 现已支持 Windows。官方已发布适用于 Windows 的 CPU 版本 wheel 包。对于需要 GPU 支持的用户，可以通过 conda-forge 渠道安装。如果在 Windows 上运行 TorchCodec 时遇到问题，请创建一个新的 issue 并详细说明你是如何安装 torch 和 torchcodec 的。","https:\u002F\u002Fgithub.com\u002Fmeta-pytorch\u002Ftorchcodec\u002Fissues\u002F640",{"id":132,"question_zh":133,"answer_zh":134,"source_url":135},4022,"TorchCodec 是否支持 AArch64 (Linux ARM) 架构？","目前 TorchCodec 尚未提供官方的 AArch64 (Linux ARM) 架构的 wheel 包。从错误信息可以看到，当前可用的平台包括 `manylinux_2_28_x86_64`、`macosx_12_0_arm64` 和 `win_amd64`，但不包含 `manylinux_2_39_aarch64`。用户可以通过在配置文件中添加平台约束（如 `\"sys_platform == 'linux' and platform_machine == 'aarch64'\"`）来避免解析错误，但这并不能解决缺少对应 wheel 包的根本问题。","https:\u002F\u002Fgithub.com\u002Fmeta-pytorch\u002Ftorchcodec\u002Fissues\u002F569",{"id":137,"question_zh":138,"answer_zh":139,"source_url":140},4023,"在 Windows 上安装 TorchCodec 0.9.1 和 PyTorch 2.9 后，出现 `RuntimeError: Could not load libtorchcodec` 错误，如何解决？","此问题通常与 FFmpeg 的安装有关。根据维护者的回复，从 TorchCodec 0.9.1 版本开始，该问题应该已经修复（该版本与 PyTorch 2.9 兼容）。如果问题仍然存在，请确保：\n1.  你安装的是 `torchcodec 0.9.1` 或更高版本。\n2.  你的 PyTorch 版本是 2.9。\n如果确认版本正确但问题依旧，建议创建一个新的 issue 并提供详细信息。","https:\u002F\u002Fgithub.com\u002Fmeta-pytorch\u002Ftorchcodec\u002Fissues\u002F1006",{"id":142,"question_zh":143,"answer_zh":144,"source_url":145},4024,"在 macOS 上，通过 Homebrew 安装 FFmpeg 后，TorchCodec 无法导入，如何解决？","这个问题通常是由于 TorchCodec 无法找到或链接到通过 Homebrew 安装的 FFmpeg 动态库。一个有效的解决方案是使用 conda 来安装 FFmpeg。可以尝试以下命令：\n```bash\nconda install -c conda-forge ffmpeg\n```\n这可以确保 FFmpeg 库被安装在 conda 环境中，并且 TorchCodec 能够正确找到它们。","https:\u002F\u002Fgithub.com\u002Fmeta-pytorch\u002Ftorchcodec\u002Fissues\u002F570",{"id":147,"question_zh":148,"answer_zh":149,"source_url":150},4025,"在安装 PyTorch 2.9 RC（候选版本）时遇到 `RuntimeError: Could not load libtorchcodec` 错误，怎么办？","这个问题特定于 PyTorch 2.9 的 RC（发布候选）版本。根据维护者的说明，该问题已在后续版本中得到解决。如果你在稳定版（非RC版）的 PyTorch 2.9 中遇到类似的错误信息，原因可能不同。建议检查你使用的 TorchCodec 版本是否与 PyTorch 2.9 稳定版兼容（例如使用 0.9.1 或更高版本）。如果问题持续，请开启一个新的 issue 并提供详细信息。","https:\u002F\u002Fgithub.com\u002Fmeta-pytorch\u002Ftorchcodec\u002Fissues\u002F912",{"id":152,"question_zh":153,"answer_zh":154,"source_url":130},4026,"除了 TorchCodec，是否有其他替代的编解码库推荐？","是的，有用户推荐了另一个名为 **deffcode** 的库（GitHub: https:\u002F\u002Fgithub.com\u002FabhiTronix\u002Fdeffcode）。根据用户的基准测试，deffcode 在速度上表现优异。此外，deffcode 与 PyTorch 版本的强绑定关系较弱，这对于那些因 GPU 兼容性等原因无法总是升级 PyTorch 版本的项目来说可能是一个优势。",[156,161,166,171,176,181,186,191,196,201,206,211,216,221,226,231,236],{"id":157,"version":158,"summary_zh":159,"released_at":160},103459,"v0.11.0","[TorchCodec 0.11](https:\u002F\u002Fgithub.com\u002Fmeta-pytorch\u002Ftorchcodec\u002Freleases\u002Ftag\u002Fv0.11.0) is out! This release brings CUDA decoding improvements and improved HDR metadata and rotation support in VideoDecoder, as well as output fps support!\r\n\r\n## CUDA decoder performance improvements\r\n\r\nWe made significant improvements to the CUDA decoder throughput, available via the[ “beta” backend](https:\u002F\u002Fmeta-pytorch.org\u002Ftorchcodec\u002Fstable\u002Fgenerated\u002Ftorchcodec.decoders.set_cuda_backend.html#torchcodec.decoders.set_cuda_backend):\r\n* [#1232](https:\u002F\u002Fgithub.com\u002Fmeta-pytorch\u002Ftorchcodec\u002Fpull\u002F1232) fixed a bug in the decoder cache, allowing more than one decoder instance to be cached per video configuration. The fix doesn’t affect single-threaded pipelines, but drastically improves the throughput of [multi-threaded decoding](https:\u002F\u002Fmeta-pytorch.org\u002Ftorchcodec\u002Fstable\u002Fgenerated_examples\u002Fdecoding\u002Fparallel_decoding.html#method-4-joblib-multithreading).\r\n* [#1227](https:\u002F\u002Fgithub.com\u002Fmeta-pytorch\u002Ftorchcodec\u002Fpull\u002F1227) improved cache performance further.\r\n* [#1243](https:\u002F\u002Fgithub.com\u002Fmeta-pytorch\u002Ftorchcodec\u002Fpull\u002F1243) added an LRU eviction policy for the cache, which will improve the cache hit when decoding lots of different video configurations.\r\n* [#1246](https:\u002F\u002Fgithub.com\u002Fmeta-pytorch\u002Ftorchcodec\u002Fpull\u002F1246) added the [set_nvdec_cache_capacity()](https:\u002F\u002Fmeta-pytorch.org\u002Ftorchcodec\u002Fstable\u002Fgenerated\u002Ftorchcodec.decoders.set_nvdec_cache_capacity.html#torchcodec.decoders.set_nvdec_cache_capacity) which allows the user to control the cache size. Larger cache sizes are typically more performant, and more memory consuming.\r\n\r\nThese are available via the[ “beta” backend”](https:\u002F\u002Fmeta-pytorch.org\u002Ftorchcodec\u002Fstable\u002Fgenerated\u002Ftorchcodec.decoders.set_cuda_backend.html#torchcodec.decoders.set_cuda_backend). \r\n\r\n⚠️ Note that in the next release, the “beta” backend will become the default backend. This will be a transparent and backward-compatible change. Users who want to stay on the less efficient FFmpeg backend should use:\r\n\r\n```python\r\nwith set_cuda_backend(\"ffmpeg\"):\r\n    decoder = VideoDecoder(..., device=\"cuda\")\r\n```\r\nRead more about this in the [CUDA utilities section](https:\u002F\u002Fmeta-pytorch.org\u002Ftorchcodec\u002Fstable\u002Fapi_ref_decoders.html)!\r\n\r\n## FPS Resampling\r\n\r\n`get_frames_played_in_range()` now accepts a `fps` parameter to resample video at a target frame rate, duplicating or dropping frames as necessary to match the desired output FPS:\r\n\r\n```python\r\ndecoder = VideoDecoder(path)\r\n# If a source video is 25 fps, a 1-second range will contain 25 frames.\r\n# We can use the fps argument to resample to 5 fps, which gives us 5 frames:\r\nframes_5fps = decoder.get_frames_played_in_range(start_seconds=1, stop_seconds=2, fps=5)\r\n```\r\n\r\nRead the [VideoDecoder docs](https:\u002F\u002Fmeta-pytorch.org\u002Ftorchcodec\u002Fstable\u002Fgenerated\u002Ftorchcodec.decoders.VideoDecoder.html#torchcodec.decoders.VideoDecoder.get_frames_played_in_range) for more details!\r\n\r\n([#1148](https:\u002F\u002Fgithub.com\u002Fmeta-pytorch\u002Ftorchcodec\u002Fpull\u002F1148))\r\n\r\n## Rotation Support\r\n\r\nTorchCodec now automatically applies rotation metadata during video decoding on CPU and Beta Cuda backend. \r\n\r\n```python\r\ndecoder = VideoDecoder(path)\r\nprint(decoder.metadata.rotation)  # e.g. 90.0, or None\r\n```\r\n\r\n⚠️ Note that this is a BC-breaking change since we consider it a bug fix. Read more about this in the [VideoStreamMetadata docs](https:\u002F\u002Fmeta-pytorch.org\u002Ftorchcodec\u002Fstable\u002Fgenerated\u002Ftorchcodec.decoders.VideoStreamMetadata.html)!\r\n\r\n([#1173](https:\u002F\u002Fgithub.com\u002Fmeta-pytorch\u002Ftorchcodec\u002Fpull\u002F1173), [#1235](https:\u002F\u002Fgithub.com\u002Fmeta-pytorch\u002Ftorchcodec\u002Fpull\u002F1235))\r\n\r\n\r\n## HDR & Color Metadata\r\n\r\nVideo Decoder metadata now exposes color-related metadata and pixel format, making it easy to identify HDR content:\r\n\r\n```python\r\nmetadata = VideoDecoder(path).metadata\r\nprint(metadata.color_primaries)     # e.g. \"bt2020\"\r\nprint(metadata.color_space)         # e.g. \"bt2020nc\"\r\nprint(metadata.color_transfer)      # e.g. \"smpte2084\"\r\nprint(metadata.pixel_format)        # e.g. \"yuv420p10le\"\r\n```\r\n\r\nRead more about these fields in the [VideoStreamMetadata docs](https:\u002F\u002Fmeta-pytorch.org\u002Ftorchcodec\u002Fstable\u002Fgenerated\u002Ftorchcodec.decoders.VideoStreamMetadata.html)!\r\n\r\n([#1271](https:\u002F\u002Fgithub.com\u002Fmeta-pytorch\u002Ftorchcodec\u002Fpull\u002F1271), [#1261](https:\u002F\u002Fgithub.com\u002Fmeta-pytorch\u002Ftorchcodec\u002Fpull\u002F1261), [#1267](https:\u002F\u002Fgithub.com\u002Fmeta-pytorch\u002Ftorchcodec\u002Fpull\u002F1267))\r\n\r\n## Installation enhancements\r\n* On Linux, `pip install torchcodec` now defaults to the CUDA 13.0 wheel to match the behavior of `pip install torch`. See updated instructions in our [README](https:\u002F\u002Fgithub.com\u002Fmeta-pytorch\u002Ftorchcodec#installing-torchcodec).\r\n* Additionally, we have added aarch64 CUDA wheels to PyPI!\r\n\r\n### Bug Fixes\r\n\r\n- Fixed audio decoding issue when decoding audio with more than 8 channels. ([#1166](https:\u002F\u002Fgithub.com\u002Fmeta-pytorch\u002Ftorchcodec\u002Fpull\u002F1166))\r\n- Fixed MKV decoding being up to 42x slower than MP4 in approximate seek mode in some situations. ([#1259](https:\u002F\u002Fgithub.com\u002Fmeta-p","2026-03-24T16:39:48",{"id":162,"version":163,"summary_zh":164,"released_at":165},103460,"v0.10.0","[TorchCodec 0.10](https:\u002F\u002Fgithub.com\u002Fmeta-pytorch\u002Ftorchcodec\u002Freleases\u002Ftag\u002Fv0.10.0) is out! It is compatible with torch 2.10, and comes with exciting new features.\r\n\r\n## Decoder Transforms\r\nDecoder Transforms are available! We have released `Resize`, `CenterCrop`, `RandomCrop`, which can be used in `VideoDecoder` to transform data during preprocessing:\r\n```py\r\nresize_decoder = VideoDecoder(\r\n    video_path,\r\n    transforms= [\r\n        torchcodec.transforms.RandomCrop(size=(1280, 1664)),\r\n        torchcodec.transforms.Resize(size=(480, 640)),\r\n    ]\r\n)\r\nresized_frame = resize_decoder[5]\r\n```\r\nRead more about this in [the tutorial](https:\u002F\u002Fmeta-pytorch.org\u002Ftorchcodec\u002Fstable\u002Fgenerated_examples\u002Fdecoding\u002Ftransforms.html)! \r\n\r\nLet us know any transforms you want to see added in https:\u002F\u002Fgithub.com\u002Fmeta-pytorch\u002Ftorchcodec\u002Fissues\u002F1134!\r\n\r\n## Video Encoding on GPU\r\nVideoEncoder now supports encoding on GPU! This can improve performance by ~3x! \r\nTo use it, simply move the input frames onto the CUDA device before encoding:\r\n```py\r\nencoder = VideoEncoder(frames=frames.cuda(), frame_rate=frame_rate)\r\nencoder.to_file(dest=\"output.mp4\", codec=\"h264_nvenc\")\r\n```\r\n\r\n## Performance Tips guide\r\nCheck out our [new performance tips guide](https:\u002F\u002Fmeta-pytorch.org\u002Ftorchcodec\u002Fstable\u002Fgenerated_examples\u002Fdecoding\u002Fperformance_tips.html) to read about best practices to improve performance! \r\nThe guide covers batch APIs, decoding seek modes, multi-threading, GPU decoding, and checking for CPU fallback during decoding.\r\n\r\n### Enhancements\r\n* We've added a detailed stack trace when FFmpeg is not found. This should help debug installation issues on various development environments. (https:\u002F\u002Fgithub.com\u002Fmeta-pytorch\u002Ftorchcodec\u002Fpull\u002F1138)\r\n* On MacOS, we've improved Homebrew FFmpeg discoverability. (https:\u002F\u002Fgithub.com\u002Fmeta-pytorch\u002Ftorchcodec\u002Fpull\u002F1152, https:\u002F\u002Fgithub.com\u002Fmeta-pytorch\u002Ftorchcodec\u002Fpull\u002F1175, https:\u002F\u002Fgithub.com\u002Fmeta-pytorch\u002Ftorchcodec\u002Fpull\u002F1177)","2026-01-22T15:56:23",{"id":167,"version":168,"summary_zh":169,"released_at":170},103461,"v0.9.1","[TorchCodec 0.9.1](https:\u002F\u002Fgithub.com\u002Fmeta-pytorch\u002Ftorchcodec\u002Freleases\u002Ftag\u002Fv0.9.1) is out! This version is compatible with torch 2.9.\r\n\r\nThis is primarily a bug-fix release which should resolve issues on Windows where FFmpeg couldn't be found.","2025-12-10T16:41:10",{"id":172,"version":173,"summary_zh":174,"released_at":175},103462,"v0.9.0","[TorchCodec 0.9](https:\u002F\u002Fdocs.pytorch.org\u002Ftorchcodec\u002F0.9\u002F) is out! This comes with a new highly requested feature: video encoding!\r\n\r\n## Video Encoding\r\n\r\nVideo encoding on CPU is available. It provides a simple API to encode video frames to tensors or bytes, and optionally enables a set of key parameters.\r\n\r\n```py\r\nfrom torchcodec.encoders import VideoEncoder\r\n\r\nencoder = VideoEncoder(frames=frame_tensor, frame_rate=frame_rate)\r\n\r\nencoder.to_file(dest=\"output.mp4\") # encode to mp4 file\r\nencoded_bytes = encoder.to_tensor(format=\"mp4\") # encode to tensor of bytes\r\n\r\n```\r\n\r\nAdditionally, several key parameters are exposed to control the encoded video:\r\n\r\n```py\r\n# Utilize a specific codec, choose a pixel format to control quality\r\nencoder.to_file(dest=\"output.mp4\", codec=\"libx264\", pixel_format=\"yuv420p\")\r\n \r\n# Set quality parameter `crf` to 0 for lossless encoding, use fast `preset`\r\nencoded_bytes = encoder.to_tensor(format=\"mp4\", crf=0, preset=\"fast\")\r\n```\r\n\r\nRead more about the available features in the [video encoding tutorial](https:\u002F\u002Fmeta-pytorch.org\u002Ftorchcodec\u002F0.9\u002Fgenerated_examples\u002Fencoding\u002Fvideo_encoding.html)! \r\n\r\n### Enhancements\r\n* This release adds support for Python 3.14! \r\n* #989: Improved VideoDecoder metadata, enabling `seek_mode=approximate` for some videos with missing metadata.\r\n* #1028: Enhanced video decoding speed up to 1.5x when decoding frames sequentially with `seek_mode=\"approximate\"`.\r\n* #1078: Updated guidance on when to use approximate mode in [the tutorial](https:\u002F\u002Fmeta-pytorch.org\u002Ftorchcodec\u002F0.9\u002Fgenerated_examples\u002Fdecoding\u002Fapproximate_mode.html).\r\n\r\n### Bug fixes\r\n\r\n* #1025: Fixed bug: passing `device=None` in `VideoDecoder` now uses the current torch device.","2025-12-04T19:57:54",{"id":177,"version":178,"summary_zh":179,"released_at":180},103463,"v0.8.1","We are releasing TorchCodec 0.8.1 which is bug-fix release, compatible with torch 2.9.\r\n\r\n### The fix\r\n\r\nIn [0.8](https:\u002F\u002Fgithub.com\u002Fmeta-pytorch\u002Ftorchcodec\u002Freleases\u002Ftag\u002Fv0.8.0) we introduced our new \"beta\" backend which is much faster than our existing CUDA decoder (try it!!). But we also introduced a hard dependency on `libnvcuvid.so`, which isn't always available on the users machine. This would cause issues when `import torchcodec` was run.\r\n\r\nWe have now removed the hard dependency on `libnvcuvid.so`: if it cannot be found at runtime, the `VideoDecoder` will gracefully fallback to the CPU. This should resolve a lot of the ongoing `import torchcodec` errors. We're working on exposing an API that allows the user to know whether they're falling back to the CPU.\r\n\r\nThanks again to @traversaro for the original diagnosis and for the help testing the fix on Windows!\r\n\r\n### Enhancement\r\n\r\nWe also added support for FFmpeg 8 on Windows - we now support FFmpeg 4, 5, 6, 7, and 8 across all platforms (Linux, MacOS and Windows).","2025-10-28T10:13:29",{"id":182,"version":183,"summary_zh":184,"released_at":185},103464,"v0.8.0","[TorchCodec 0.8](https:\u002F\u002Fdocs.pytorch.org\u002Ftorchcodec\u002F0.8\u002F) is out, and is compatible with torch 2.9!\r\n\r\n## Faster GPU decoding!\r\n\r\nFaster video decoding on GPU is available, with our new Beta CUDA backend! We have observed **up to 3x speedups** compared to our previous GPU decoding implementation, and up to 90% NVDEC utilization. \r\n\r\nWe are releasing it as a Beta feature that we will polish over time, but we are confident it is ready to use, and we are eager to hear your feedback! Eventually, this Beta backend will become the default.\r\n\r\nTo use it, you just need to specify the [\"beta\" backend](https:\u002F\u002Fmeta-pytorch.org\u002Ftorchcodec\u002F0.8\u002Fgenerated\u002Ftorchcodec.decoders.set_cuda_backend.html#torchcodec.decoders.set_cuda_backend) when creating the `VideoDecoder` instance:\r\n\r\n```py\r\nfrom torchcodec.decoders import set_cuda_backend, VideoDecoder\r\n\r\nwith set_cuda_backend(\"beta\"):\r\n    dec = VideoDecoder(\"file.mp4\", device=\"cuda\")\r\n\r\n# All existing methods are supported\r\nbatch = dec.get_frames_at(...)\r\n```\r\n\r\n## Custom Frame Mappings\r\nVideo decoding now accepts pre-computed frame index data for faster `VideoDecoder` instantiation speeds, while maintaining exact frame seeking accuracy.\r\n\r\nRead more about this feature in [our tutorial](https:\u002F\u002Fmeta-pytorch.org\u002Ftorchcodec\u002F0.8\u002Fgenerated_examples\u002Fdecoding\u002Fcustom_frame_mappings.html#sphx-glr-generated-examples-decoding-custom-frame-mappings-py)!\r\n\r\n### Enhancements\r\n* #935, #947 - Enabled compatibility with FFmpeg8 for Linux and Mac\r\n* #899 - More robust support for 10-bit videos on CUDA.\r\n* #915 - Added support for tensor indices in `dec.get_frames_at(indices)` and for timestamps in `dec.get_frames_played_at(timestamps)`.\r\n\r\n### Bug fixes\r\n\r\n* #901 - Fixed a rare floating point error in `clips_at_regular_timestamps()`","2025-10-16T15:22:26",{"id":187,"version":188,"summary_zh":189,"released_at":190},103465,"v0.7.0","[TorchCodec 0.7](https:\u002F\u002Fdocs.pytorch.org\u002Ftorchcodec\u002F0.7\u002F) is out and it's compatible with torch 2.8!\r\n\r\n## Windows support\r\n\r\nThe main new feature is that TorchCodec now has *BETA* support for Windows! This is our [most popular](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Ftorchcodec\u002Fissues\u002F640) feature request to date. Windows users can try it out with `pip install torchcodec` for CPU, and use `conda-forge` for GPU support (thanks @traversaro !): `conda install torchcodec -c conda-forge`\r\n\r\nThis is currently in BETA support, so there may be rough edges. Let us know if you encounter any issue.\r\n\r\n### Enhancements\r\n\r\n- https:\u002F\u002Fgithub.com\u002Fpytorch\u002Ftorchcodec\u002Fpull\u002F865 improves audio decoding coverage of the `AudioDecoder` on some wav files with FFmpeg 4\r\n\r\n### Bug fixes\r\n\r\nThis release also comes with a few bug fixes:\r\n\r\n- https:\u002F\u002Fgithub.com\u002Fpytorch\u002Ftorchcodec\u002Fpull\u002F777 prevents silently wrong results for 10bit videos when decoding on the GPU. We'll be submitting more fixes for 10bit videos in the near future.\r\n- https:\u002F\u002Fgithub.com\u002Fpytorch\u002Ftorchcodec\u002Fpull\u002F852 allows  `AudioEncoder.to_file()` to accept a `pathlib.Path` instead of just a string\r\n- https:\u002F\u002Fgithub.com\u002Fpytorch\u002Ftorchcodec\u002Fpull\u002F868 Fixes a stream synchronization issue between NVDEC (the decoder) and NPP (the color conversion). If you weren't explicitly specifying custom CUDA stream for decoding, this doesn't affect you.","2025-09-08T14:43:52",{"id":192,"version":193,"summary_zh":194,"released_at":195},103466,"v0.6.0","This version is the same as 0.5, but adds compatibility with the latest PyTorch 2.8.","2025-08-07T09:03:55",{"id":197,"version":198,"summary_zh":199,"released_at":200},103467,"v0.5.0","**[TorchCodec 0.5](https:\u002F\u002Fpytorch.org\u002Ftorchcodec\u002F0.5\u002Findex.html) is out**! It is compatible with `torch 2.7`. This version comes with the highly requested feature:  Audio Encoding!\r\n\r\n## Audio Encoding\r\n\r\nYou can now encode audio samples to a file or to raw bytes!\r\n```py\r\nfrom torchcodec.encoders import AudioEncoder\r\n\r\nencoder = AudioEncoder(samples=samples, sample_rate=sample_rate)\r\n\r\nencoder.to_file(\"samples.mp3\")  # encode to a file\r\nencoded_bytes = encoder.to_tensor(format=\"mp3\")  # encode to a tensor of bytes\r\n```\r\n\r\nLearn more in our [tutorial](https:\u002F\u002Fdocs.pytorch.org\u002Ftorchcodec\u002Fstable\u002Fgenerated_examples\u002Fencoding\u002Faudio_encoding.html#sphx-glr-generated-examples-encoding-audio-encoding-py).\r\n\r\n### Parallel video decoding\r\nWe added a new tutorial for workflows to enable parallel video decoding using multi-processing and multi-threading. Read more in our [tutorial](https:\u002F\u002Fdocs.pytorch.org\u002Ftorchcodec\u002Fstable\u002Fgenerated_examples\u002Fdecoding\u002Fparallel_decoding.html#sphx-glr-generated-examples-decoding-parallel-decoding-py).\r\n\r\n## Additional features and improvements\r\n* Added a field to the Stream Metadata struct to contain sample\u002Fpixel aspect ratio to support non-square pixels.\r\n\r\n* Made changes to the `VideoDecoder` to be more resilient to missing metadata, specifically the number of frames in a stream or stream duration. It will use average FPS and other metadata to calculate these fields when they are missing.\r\n\r\n\r\n## Bug fixes\r\n* A bug fix in `VideoDecoder` and `AudioDecoder` when they are instantiated from bytes or a Tensor: they now adopt the data representing the video to ensure the data's lifetime matches that of the decoder. \r\n\r\n","2025-07-23T19:29:23",{"id":202,"version":203,"summary_zh":204,"released_at":205},103468,"v0.4.0","**[TorchCodec 0.4](https:\u002F\u002Fpytorch.org\u002Ftorchcodec\u002F0.4\u002Findex.html) is out**! It is a small release with:\r\n\r\n- A new `num_channels` parameter to [`AudioDecoder`](https:\u002F\u002Fdocs.pytorch.org\u002Ftorchcodec\u002F0.4\u002Fgenerated\u002Ftorchcodec.decoders.AudioDecoder.html#torchcodec.decoders.AudioDecoder), allowing you to directly specify whether you want to convert the audio to mono or stereo.\r\n- A bug fix which fixes the time conversion in our time-based APIs, which used to be incorrect for some specific videos.\r\n- A robustness improvement: TorchCodec is now able to decode poorly-encoded videos, when the PTS values are missing (it falls-back to DTS in that case). Previously, TorchCodec would fail on such videos.\r\n- A bug fix in `AudioDecoder.get_samples_played_in_range()`: if `stop_seconds` was before the first sample's start, we would return all the samples. Now, we raise a loud error.\r\n- A bug fix in `AudioDecoder.get_samples_played_in_range()` when `start_seconds == stop_seconds`: the shape of the output is now `(num_channels, 0)` instead of `(0, 0)`.","2025-05-16T09:27:02",{"id":207,"version":208,"summary_zh":209,"released_at":210},103469,"v0.3.0","**[TorchCodec 0.3.0](https:\u002F\u002Fpytorch.org\u002Ftorchcodec\u002F0.3\u002Findex.html) is out**! It comes with two new major features: Audio decoding, and Streaming.\r\n\r\n### Audio decoding\r\n\r\nYou can now decode audio streams from videos, or from audio files! The `AudioDecoder` looks a lot like the existing `VideoDecoder`:\r\n\r\n```py\r\nfrom torchcodec.decoders import AudioDecoder\r\n\r\ndecoder = AudioDecoder(path_to_audio)\r\nsamples = decoder.get_all_samples()\r\n\r\nprint(samples)\r\n# AudioSamples:\r\n#  data (shape): torch.Size([2, 4297722])\r\n#  pts_seconds: 0.02505668934240363\r\n#  duration_seconds: 97.45401360544217\r\n#  sample_rate: 44100\r\n```\r\n\r\nLean more in our [tutorial](https:\u002F\u002Fpytorch.org\u002Ftorchcodec\u002F0.3\u002Fgenerated_examples\u002Faudio_decoding.html#sphx-glr-generated-examples-audio-decoding-py).\r\n\r\n### Streaming\r\n\r\nYou can now decode steaming videos and audio! That is, when files do not reside locally, TorchCodec now supports downloading only the data segments that are needed to decode the frames you care about. The API is generic and integrates nicely with existing file-like interfaces like `fsspec` and others.\r\n\r\nLearn more in our [tutorial](https:\u002F\u002Fpytorch.org\u002Ftorchcodec\u002F0.3\u002Fgenerated_examples\u002Ffile_like.html#sphx-glr-generated-examples-file-like-py).\r\n\r\n\r\n-----\r\n\r\n#### Bug fixes\r\n\r\n- `VideoDecoder` now accept a `torch.device` parameter (https:\u002F\u002Fgithub.com\u002Fpytorch\u002Ftorchcodec\u002Fpull\u002F607)\r\n- Fix PTS of the first frame (https:\u002F\u002Fgithub.com\u002Fpytorch\u002Ftorchcodec\u002Fpull\u002F565)\r\n","2025-04-24T09:29:56",{"id":212,"version":213,"summary_zh":214,"released_at":215},103470,"v0.2.1","[TorchCodec 0.2.1](https:\u002F\u002Fpytorch.org\u002Ftorchcodec\u002F0.2\u002F) is out! This version is compatible with pytorch 2.6. This is small release with two quality-of-life improvements:\r\n\r\n- FFmpeg logs are deactivated, producing less verbose outputs.\r\n- Compatibility with Google colab: GPU decoding now works with FFmpeg 4 (in addition to 5, 6, 7), which is the default version supported by Google Colab.","2025-03-12T13:55:00",{"id":217,"version":218,"summary_zh":219,"released_at":220},103471,"v0.2.0","[TorchCodec 0.2.0](https:\u002F\u002Fpytorch.org\u002Ftorchcodec\u002F0.2\u002F) is out! This version is compatible with pytorch 2.6.\r\n\r\n\r\n### New features - perf improvement !\r\n\r\nThe main new feature is the addition of an **approximate seeking mode**, which can significantly improve the decoding performance:\r\n\r\n```py\r\ndecoder = VideoDecoder(video_path, seek_mode=\"approximate\")  # default value is \"exact\"\r\n```\r\n\r\nTo learn more, check out our [seek mode tutorial](https:\u002F\u002Fpytorch.org\u002Ftorchcodec\u002F0.2\u002Fgenerated_examples\u002Fapproximate_mode.html#sphx-glr-generated-examples-approximate-mode-py)!\r\n\r\n### Bug fixes\r\n\r\n-  Fixed AV1 decoding on CUDA (https:\u002F\u002Fgithub.com\u002Fpytorch\u002Ftorchcodec\u002Fpull\u002F448)","2025-02-05T17:49:49",{"id":222,"version":223,"summary_zh":224,"released_at":225},103472,"v0.1.1","[TorchCodec 0.1](https:\u002F\u002Fpytorch.org\u002Ftorchcodec\u002F0.1\u002F) is out ! It is **packed** with exciting features, and it is the first release of TorchCodec that we're pushing for wide adoption.\r\n\r\n- [Installation Instructions](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Ftorchcodec?tab=readme-ov-file#installing-torchcodec)\r\n- [Getting Started](https:\u002F\u002Fpytorch.org\u002Ftorchcodec\u002F0.1\u002Fgenerated_examples\u002Findex.html)\r\n\r\n# New features and improvements\r\n\r\n### GPU Decoding\r\n\r\nDecoding can now be done on CUDA GPUs by simply using the `device` parameter: `decoder = VideoDecoder(..., device=\"cuda\")`. GPU decoding can lead to faster decoding pipelines in a variety of cases. To learn more on how to use GPU decoding and how to install it, follow our [GPU decoding example](https:\u002F\u002Fpytorch.org\u002Ftorchcodec\u002F0.1\u002Fgenerated_examples\u002Fbasic_cuda_example.html#sphx-glr-generated-examples-basic-cuda-example-py)!\r\n\r\n### Clip sampling\r\n\r\nTorchCodec now supports fast clip samplers in the `torchcodec.samplers` namespace. We support random and regular sampling for both index-based and time-based strategies. Read more about samplers in our [sampling example](https:\u002F\u002Fpytorch.org\u002Ftorchcodec\u002F0.1\u002Fgenerated_examples\u002Fsampling.html#sphx-glr-generated-examples-sampling-py)!\r\n\r\n### Improvements to `VideoDecoder`\r\n\r\nNote: `SimpleVideoDecoder` became `VideoDecoder`! See below for other changes.\r\n\r\n- The `VideoDecoder` class now exposes the following parameter to provide users with more control:\r\n  - `num_ffmpeg_threads`\r\n  -  `stream_index`\r\n\r\n- Two new methods were added: `decoder.get_frames_at(indices=[3, 1, 10])` and `decoder.get_frames_played_at(seconds=[10.5, 0.3])`.  When decoding multiple frames, calling these method is a lot faster than calling `get_frame_at()` or `get_frame_played_at()` repeatedly.\r\n\r\nRead more on the [docs](https:\u002F\u002Fpytorch.org\u002Ftorchcodec\u002F0.1\u002Fgenerated\u002Ftorchcodec.decoders.VideoDecoder.html#torchcodec.decoders.VideoDecoder).\r\n\r\n### Speed improvements\r\n\r\nVarious performance improvements were made, including:\r\n\r\n- The decoder now automatically switches between the lower-level `swscale` and `filtergraph` libraries. These libraries are mainly used to convert YUV colors to RGB, and swscale usually leads to faster results. TorchCodec relies on one or the other when appropriate.\r\n- We now avoid extra copies of the output frame tensor in batch-decoding APIs \r\n\r\nYou can find detailed benchmark results on [the repo](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Ftorchcodec\u002Ftree\u002Fmain?tab=readme-ov-file#benchmark-results).\r\n\r\n### MacOS support\r\n\r\nTorchCodec now supports MacOS! Just run `pip install torchcodec` and follow our normal [installation instructions](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Ftorchcodec#installing-torchcodec).\r\n\r\n\r\n# Breaking changes\r\n\r\nTorchCodec is still in development stage and some APIs may be updated in future versions without a deprecation cycle, depending on user feedback. For this release, a few important API changes were made, but we do not anticipate significant changes of the sort in future releases, and we now consider the existing APIs largely stable. \r\n\r\n- The  `SimpleVideoDecoder` class was renamed to `VideoDecoder`\r\n- Methods of `VideoDecoder` containing the term \"displayed\" have been changed to the term \"played\". E.g. `get_frame_displayed_at()` is now  `get_frame_played_at()`. This is to accommodate for future audio support.\r\n- The `get_frames_at()` and `get_frames_displayed_at()` methods have been renamed to `get_frames_in_range()` and `get_frames_played_in_range()`. The method names `get_frames_at()` and `get_frames_played_at()` still exist, but they do something else (see new features section).\r\n\r\n# Bug fixes\r\n\r\n- Time-based decoding APIs were returning the wrong frame when the timestamp corresponded to the second-to-last frame. See https:\u002F\u002Fgithub.com\u002Fpytorch\u002Ftorchcodec\u002Fpull\u002F287 for more details.\r\n","2024-12-12T15:54:19",{"id":227,"version":228,"summary_zh":229,"released_at":230},103473,"v0.0.3","[TorchCodec 0.0.3](https:\u002F\u002Fpytorch.org\u002Ftorchcodec\u002F0.0.3\u002F) is out !\r\n\r\nThis is a small release which [fixes decoding frames for H265](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Ftorchcodec\u002Fissues\u002F179).","2024-08-15T17:05:10",{"id":232,"version":233,"summary_zh":234,"released_at":235},103474,"v0.0.2","[TorchCodec 0.0.2](https:\u002F\u002Fpytorch.org\u002Ftorchcodec\u002F0.0.2\u002F) is out !\r\n\r\nThis is a small release which adds the [`SimpleVideoDecoder.get_frames_displayed_at()`](https:\u002F\u002Fpytorch.org\u002Ftorchcodec\u002Fstable\u002Fgenerated\u002Ftorchcodec.decoders.SimpleVideoDecoder.html#torchcodec.decoders.SimpleVideoDecoder.get_frames_displayed_at) method.","2024-08-08T13:21:54",{"id":237,"version":238,"summary_zh":239,"released_at":240},103475,"v0.0.1","This is the first release of [TorchCodec](https:\u002F\u002Fpytorch.org\u002Ftorchcodec\u002F0.0.1\u002F)!","2024-08-08T13:23:32"]