mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-26 19:06:11 +01:00
48 lines
20 KiB
HTML
48 lines
20 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
<meta name="generator" content="Docusaurus v2.0.0-alpha.70">
|
|
<link rel="alternate" type="application/rss+xml" href="/frigate/blog/rss.xml" title="Frigate Blog RSS Feed">
|
|
<link rel="alternate" type="application/atom+xml" href="/frigate/blog/atom.xml" title="Frigate Blog Atom Feed">
|
|
<link rel="search" type="application/opensearchdescription+xml" title="Frigate" href="/frigate/opensearch.xml"><title data-react-helmet="true">nVidia hardware decoder | Frigate</title><meta data-react-helmet="true" name="twitter:card" content="summary_large_image"><meta data-react-helmet="true" name="docsearch:language" content="en"><meta data-react-helmet="true" name="docsearch:version" content="current"><meta data-react-helmet="true" name="docsearch:docusaurus_tag" content="docs-default-current"><meta data-react-helmet="true" property="og:title" content="nVidia hardware decoder | Frigate"><meta data-react-helmet="true" name="description" content="Certain nvidia cards include a hardware decoder, which can greatly improve the"><meta data-react-helmet="true" property="og:description" content="Certain nvidia cards include a hardware decoder, which can greatly improve the"><meta data-react-helmet="true" property="og:url" content="https://blakeblackshear.github.io/frigate/configuration/nvdec"><link data-react-helmet="true" rel="shortcut icon" href="/frigate/img/favicon.ico"><link data-react-helmet="true" rel="preconnect" href="https://BH4D9OD16A-dsn.algolia.net" crossorigin="anonymous"><link data-react-helmet="true" rel="canonical" href="https://blakeblackshear.github.io/frigate/configuration/nvdec"><link rel="stylesheet" href="/frigate/styles.4dd8d972.css">
|
|
<link rel="preload" href="/frigate/styles.e85537b2.js" as="script">
|
|
<link rel="preload" href="/frigate/runtime~main.ad423867.js" as="script">
|
|
<link rel="preload" href="/frigate/main.7d94a74f.js" as="script">
|
|
<link rel="preload" href="/frigate/1.893d6f7b.js" as="script">
|
|
<link rel="preload" href="/frigate/2.ed063b9f.js" as="script">
|
|
<link rel="preload" href="/frigate/25.8a84c34d.js" as="script">
|
|
<link rel="preload" href="/frigate/28.24760c23.js" as="script">
|
|
<link rel="preload" href="/frigate/935f2afb.ef68a5db.js" as="script">
|
|
<link rel="preload" href="/frigate/17896441.9ee5aadd.js" as="script">
|
|
<link rel="preload" href="/frigate/57316f1e.36317170.js" as="script">
|
|
</head>
|
|
<body>
|
|
<script>!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){var t=null;try{t=localStorage.getItem("theme")}catch(t){}return t}();t(null!==e?e:"light")}()</script><div id="__docusaurus">
|
|
<nav aria-label="Skip navigation links"><button type="button" tabindex="0" class="skipToContent_11B0">Skip to main content</button></nav><nav class="navbar navbar--fixed-top"><div class="navbar__inner"><div class="navbar__items"><div aria-label="Navigation bar toggle" class="navbar__toggle" role="button" tabindex="0"><svg aria-label="Menu" width="30" height="30" viewBox="0 0 30 30" role="img" focusable="false"><title>Menu</title><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></div><a class="navbar__brand" href="/frigate/"><img src="/frigate/img/logo.svg" alt="Frigate" class="themedImage_YANc themedImage--light_3CMI navbar__logo"><img src="/frigate/img/logo-dark.svg" alt="Frigate" class="themedImage_YANc themedImage--dark_3ARp navbar__logo"><strong class="navbar__title">Frigate</strong></a><a class="navbar__item navbar__link" href="/frigate/">Docs</a></div><div class="navbar__items navbar__items--right"><a href="https://github.com/blakeblackshear/frigate" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link">GitHub</a><div class="react-toggle react-toggle--disabled displayOnlyInLargeViewport_2N3Q"><div class="react-toggle-track"><div class="react-toggle-track-check"><span class="toggle_3NWk">🌜</span></div><div class="react-toggle-track-x"><span class="toggle_3NWk">🌞</span></div></div><div class="react-toggle-thumb"></div><input type="checkbox" disabled="" aria-label="Dark mode toggle" class="react-toggle-screenreader-only"></div><button type="button" class="DocSearch DocSearch-Button" aria-label="Search"><div class="DocSearch-Button-Container"><svg width="20" height="20" class="DocSearch-Search-Icon" viewBox="0 0 20 20"><path d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z" stroke="currentColor" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"></path></svg><span class="DocSearch-Button-Placeholder">Search</span></div></button></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div><div class="navbar-sidebar"><div class="navbar-sidebar__brand"><a class="navbar__brand" href="/frigate/"><img src="/frigate/img/logo.svg" alt="Frigate" class="themedImage_YANc themedImage--light_3CMI navbar__logo"><img src="/frigate/img/logo-dark.svg" alt="Frigate" class="themedImage_YANc themedImage--dark_3ARp navbar__logo"><strong class="navbar__title">Frigate</strong></a></div><div class="navbar-sidebar__items"><div class="menu"><ul class="menu__list"><li class="menu__list-item"><a class="menu__link" href="/frigate/">Docs</a></li><li class="menu__list-item"><a href="https://github.com/blakeblackshear/frigate" target="_blank" rel="noopener noreferrer" class="menu__link">GitHub</a></li></ul></div></div></div></nav><div class="main-wrapper"><div class="docPage_vMrn"><main class="docMainContainer_2iGs"><div class="container padding-vert--lg docItemWrapper_1bxp"><div class="row"><div class="col docItemCol_U38p"><div class="docItemContainer_a7m4"><article><header><h1 class="docTitle_Oumm">nVidia hardware decoder</h1></header><div class="markdown"><p>Certain nvidia cards include a hardware decoder, which can greatly improve the
|
|
performance of video decoding. In order to use NVDEC, a special build of
|
|
ffmpeg with NVDEC support is required. The special docker architecture 'amd64nvidia'
|
|
includes this support for amd64 platforms. An aarch64 for the Jetson, which
|
|
also includes NVDEC may be added in the future.</p><h2><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_prK2" id="docker-setup"></a>Docker setup<a class="hash-link" href="#docker-setup" title="Direct link to heading">#</a></h2><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_prK2" id="requirements"></a>Requirements<a class="hash-link" href="#requirements" title="Direct link to heading">#</a></h3><p><a href="https://www.nvidia.com/en-us/drivers/unix/" target="_blank" rel="noopener noreferrer">nVidia closed source driver</a> required to access NVDEC.
|
|
<a href="https://github.com/NVIDIA/nvidia-docker" target="_blank" rel="noopener noreferrer">nvidia-docker</a> required to pass NVDEC to docker.</p><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_prK2" id="setting-up-docker-compose"></a>Setting up docker-compose<a class="hash-link" href="#setting-up-docker-compose" title="Direct link to heading">#</a></h3><p>In order to pass NVDEC, the docker engine must be set to <code>nvidia</code> and the environment variables
|
|
<code>NVIDIA_VISIBLE_DEVICES=all</code> and <code>NVIDIA_DRIVER_CAPABILITIES=compute,utility,video</code> must be set.</p><p>In a docker compose file, these lines need to be set:</p><div class="mdxCodeBlock_1zKU"><div class="codeBlockContent_actS"><div tabindex="0" class="prism-code language-undefined codeBlock_tuNs thin-scrollbar"><div class="codeBlockLines_3uvA" style="color:#bfc7d5;background-color:#292d3e"><div class="token-line" style="color:#bfc7d5"><span class="token plain">services:</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain"> frigate:</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain"> ...</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain"> image: blakeblackshear/frigate:stable-amd64nvidia</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain"> runtime: nvidia</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain"> environment:</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain"> - NVIDIA_VISIBLE_DEVICES=all</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain"> - NVIDIA_DRIVER_CAPABILITIES=compute,utility,video</span></div></div></div><button type="button" aria-label="Copy code to clipboard" class="copyButton_2GIj">Copy</button></div></div><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_prK2" id="setting-up-the-configuration-file"></a>Setting up the configuration file<a class="hash-link" href="#setting-up-the-configuration-file" title="Direct link to heading">#</a></h3><p>In your frigate config.yml, you'll need to set ffmpeg to use the hardware decoder.
|
|
The decoder you choose will depend on the input video.</p><p>A list of supported codecs (you can use <code>ffmpeg -decoders | grep cuvid</code> in the container to get a list)</p><div class="mdxCodeBlock_1zKU"><div class="codeBlockContent_actS"><div tabindex="0" class="prism-code language-undefined codeBlock_tuNs thin-scrollbar"><div class="codeBlockLines_3uvA" style="color:#bfc7d5;background-color:#292d3e"><div class="token-line" style="color:#bfc7d5"><span class="token plain"> V..... h263_cuvid Nvidia CUVID H263 decoder (codec h263)</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain"> V..... h264_cuvid Nvidia CUVID H264 decoder (codec h264)</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain"> V..... hevc_cuvid Nvidia CUVID HEVC decoder (codec hevc)</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain"> V..... mjpeg_cuvid Nvidia CUVID MJPEG decoder (codec mjpeg)</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain"> V..... mpeg1_cuvid Nvidia CUVID MPEG1VIDEO decoder (codec mpeg1video)</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain"> V..... mpeg2_cuvid Nvidia CUVID MPEG2VIDEO decoder (codec mpeg2video)</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain"> V..... mpeg4_cuvid Nvidia CUVID MPEG4 decoder (codec mpeg4)</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain"> V..... vc1_cuvid Nvidia CUVID VC1 decoder (codec vc1)</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain"> V..... vp8_cuvid Nvidia CUVID VP8 decoder (codec vp8)</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain"> V..... vp9_cuvid Nvidia CUVID VP9 decoder (codec vp9)</span></div></div></div><button type="button" aria-label="Copy code to clipboard" class="copyButton_2GIj">Copy</button></div></div><p>For example, for H265 video (hevc), you'll select <code>hevc_cuvid</code>. Add
|
|
<code>-c:v hevc_covid</code> to your ffmpeg input arguments:</p><div class="mdxCodeBlock_1zKU"><div class="codeBlockContent_actS"><div tabindex="0" class="prism-code language-undefined codeBlock_tuNs thin-scrollbar"><div class="codeBlockLines_3uvA" style="color:#bfc7d5;background-color:#292d3e"><div class="token-line" style="color:#bfc7d5"><span class="token plain">ffmpeg:</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain"> input_args:</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain"> ...</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain"> - -c:v</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain"> - hevc_cuvid</span></div></div></div><button type="button" aria-label="Copy code to clipboard" class="copyButton_2GIj">Copy</button></div></div><p>If everything is working correctly, you should see a significant improvement in performance.
|
|
Verify that hardware decoding is working by running <code>nvidia-smi</code>, which should show the ffmpeg
|
|
processes:</p><div class="mdxCodeBlock_1zKU"><div class="codeBlockContent_actS"><div tabindex="0" class="prism-code language-undefined codeBlock_tuNs thin-scrollbar"><div class="codeBlockLines_3uvA" style="color:#bfc7d5;background-color:#292d3e"><div class="token-line" style="color:#bfc7d5"><span class="token plain">+-----------------------------------------------------------------------------+</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain">| NVIDIA-SMI 455.38 Driver Version: 455.38 CUDA Version: 11.1 |</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain">|-------------------------------+----------------------+----------------------+</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain">| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain">| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain">| | | MIG M. |</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain">|===============================+======================+======================|</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain">| 0 GeForce GTX 166... Off | 00000000:03:00.0 Off | N/A |</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain">| 38% 41C P2 36W / 125W | 2082MiB / 5942MiB | 5% Default |</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain">| | | N/A |</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain">+-------------------------------+----------------------+----------------------+</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain" style="display:inline-block">
|
|
</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain">+-----------------------------------------------------------------------------+</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain">| Processes: |</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain">| GPU GI CI PID Type Process name GPU Memory |</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain">| ID ID Usage |</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain">|=============================================================================|</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain">| 0 N/A N/A 12737 C ffmpeg 249MiB |</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain">| 0 N/A N/A 12751 C ffmpeg 249MiB |</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain">| 0 N/A N/A 12772 C ffmpeg 249MiB |</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain">| 0 N/A N/A 12775 C ffmpeg 249MiB |</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain">| 0 N/A N/A 12800 C ffmpeg 249MiB |</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain">| 0 N/A N/A 12811 C ffmpeg 417MiB |</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain">| 0 N/A N/A 12827 C ffmpeg 417MiB |</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain">+-----------------------------------------------------------------------------+</span></div></div></div><button type="button" aria-label="Copy code to clipboard" class="copyButton_2GIj">Copy</button></div></div><p>To further improve performance, you can set ffmpeg to skip frames in the output,
|
|
using the fps filter:</p><div class="mdxCodeBlock_1zKU"><div class="codeBlockContent_actS"><div tabindex="0" class="prism-code language-undefined codeBlock_tuNs thin-scrollbar"><div class="codeBlockLines_3uvA" style="color:#bfc7d5;background-color:#292d3e"><div class="token-line" style="color:#bfc7d5"><span class="token plain"> output_args:</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain"> - -filter:v</span></div><div class="token-line" style="color:#bfc7d5"><span class="token plain"> - fps=fps=5</span></div></div></div><button type="button" aria-label="Copy code to clipboard" class="copyButton_2GIj">Copy</button></div></div><p>This setting, for example, allows Frigate to consume my 10-15fps camera streams on
|
|
my relatively low powered Haswell machine with relatively low cpu usage.</p></div></article><div class="margin-vert--xl"><div class="row"><div class="col"><a href="https://github.com/blakeblackshear/frigate/edit/master/docs/docs/configuration/nvdec.md" target="_blank" rel="noreferrer noopener"><svg fill="currentColor" height="1.2em" width="1.2em" preserveAspectRatio="xMidYMid meet" role="img" viewBox="0 0 40 40" class="iconEdit_2LL7"><g><path d="m34.5 11.7l-3 3.1-6.3-6.3 3.1-3q0.5-0.5 1.2-0.5t1.1 0.5l3.9 3.9q0.5 0.4 0.5 1.1t-0.5 1.2z m-29.5 17.1l18.4-18.5 6.3 6.3-18.4 18.4h-6.3v-6.2z"></path></g></svg>Edit this page</a></div></div></div><div class="margin-vert--lg"><nav class="pagination-nav" aria-label="Blog list page navigation"><div class="pagination-nav__item"></div><div class="pagination-nav__item pagination-nav__item--next"></div></nav></div></div></div><div class="col col--3"><div class="tableOfContents_2xL- thin-scrollbar"><ul class="table-of-contents table-of-contents__left-border"><li><a href="#docker-setup" class="table-of-contents__link">Docker setup</a><ul><li><a href="#requirements" class="table-of-contents__link">Requirements</a></li><li><a href="#setting-up-docker-compose" class="table-of-contents__link">Setting up docker-compose</a></li><li><a href="#setting-up-the-configuration-file" class="table-of-contents__link">Setting up the configuration file</a></li></ul></li></ul></div></div></div></div></main></div></div><footer class="footer footer--dark"><div class="container"><div class="row footer__links"><div class="col footer__col"><h4 class="footer__title">Community</h4><ul class="footer__items"><li class="footer__item"><a href="https://github.com/blakeblackshear/frigate" target="_blank" rel="noopener noreferrer" class="footer__link-item">GitHub</a></li><li class="footer__item"><a href="https://github.com/blakeblackshear/frigate/discussions" target="_blank" rel="noopener noreferrer" class="footer__link-item">Discussions</a></li></ul></div></div><div class="footer__bottom text--center"><div class="footer__copyright">Copyright © 2021 Blake Blackshear</div></div></div></footer></div>
|
|
<script src="/frigate/styles.e85537b2.js"></script>
|
|
<script src="/frigate/runtime~main.ad423867.js"></script>
|
|
<script src="/frigate/main.7d94a74f.js"></script>
|
|
<script src="/frigate/1.893d6f7b.js"></script>
|
|
<script src="/frigate/2.ed063b9f.js"></script>
|
|
<script src="/frigate/25.8a84c34d.js"></script>
|
|
<script src="/frigate/28.24760c23.js"></script>
|
|
<script src="/frigate/935f2afb.ef68a5db.js"></script>
|
|
<script src="/frigate/17896441.9ee5aadd.js"></script>
|
|
<script src="/frigate/57316f1e.36317170.js"></script>
|
|
</body>
|
|
</html> |