{"id":642,"date":"2022-02-10T14:16:03","date_gmt":"2022-02-10T06:16:03","guid":{"rendered":"http:\/\/124.223.94.246\/?p=642"},"modified":"2024-01-11T17:51:03","modified_gmt":"2024-01-11T09:51:03","slug":"ffmpeg%e7%a1%ac%e4%bb%b6%e5%8a%a0%e9%80%9f-2","status":"publish","type":"post","link":"https:\/\/www.xianwaizhiyin.net\/?p=642","title":{"rendered":"FFmpeg\u786c\u4ef6\u52a0\u901f"},"content":{"rendered":"\n<p>\u672c\u6587 ffmpeg4.4.1 \u6e90\u7801\u4e3a\u51c6\uff0c\u7528\u4ee5\u4e0b\u547d\u4ee4\u5206\u6790 ffmpeg.c \u91cc\u9762\u7684\u786c\u4ef6\u52a0\u901f\u903b\u8f91\u5b9e\u73b0\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<p>\u547d\u4ee4\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"prettyprint\" >ffmpeg.exe -hwaccel cuvid -vcodec h264_cuvid -i juren_10s.mp4 -vcodec h264_nvenc -acodec copy juren_h264_nvenc_10s.mp4 -y<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<p>\u4ee5\u4e0a\u547d\u4ee4\u4f7f\u7528 h264_cuvid \u786c\u4ef6\u89e3\u7801 MP4\uff0c\u7136\u540e\u518d\u4f7f\u7528 h264_nvenc \u786c\u4ef6\u7f16\u7801\u6210 MP4\u3002juren_10s.mp4 \u4e0b\u8f7d\u5730\u5740\uff0c<a href=\"https:\/\/pan.baidu.com\/s\/1QSODN_t3kwLnF9Yf2wWhQQ\">\u767e\u5ea6\u7f51\u76d8<\/a>\uff0c\u63d0\u53d6\u7801\uff1a3khn<\/p>\n\n\n\n<p>\u5982\u4f55\u642d\u5efa qt creator \u7684 ffmpeg \u786c\u4ef6\u52a0\u901f\u8c03\u8bd5\u73af\u5883\uff0c\u8bf7\u770b\u4ee5\u4e0b\u6587\u7ae0\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u300a<strong>window10_ffmpeg-with-nvidia-gpu\u7f16\u8bd1<\/strong>\u300b<\/li>\n\n\n\n<li>\u300a<strong>ffmpeg-qt-msvc\u79fb\u690d\u8c03\u8bd5<\/strong>\u300b<\/li>\n<\/ul>\n\n\n\n<p>CUDA \u786c\u4ef6\u52a0\u901f\u7684\u4ee3\u7801\uff0c\u8c8c\u4f3c\u4e0d\u662fABI \u517c\u5bb9\u7684\uff0c\u6240\u4ee5\u53ea\u80fd\u7528 MSVC \u7f16\u8bd1\u51fa DLL\u3002\u7136\u540e qt creator \u91cc\u9762\u4e5f\u5fc5\u987b\u4f7f\u7528 msvc \u7f16\u8bd1\u8c03\u8bd5\uff0c\u4e0d\u80fd\u7528 MinGW \uff0c\u4f1a\u62a5\u9519\u3002<\/p>\n\n\n\n<p>\u5b8c\u6574\u9879\u76ee\u4e0b\u8f7d\uff1a<a href=\"https:\/\/pan.baidu.com\/s\/1RIuDvk8Ie6NYvNEC2qaaBQ\">\u767e\u5ea6\u7f51\u76d8<\/a>\uff0c\u63d0\u53d6\u7801\uff1a9yeu\uff0cqt creator \u7f16\u8bd1 Kits \u8bf7\u9009\u62e9 <strong>MSVC 2019 64 bits<\/strong> \uff0c\u8c03\u8bd5\u73af\u5883\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1260\" height=\"732\" src=\"\/wp-content\/uploads\/2022\/02\/cuda-code-1-1-1.png\" alt=\"\" class=\"wp-image-643\"\/><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<p>google_ads_content<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u5176\u5b9effmpeg.c \u5de5\u7a0b\u7684\u786c\u4ef6\u52a0\u901f\u4ee3\u7801\u57283\u5730\u65b9\u90fd\u6709\u5206\u5e03\uff0c\u89e3\u7801\uff0cfilter\uff0c\u7f16\u7801\u3002\u672c\u6587\u5206\u5f00\u8bb2\u8ff0\u3002<\/p>\n\n\n\n<p><strong>\u786c\u4ef6\u52a0\u901f\uff0c\u89e3\u7801\u7684\u6d41\u7a0b\u56fe\u5982\u4e0b\uff1a<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"290\" src=\"\/wp-content\/uploads\/2022\/02\/cuda-code-1-1-1-1.png\" alt=\"\" class=\"wp-image-661\"\/><\/figure>\n\n\n\n<p>\u9996\u5148\uff0c\u5728 ffmpeg_opt.c \u7684 add_input_streams() \u6dfb\u52a0\u8f93\u5165\u6d41\u7684\u65f6\u5019\uff0c\u521d\u59cb\u5316\u786c\u4ef6\u89e3\u7801\u76f8\u5173\u53d8\u91cf\u53c2\u6570\uff0c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"prettyprint\" >ffmpeg_opt.c \n            if (hwaccel) {\n                \/\/ The NVDEC hwaccels use a CUDA device, so remap the name here.\n                if (!strcmp(hwaccel, &quot;nvdec&quot;) || !strcmp(hwaccel, &quot;cuvid&quot;))\n                    hwaccel = &quot;cuda&quot;;\n\u200b\n                if (!strcmp(hwaccel, &quot;none&quot;))\n                    ist-&gt;hwaccel_id = HWACCEL_NONE;\n                else if (!strcmp(hwaccel, &quot;auto&quot;))\n                    ist-&gt;hwaccel_id = HWACCEL_AUTO;\n                else {\n                    enum AVHWDeviceType type;\n                    int i;\n                    for (i = 0; hwaccels&#091;i].name; i++) {\n                        if (!strcmp(hwaccels&#091;i].name, hwaccel)) {\n                            ist-&gt;hwaccel_id = hwaccels&#091;i].id;\n                            break;\n                        }\n                    }\n\u200b\n                    if (!ist-&gt;hwaccel_id) {\n                        type = av_hwdevice_find_type_by_name(hwaccel);\n                        if (type != AV_HWDEVICE_TYPE_NONE) {\n                            ist-&gt;hwaccel_id = HWACCEL_GENERIC;\n                            ist-&gt;hwaccel_device_type = type;\n                        }\n                    }\n\u200b\n                    if (!ist-&gt;hwaccel_id) {\n                        av_log(NULL, AV_LOG_FATAL, &quot;Unrecognized hwaccel: %s.\\n&quot;,\n                               hwaccel);\n                        av_log(NULL, AV_LOG_FATAL, &quot;Supported hwaccels: &quot;);\n                        type = AV_HWDEVICE_TYPE_NONE;\n                        while ((type = av_hwdevice_iterate_types(type)) !=\n                               AV_HWDEVICE_TYPE_NONE)\n                            av_log(NULL, AV_LOG_FATAL, &quot;%s &quot;,\n                                   av_hwdevice_get_type_name(type));\n                        av_log(NULL, AV_LOG_FATAL, &quot;\\n&quot;);\n                        exit_program(1);\n                    }\n                }\n            }<\/code><\/pre>\n\n\n\n<p>\u4e0a\u9762\u8fd9\u6bb5\u4ee3\u7801\u4e3b\u8981\u6709\u4ee5\u4e0b\u91cd\u70b9\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u89e3\u6790\u547d\u4ee4\u884c\u53c2\u6570 <code class=\"prettyprint\" >-hwaccel cuvid<\/code> \u5230 hwaccel \u53d8\u91cf\uff0c\u6240\u4ee5\u4e0a\u56fe\u4e2d\u7684 hwaccel \u7b49\u4e8e cuvid\uff0c\u540e\u7eed\u88ab\u5408\u5e76\u4fee\u6539\u4e3a cuda\u3002<\/li>\n\n\n\n<li>\u8bbe\u7f6e ist-&gt;hwaccel_id \uff0c\u5728\u672c\u73af\u5883\u4e2d\uff0c\u88ab\u8bbe\u7f6e\u4e3a HWACCEL_GENERIC\u3002<\/li>\n\n\n\n<li>\u8bbe\u7f6e ist-&gt;hwaccel_device_type\uff0c\u5728\u672c\u73af\u5883\u4e2d\uff0c\u88ab\u8bbe\u7f6e\u4e3a AV_HWDEVICE_TYPE_CUDA<\/li>\n\n\n\n<li>\u547d\u4ee4\u884c\u6ca1\u6307\u5b9a <code class=\"prettyprint\" >-hwaccel cuvid<\/code> \u4f1a\u5bfc\u81f4 ist-&gt;hwaccel_id \u6ca1\u8bbe\u7f6e\uff0c\u4f1a\u5f71\u54cd <code>get_format()<\/code> \u91cc\u9762\u7684\u903b\u8f91<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<p>\u7136\u540e\u5728 ffmpeg.c \u7684 init_input_stream() \u51fd\u6570\u91cc\u9762\uff0c\u521d\u59cb\u5316\u8f93\u5165\u6d41\u7684\u65f6\u5019\uff0c\u4e5f\u6709\u4e00\u90e8\u5206\u786c\u4ef6\u89e3\u7801\u76f8\u5173\u4ee3\u7801 \uff0c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"prettyprint\" >ffmpeg.c \nstatic int init_input_stream(int ist_index, char *error, int error_len)\n{\n    \/\/\u7701\u7565\u4ee3\u7801...\n    if (ist-&gt;decoding_needed) {\n        ist-&gt;dec_ctx-&gt;opaque                = ist;\n        \/\/\u6ce8\u610f get_format\n        ist-&gt;dec_ctx-&gt;get_format            = get_format;\n        ist-&gt;dec_ctx-&gt;get_buffer2           = get_buffer;\n        \u7701\u7565\u4ee3\u7801...\n    }\n    \n    ret = hw_device_setup_for_decode(ist);\n    if (ret &lt; 0) {\n        snprintf(error, error_len, &quot;Device setup failed for &quot;\n             &quot;decoder on input stream #%d:%d : %s&quot;,\n             ist-&gt;file_index, ist-&gt;st-&gt;index, av_err2str(ret));\n        return ret;\n    }\n    if ((ret = avcodec_open2(ist-&gt;dec_ctx, codec, &amp;ist-&gt;decoder_opts)) &lt; 0) {\n        \/\/\u7701\u7565\u4ee3\u7801...\n    }\n    \n    return 0;\n}<\/code><\/pre>\n\n\n\n<p>\u4e0a\u9762\u4ee3\u7801\uff0c\u6709\u4e24\u4e2a\u91cd\u70b9\u3002<\/p>\n\n\n\n<p>1\uff0chw_device_setup_for_decode() \u521d\u59cb\u5316\u786c\u4ef6\u89e3\u7801\u8bbe\u5907<\/p>\n\n\n\n<p>2\uff0cget_format() \uff0cget_format() \u8fd9\u662f\u4e00\u4e2a\u56de\u8c03\u51fd\u6570\uff0c\u5728 avcodec_open2() \u6253\u5f00\u7684\u89e3\u7801\u5668\u7684\u65f6\u5019\u4f1a\u8c03\u7528 get_format()\uff0c\u6839\u636e get_format \u7684\u8fd4\u56de\u503c\u51b3\u5b9a\u89e3\u7801\u5668\u8f93\u51fa\u54ea\u79cd \u50cf\u7d20\u683c\u5f0f\uff0c\u4e00\u822c\u89e3\u7801\u5668\u652f\u6301\u8f93\u51fa\u7684\u50cf\u7d20\u683c\u5f0f\u6709\u9650\uff0c\u4f8b\u5982 h264_cuvid \u53ea\u652f\u6301\u8f93\u51fa NV12 \u8ddf CUDA \u4e24\u79cd\u50cf\u7d20\u683c\u5f0f\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<p>\u5148\u8bb2 hw_device_setup_for_decode() \u51fd\u6570\uff0c\u4e3b\u8981\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"prettyprint\" >int hw_device_setup_for_decode(InputStream *ist)\n{\n    const AVCodecHWConfig *config;\n    enum AVHWDeviceType type;\n    HWDevice *dev = NULL;\n    int err, auto_device = 0;\n\u200b\n    if (ist-&gt;hwaccel_device) {\n        \/\/\u7701\u7565\u4ee3\u7801...\n        \/\/\u547d\u4ee4\u884c\u6ca1\u6307\u5b9a -hwaccel_device\uff0c\u8fd9\u91cc\u903b\u8f91\u6ca1\u6267\u884c\u3002\n    } else {\n        if (ist-&gt;hwaccel_id == HWACCEL_AUTO) {\n            auto_device = 1;\n        } else if (ist-&gt;hwaccel_id == HWACCEL_GENERIC) {\n            type = ist-&gt;hwaccel_device_type;\n            dev = hw_device_get_by_type(type);\n            if (!dev){\n                \/\/\u91cd\u70b9\u4ee3\u7801\n                err = hw_device_init_from_type(type, NULL, &amp;dev);\n            }\n        } else {\n            \/\/\u7701\u7565\u4ee3\u7801.\uff0c\u903b\u8f91\u6ca1\u6709\u6267\u884c\n        }\n    }\n\u200b\n    if (auto_device) {\n        \/\/\u7701\u7565\u4ee3\u7801.\uff0c\u903b\u8f91\u6ca1\u6709\u6267\u884c\n    }\n\u200b\n    if (!dev) {\n        av_log(ist-&gt;dec_ctx, AV_LOG_ERROR, &quot;No device available &quot;\n               &quot;for decoder: device type %s needed for codec %s.\\n&quot;,\n               av_hwdevice_get_type_name(type), ist-&gt;dec-&gt;name);\n        return err;\n    }\n\u200b    \/\/\u91cd\u70b9\u4ee3\u7801\n    ist-&gt;dec_ctx-&gt;hw_device_ctx = av_buffer_ref(dev-&gt;device_ref);\n    if (!ist-&gt;dec_ctx-&gt;hw_device_ctx)\n        return AVERROR(ENOMEM);\n\u200b\n    return 0;\n}<\/code><\/pre>\n\n\n\n<p>\u7531\u4e8e\u6211\u4eec\u547d\u4ee4\u884c\u6ca1\u4f7f\u7528 <code class=\"prettyprint\" >-hwaccel_device<\/code> \u6307\u5b9a\u786c\u4ef6\u52a0\u901f\u8bbe\u5907\uff0c\u6240\u4ee5 <code>if (ist-&gt;hwaccel_device) {xxx}<\/code> \u7684\u6761\u4ef6\u5e76\u6ca1\u6709\u8dd1\u8fdb\u53bb\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0a\u4ee3\u7801\u90fd\u662f\u7ecf\u8fc7\u5220\u51cf\u7684\u4ee3\u7801\uff0c\u6709\u4ee5\u4e0b\u91cd\u70b9\u3002<\/p>\n\n\n\n<p>1\uff0c\u8c03\u7528 <code class=\"prettyprint\" >hw_device_init_from_type(type, NULL, &amp;dev);<\/code> \u521d\u59cb\u5316 dev \u53d8\u91cf\u3002<\/p>\n\n\n\n<p>2\uff0c<code class=\"prettyprint\" >ist-&gt;dec_ctx-&gt;hw_device_ctx<\/code> \u521d\u59cb\u5316\uff0c\u7528\u4e86 av_buffer_ref() \u51fd\u6570\uff0cAVBuffer \u662fffmpeg\u7684\u4e00\u4e2a\u901a\u7528\u7ed3\u6784\uff0c\u5f88\u591a\u5b57\u6bb5\u90fd\u662f AVBuffer\u3002C\u8bed\u8a00\u5c31\u662f\u7528\u4e00\u5757void *\u5185\u5b58\u6765\u5b9e\u73b0\u6cdb\u578b\uff0c\u7136\u540e\u505a\u6307\u9488\u5f3a\u5236\u8f6c\u6362\uff0c\u8fd9\u5757\u5185\u5b58\u5c31\u4f1a\u88ab\u89e3\u6790\u6210\u76f8\u5e94\u7684\u7c7b\u578b\uff08struct\uff09\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<p>\u63a5\u7740\u5206\u6790 get_format \u51fd\u6570\uff0cget_format \u662f\u7528\u6765\u7ed9\u8c03\u7528\u5c42 \u51b3\u5b9a\u89e3\u7801\u51fa\u6765\u4ec0\u4e48\u6837\u7684 pixel format \u7684\u3002get_format() \u7684\u5b9a\u4e49\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"prettyprint\" >\/**\n* callback to negotiate the pixelFormat\n* @param fmt is the list of formats which are supported by the codec,\n* it is terminated by -1 as 0 is a valid format, the formats are ordered by quality.\n* The first is always the native one.\n* @note The callback may be called again immediately if initialization for\n* the selected (hardware-accelerated) pixel format failed.\n* @warning Behavior is undefined if the callback returns a value not\n* in the fmt list of formats.\n* @return the chosen format\n* - encoding: unused\n* - decoding: Set by user, if not set the native format will be chosen.\n*\/\nenum AVPixelFormat (*get_format)(struct AVCodecContext *s, const enum AVPixelFormat * fmt);<\/code><\/pre>\n\n\n\n<p>\u7b2c\u4e8c\u4e2a\u53c2\u6570 <strong>const enum AVPixelFormat * fmt<\/strong> \u662f\u89e3\u7801\u5668\u652f\u6301\u7684 \u50cf\u7d20\u683c\u5f0f\u3002\u672c\u547d\u4ee4\u4f7f\u7528\u7684\u89e3\u7801\u5668\u662f h264_cuvid \uff0c\u53ea\u652f\u6301 NV12\uff0cCUDA \u4e24\u79cd\u50cf\u7d20\u683c\u5f0f\u3002<\/p>\n\n\n\n<p>get_format \u51fd\u6570\u7684\u5b9e\u73b0\u5728 ffmpeg.c \u91cc\u9762\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"prettyprint\" >static enum AVPixelFormat get_format(AVCodecContext *s, const enum AVPixelFormat *pix_fmts)\n{\n    InputStream *ist = s-&gt;opaque;\n    const enum AVPixelFormat *p;\n    int ret;\n\u200b\n    \u7701\u7565\u4ee3\u7801...\n\u200b\n    return *p;\n}<\/code><\/pre>\n\n\n\n<p>\u4e3b\u8981\u6709\u4ee5\u4e0b\u91cd\u70b9\uff1a<\/p>\n\n\n\n<p>1\uff0c\u975e\u786c\u4ef6\u52a0\u901f\u7684\u89e3\u7801\u5668 \uff08NV12 \u50cf\u7d20\u683c\u5f0f\u662f\u975e\u786c\u4ef6\u52a0\u901f\u7684\uff09\uff0c\u9ed8\u8ba4\u53d6\u7b2c\u4e00\u4e2a\u652f\u6301\u7684\u50cf\u7d20\u683c\u5f0f\u4f5c\u4e3a\u89e3\u7801\u8f93\u51fa\u3002\u53ef\u4ee5\u770b\u5230\u8fd9\u91cc\u76f4\u63a5 break \uff0c\u8df3\u8fc7\u5faa\u73af\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"prettyprint\" >if (!(desc-&gt;flags &amp; AV_PIX_FMT_FLAG_HWACCEL))\n    break;<\/code><\/pre>\n\n\n\n<p>2\uff0c\u5982\u679c\u662f\u786c\u4ef6\u52a0\u901f\u7684\u89e3\u7801 \uff08CUDA \u50cf\u7d20\u683c\u5f0f\u662f\u786c\u4ef6\u52a0\u901f\u7684\uff09\uff0c\u5c31\u4f1a\u7ee7\u7eed\u6267\u884c\uff0c\u7528 avcodec_get_hw_config() \u627e\u51fa\u4e00\u4e2a config \u662f\u652f\u6301 AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX \u7684\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"prettyprint\" >if (ist-&gt;hwaccel_id == HWACCEL_GENERIC ||\n    ist-&gt;hwaccel_id == HWACCEL_AUTO) {\n    for (i = 0;; i++) {\n        config = avcodec_get_hw_config(s-&gt;codec, i);\n        if (!config)\n            break;\n        if (!(config-&gt;methods &amp;\n              AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX))\n            continue;\n        if (config-&gt;pix_fmt == *p)\n            break;\n    }\n}<\/code><\/pre>\n\n\n\n<p>3\uff0c\u5c1d\u8bd5\u521d\u59cb\u5316\u786c\u4ef6\u89e3\u7801\u5668\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"prettyprint\" > ret = hwaccel_decode_init(s);\n if (ret &lt; 0) {\n    if (ist-&gt;hwaccel_id == HWACCEL_GENERIC) {\n        av_log(NULL, AV_LOG_FATAL,\n            &quot;   %s hwaccel requested for input stream #%d:%d, &quot;\n                &quot;but cannot be initialized.\\n&quot;,\n                av_hwdevice_get_type_name(config-&gt;device_type),\n        ist-&gt;file_index, ist-&gt;st-&gt;index);\n        return AV_PIX_FMT_NONE;\n    }\n    continue;\n }<\/code><\/pre>\n\n\n\n<p>4\uff0c\u8bbe\u7f6e \u786c\u4ef6\u89e3\u7801\u8f93\u51fa\u7684 \u683c\u5f0f \u4e3a CUDA \u683c\u5f0f\uff0cbreak\uff0c\u7136\u540e\u4f1a return\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"prettyprint\" >ist-&gt;hwaccel_pix_fmt = *p;\nbreak;<\/code><\/pre>\n\n\n\n<p>\u4ee5\u4e0a\u5c31\u662f ffmpeg.c \u91cc get_foramt() \u5bf9\u4e8e\u666e\u901a\u7684\u89e3\u7801\u8ddf\u786c\u4ef6\u89e3\u7801\u7684\u533a\u522b\u5904\u7406\uff0c\u4e3b\u8981\u91cd\u70b9\u5982\u4e0b\uff1a<\/p>\n\n\n\n<p>1\uff0c\u666e\u901a\u89e3\u7801\u76f4\u63a5\u8fd4\u56de\u7b2c\u4e00\u4e2a\u89e3\u7801\u5668\u652f\u6301\u7684\u50cf\u7d20\u683c\u5f0f\u3002<\/p>\n\n\n\n<p>2\uff0c\u786c\u4ef6\u89e3\u7801\u4f1a\u591a\u505a\u4e00\u4e9b\u68c0\u6d4b\uff0c\u8ddf\u53d8\u91cf\u521d\u59cb\u5316\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<p>\u786c\u4ef6\u89e3\u7801\u8fd8\u6709\u4e00\u4e2a\u51fd\u6570 get_buffer()\uff0c\u4e5f\u662f\u5728 ffmpeg.c \u91cc\u9762\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"prettyprint\" >static int get_buffer(AVCodecContext *s, AVFrame *frame, int flags)\n{\n    InputStream *ist = s-&gt;opaque;\n\u200b\n    if (ist-&gt;hwaccel_get_buffer &amp;&amp; frame-&gt;format == ist-&gt;hwaccel_pix_fmt)\n        return ist-&gt;hwaccel_get_buffer(s, frame, flags);\n\u200b\n    return avcodec_default_get_buffer2(s, frame, flags);\n}<\/code><\/pre>\n\n\n\n<p>\u8fd9\u91cc\u9762\u5176\u5b9e\u662f\u5bf9 qsv \u786c\u4ef6\u89e3\u7801\u505a\u4e86\u7279\u6b8a\u5904\u7406\uff0cist-&gt;hwaccel_get_buffer \u8fd9\u4e2a\u53ea\u4f1a\u5728 qsv_init() \u91cc\u9762\u88ab\u521d\u59cb\u5316\u8d4b\u503c\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u7528\u7684\u662f cuda\uff0c\u4f1a\u76f4\u63a5\u8d70\u9ed8\u8ba4\u7684 get_buffer \u51fd\u6570\uff0c\u5c31\u662f avcodec_default_get_buffer2()\u3002<\/p>\n\n\n\n<p>\u81f3\u6b64 \uff0cffmpeg \u7684\u786c\u4ef6\u89e3\u7801\u5df2\u7ecf\u5206\u6790\u5b8c\u6bd5\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<p><strong>\u786c\u4ef6\u52a0\u901f filter\u7684\u5904\u7406\u5982\u4e0b\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"prettyprint\" >ffmpeg_filter.c 1037\u884c\nret = hw_device_setup_for_filter(fg);<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"prettyprint\" >int hw_device_setup_for_filter(FilterGraph *fg)\n{\n    HWDevice *dev;\n    int i;\n\u200b\n    \/\/ If the user has supplied exactly one hardware device then just\n    \/\/ give it straight to every filter for convenience.  If more than\n    \/\/ one device is available then the user needs to pick one explcitly\n    \/\/ with the filter_hw_device option.\n    if (filter_hw_device)\n        dev = filter_hw_device;\n    else if (nb_hw_devices == 1)\n        dev = hw_devices&#091;0];\n    else\n        dev = NULL;\n\u200b\n    if (dev) {\n        for (i = 0; i &lt; fg-&gt;graph-&gt;nb_filters; i++) {\n            fg-&gt;graph-&gt;filters&#091;i]-&gt;hw_device_ctx =\n                av_buffer_ref(dev-&gt;device_ref);\n            if (!fg-&gt;graph-&gt;filters&#091;i]-&gt;hw_device_ctx)\n                return AVERROR(ENOMEM);\n        }\n    }\n\u200b\n    return 0;\n}<\/code><\/pre>\n\n\n\n<p>hw_device_setup_for_filter() \u91cd\u70b9\u5c31\u662f\u8bbe\u7f6e\u4e86 filter\u91cc\u9762\u7684 hw_device_ctx \u53d8\u91cf\uff0c\u4f30\u8ba1\u662f\u7528\u6765\u5904\u7406 \u786c\u4ef6\u50cf\u7d20\u683c\u5f0f\u7684 filter \u903b\u8f91\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<p><strong>\u786c\u4ef6\u52a0\u901f\uff0c\u7f16\u7801\u6d41\u7a0b\u56fe\u5982\u4e0b\uff1a<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"485\" height=\"135\" src=\"\/wp-content\/uploads\/2022\/02\/cuda-code-1-1-2.png\" alt=\"\" class=\"wp-image-662\"\/><\/figure>\n\n\n\n<p>hw_device_setup_for_encode() \u51fd\u6570\u91cc\u7684\u4ee3\u7801\u5c31\u4e0d\u7c98\u8d34\u4e86\uff0c\u6bd4\u8f83\u5bb9\u6613\u7406\u89e3\uff0c\u5728\u672c\u6587\u547d\u4ee4\u91cc\u4e3b\u8981\u5c31\u8bbe\u7f6e\u4e86\u4e00\u4e2a\u53d8\u91cf <code class=\"prettyprint\" >ost-&gt;enc_ctx-&gt;hw_frames_ctx<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"prettyprint\" >hw_device_setup_for_encode()\nost-&gt;enc_ctx-&gt;hw_frames_ctx = av_buffer_ref(frames_ref);<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<p>google_ads_content<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u547d\u4ee4\u884c\u53c2\u6570\u4e2d\uff0c\u6709\u4e2a\u5947\u602a\u7684\u5730\u65b9\uff0c -hwaccel cuvid\uff0c\u6211\u4e2a\u4eba\u6bd4\u8f83\u7591\u60d1\uff0c\u8fd9\u4e2a\u53c2\u6570\u8d77\u5230\u4ec0\u4e48\u6837\u7684\u4f5c\u7528\uff0c\u786c\u4ef6\u7f16\u89e3\u7801\u5e94\u8be5\u53ea\u9700\u8981\u6307\u5b9a\u89e3\u7801\u5668\u662f\u4ec0\u4e48\u5c31\u884c\u4e86\uff0c\u4e3a\u4ec0\u4e48\u8fd8\u8981\u591a\u6b64\u4e00\u4e3e\u6307\u5b9a -hwaccel cuvid \u5462\uff1f\u5e26\u7740\u8fd9\u4e2a\u7591\u95ee\u7ee7\u7eed\u7814\u7a76\u3002\u63a5\u4e0b\u6765\u5206\u6790\u5982\u679c\u6ca1\u6709\u6307\u5b9a <code class=\"prettyprint\" >-hwaccel cuvid<\/code> \u8fd9\u4e2a\u4f1a\u6709\u4f55\u5f71\u54cd\uff0c\u547d\u4ee4\u5982\u4e0b\uff1a<\/p>\n\n\n\n<p><code class=\"prettyprint\" >ffmpeg.exe -vcodec h264_cuvid -i juren_10s.mp4 -vcodec h264_nvenc -acodec copy juren_h264_nvenc_10s.mp4 -y<\/code><\/p>\n\n\n\n<p>\u6ca1\u8bbe\u7f6e <code class=\"prettyprint\" >-hwaccel cuvid<\/code> \u4f1a\u5bfc\u81f4\u4ee5\u4e0b\u53d8\u5316\uff1a<\/p>\n\n\n\n<p>1\uff0c\u5bfc\u81f4 add_input_streams() \u91cc\u9762\u7684\u4ee5\u4e0b\u903b\u8f91\u4e0d\u4f1a\u6267\u884c\uff0c\u5bfc\u81f4 ist-&gt;hwaccel_id \u6ca1\u6709\u503c \u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"prettyprint\" >add_input_streams()\nif( hwaccel ){ \n    \u8bbe\u7f6e ist-&gt;hwaccel_id \n    \u8bbe\u7f6e ist-&gt;hwaccel_device_type\n}<\/code><\/pre>\n\n\n\n<p>2\uff0cist-&gt;hwaccel_id \u6ca1\u6709\u503c\uff0c\u5c31\u4f1a\u5bfc\u81f4 get_format() \u51fd\u6570\u8fd4\u56de\u7684 <code class=\"prettyprint\" >AVPixelFormat *p<\/code> \u662f NV12\uff0c\u800c\u4e0d\u662f CUDA\u3002\u8fd9\u91cc NV12 \u662f\u6ca1\u6709 AV_PIX_FMT_FLAG_HWACCEL \u8fd9\u4e2a\u6807\u8bb0\u7684\uff0cCUDA\u6709\u8fd9\u4e2a\u6807\u8bb0\u3002\u6240\u4ee5\u4f1a\u5bfc\u81f4 h264_cuvid \u8fd9\u4e2a\u89e3\u7801\u5668\u8f93\u51fa\u7684 AVFrame \u662f NV12 \u683c\u5f0f\u7684\uff0c\u4e0d\u662f\u539f\u6765\u7684 CUDA \u683c\u5f0f\u3002\u4f46 h264_cuvid \u4f9d\u7136\u662f\u4e00\u4e2a\u786c\u4ef6\u89e3\u7801\u5668\u3002<\/p>\n\n\n\n<p>3\uff0c\u5f71\u54cd hw_device_setup_for_decode() \u51fd\u6570\u7684\u903b\u8f91\uff0c\u5bfc\u81f4 ist-&gt;dec_ctx-&gt;hw_device_ctx \u6ca1\u6709\u503c\u3002<\/p>\n\n\n\n<p>4\uff0c\u5f71\u54cd hw_device_setup_for_decode() \u51fd\u6570\u7684\u903b\u8f91\uff0c\u5bfc\u81f4 hw_device_init_from_type() \u6ca1\u6709\u6267\u884c\uff0c\u6240\u4ee5\u53d8\u91cf nb_hw_devices \u7b49\u4e8e 0\uff0c\u5e94\u8be5\u662f\u6ca1\u6709\u786c\u4ef6\u8bbe\u5907\u7684\u610f\u601d\u3002<\/p>\n\n\n\n<p>4\uff0c\u53d8\u91cf nb_hw_devices \u7b49\u4e8e 0 \u4f1a\u5f71\u54cd hw_device_setup_for_filter() \u51fd\u6570\u7684\u903b\u8f91\uff0c\u5bfc\u81f4 <code class=\"prettyprint\" >fg-&gt;graph-&gt;filters[i]-&gt;hw_device_ctx<\/code> \u6ca1\u6709\u8d4b\u503c\uff0chw_device_setup_for_filte() \u51fd\u6570\u7684\u4ee3\u7801\u4e0a\u9762\u6709\uff0c\u4e0d\u8d34\u4e86\u3002<\/p>\n\n\n\n<p>5\uff0c<code class=\"prettyprint\" >fg-&gt;graph-&gt;filters[i]-&gt;hw_device_ctx<\/code> \u6ca1\u6709\u8d4b\u503c\uff0c\u4f1a\u5bfc\u81f4 hw_device_setup_for_encode() \u91cc\u9762\u7684 av_buffersink_get_hw_frames_ctx() \u51fd\u6570\u62ff\u4e0d\u5230\u503c\uff0c\u8fdb\u800c\u5bfc\u81f4 <code>ost-&gt;enc_ctx-&gt;hw_frames_ctx<\/code> \u6ca1\u6709\u88ab\u8bbe\u7f6e\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"prettyprint\" >hw_device_setup_for_encode()\nframes_ref = av_buffersink_get_hw_frames_ctx(ost-&gt;filter-&gt;filter);\nost-&gt;enc_ctx-&gt;hw_frames_ctx = av_buffer_ref(frames_ref); \/\/\u6ca1\u6709\u6267\u884c<\/code><\/pre>\n\n\n\n<p>\u505a\u4e0b\u603b\u7ed3\uff0c <code class=\"prettyprint\" >-hwaccel cuvid<\/code> \u6ca1\u8bbe\u7f6e\uff0c\u6240\u4ee5<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>ist-&gt;hwaccel_id \u6ca1\u6709\u503c<\/li>\n\n\n\n<li>ist-&gt;hwaccel_device_type \u6ca1\u6709\u503c<\/li>\n\n\n\n<li>ist-&gt;dec_ctx-&gt;hw_device_ctx \u6ca1\u6709\u503c<\/li>\n\n\n\n<li>nb_hw_devices \u7b49\u4e8e 0<\/li>\n\n\n\n<li>fg-&gt;graph-&gt;filters[i]-&gt;hw_device_ctx \u6ca1\u6709\u503c<\/li>\n\n\n\n<li>ost-&gt;enc_ctx-&gt;hw_frames_ctx \u6ca1\u6709\u503c<\/li>\n<\/ol>\n\n\n\n<p>\u91cd\u70b9\uff1a\u89e3\u7801\u7684\u65f6\u5019\u7528\u7684\u662f dec_ctx-&gt;hw_device_ctx ,\u7f16\u7801\u7684\u65f6\u5019\u8bbe\u7f6e\u7684 enc_ctx-&gt;hw_frames_ctx\uff0chw_device_ctx \u8ddf hw_frames_ctx \u5e94\u8be5\u662f\u4e24\u4e2a\u4e0d\u540c\u7684\u4e1c\u897f\uff0c\u8fd9\u91cc\u57cb\u4e2a\u5751\uff0c\u540e\u7eed\u8bb2\u89e3\u3002<\/p>\n\n\n\n<p>\u867d\u7136\u6ca1\u8bbe\u7f6e <code class=\"prettyprint\" >-hwaccel cuvid<\/code> \u5bfc\u81f4\u8fd9\u4e48\u591a\u53d8\u91cf\u6ca1\u6709\u503c\uff0c\u4f46\u662f\u6211\u770b\u6211\u7684GPU\uff0c\u5374\u5b9e\u5b9e\u5728\u5728\u8dd1\u6ee1\u4e86\uff0c\u8fd9\u4e2a\u95ee\u9898\uff0c\u6211\u4e5f\u767e\u601d\u4e0d\u5f97\u5176\u89e3\uff0c\u5982\u4e0b\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"555\" height=\"585\" src=\"\/wp-content\/uploads\/2022\/02\/cuda-code-1-1-3.png\" alt=\"\" class=\"wp-image-663\"\/><\/figure>\n\n\n\n<p>\u4ece\u4e0a\u9762\u7684\u5206\u6790\u770b\u8d77\u6765\uff0c<code class=\"prettyprint\" >-hwaccel cuvid<\/code> \u8c8c\u4f3c\u5e76\u4e0d\u4f1a\u5f71\u54cd\u5230\u4f7f\u7528GPU\u7f16\u89e3\u7801<\/p>\n\n\n\n<p>\u8ba8\u8bba\u8865\u5145\uff1a<\/p>\n\n\n\n<p>CUDA \u8ddf CUVID \u662f ffmpeg \u5b9e\u73b0\u7684\u4e24\u79cd\u4f7f\u7528\u786c\u4ef6\u52a0\u901f\u7684\u65b9\u5f0f\uff0c\u4e3b\u8981\u533a\u522b\u662f frame \u600e\u4e48\u89e3\u7801\uff0c\u7136\u540e\u5185\u5b58\u6570\u636e\u600e\u4e48\u8f6c\u53d1\u3002<\/p>\n\n\n\n<p>\u7f51\u5740\uff1a<strong><a href=\"https:\/\/trac.ffmpeg.org\/wiki\/HWAccelIntro\">https:\/\/trac.ffmpeg.org\/wiki\/HWAccelIntro<\/a><\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1643\" height=\"513\" src=\"https:\/\/www.xianwaizhiyin.net\/wp-content\/uploads\/2022\/02\/cuda-code-2-2.png\" alt=\"\" class=\"wp-image-885\"\/><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<p>\u8fd8\u6709\u6700\u540e\u4e00\u4e2a\u5206\u6790\uff0ch264_cuvid \u89e3\u7801\u5668\u89e3\u7801\u51fa\u6765 CUDA \u683c\u5f0f\u7684 AVFrame\uff0c\u56e0\u4e3a\u67d0\u4e9b\u7f16\u7801\u5668\u53ea\u652f\u6301NV12\u683c\u5f0f\uff0c\u6211\u4eec\u60f3\u8f6c\u6210 NV12 \u7684AVFrame\uff0c\u518d\u4f20\u9012\u7ed9 \u7f16\u7801\u5668\u5982\u4f55\u64cd\u4f5c\u3002\u53ef\u4ee5\u6307\u5b9a <code class=\"prettyprint\" >-hwaccel_output_format nv12<\/code> ,\u547d\u4ee4\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"prettyprint\" >ffmpeg.exe -hwaccel cuvid  -hwaccel_output_format nv12 -vcodec h264_cuvid -i juren_10s.mp4 -vcodec h264_nvenc -acodec copy juren_h264_nvenc_10s.mp4 -y<\/code><\/pre>\n\n\n\n<p>\u8fd9\u4e2a\u529f\u80fd\u662f\u7531 hwaccel_retrieve_data() \u51fd\u6570\u5b9e\u73b0\u7684\uff0c\u5728 hwaccel_retrieve_data() \u5185\u90e8 \u5982\u679c <code class=\"prettyprint\" >ist-&gt;hwaccel_pix_fmt<\/code> \u8ddf <code>ist-&gt;hwaccel_output_format<\/code> \u4e0d\u4e00\u81f4\uff0c\u5c31\u4f1a\u8fdb\u884c\u786c\u4ef6\u683c\u5f0f\u8f6c\u6362\u3002<\/p>\n\n\n\n<p>\u8fd9\u91cc\u7684\u50cf\u7d20\u683c\u5f0f\u8f6c\u6362\u8ddf \u300a<a href=\"\/?p=654\">ffmpeg\u547d\u4ee4\u5206\u6790-pix_fmt<\/a>\u300b \u4e0d\u592a\u4e00\u6837\uff0c-pix_fmt \u662f\u901a\u8fc7 format filter \u6765\u5b9e\u73b0\u7684\uff0c\u9488\u5bf9\u7684\u662f\u975e\u786c\u4ef6\u50cf\u7d20\u683c\u5f0f\uff0c\u5982\u679c format filter \u7684\u8f93\u5165\u662f cuda \u50cf\u7d20\u683c\u5f0f\uff0c\u8f93\u51fa\u662f nv12 \u4e4b\u7c7b\u7684\u975e\u786c\u4ef6\u50cf\u7d20\u683c\u5f0f\uff0cformat filter\u4f1a\u62a5\u9519\u3002<\/p>\n\n\n\n<p>\u603b\u7ed3\uff1a<\/p>\n\n\n\n<p>1\uff0c-pix_fmt \uff0c\u901a\u8fc7 format filter \u6765\u5b9e\u73b0\uff0c\u7528\u4e8e\u975e\u786c\u4ef6\u50cf\u7d20\u683c\u5f0f\u7684\u8f6c\u6362\u3002<\/p>\n\n\n\n<p>2\uff0c-hwaccel_output_format\uff0c\u901a\u8fc7 hwaccel_retrieve_data() \u6765\u5b9e\u73b0\uff0c\u7528\u4e8e\u786c\u4ef6\u50cf\u7d20\u683c\u5f0f\u7684\u8f6c\u6362\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<p>ffmpeg cuda \u786c\u4ef6\u52a0\u901f \u5206\u6790\u5b8c\u6bd5\u3002<\/p>\n\n\n\n<p>\u00a9\u7248\u6743\u6240\u5c5e\uff1a\u5f26\u5916\u4e4b\u97f3\uff0cQQ\uff1a2338195090\u3002<\/p>\n\n\n\n<p>\u7531\u4e8e\u7b14\u8005\u7684\u6c34\u5e73\u6709\u9650\uff0c \u52a0\u4e4b\u7f16\u5199\u7684\u540c\u65f6\u8fd8\u8981\u53c2\u4e0e\u5f00\u53d1\u5de5\u4f5c\uff0c\u6587\u4e2d\u96be\u514d\u4f1a\u51fa\u73b0\u4e00\u4e9b\u9519\u8bef\u6216\u8005\u4e0d\u51c6\u786e\u7684\u5730\u65b9\uff0c\u6073\u8bf7\u8bfb\u8005\u6279\u8bc4\u6307\u6b63\u3002\u5982\u679c\u8bfb\u8005\u6709\u4efb\u4f55\u5b9d\u8d35\u610f\u89c1\uff0c\u6216\u8005\u5e0c\u671b\u4ea4\u6d41\u97f3\u89c6\u9891\u6280\u672f\u7684\uff0c\u53ef\u4ee5\u52a0\u6211\u5fae\u4fe1 Loken1\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587 ffmpeg4.4.1 \u6e90\u7801\u4e3a\u51c6\uff0c\u7528\u4ee5\u4e0b\u547d\u4ee4\u5206\u6790 ffmpeg.c \u91cc\u9762\u7684\u786c\u4ef6\u52a0\u901f\u903b\u8f91\u5b9e\u73b0\u3002 \u547d\u4ee4\u5982\u4e0b\uff1a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,17],"tags":[],"class_list":["post-642","post","type-post","status-publish","format-standard","hentry","category-ffmpeg","category-ffmpeg-cmds"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v18.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>FFmpeg\u786c\u4ef6\u52a0\u901f - \u5f26\u5916\u4e4b\u97f3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.xianwaizhiyin.net\/?p=642\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"FFmpeg\u786c\u4ef6\u52a0\u901f - \u5f26\u5916\u4e4b\u97f3\" \/>\n<meta property=\"og:description\" content=\"\u672c\u6587 ffmpeg4.4.1 \u6e90\u7801\u4e3a\u51c6\uff0c\u7528\u4ee5\u4e0b\u547d\u4ee4\u5206\u6790 ffmpeg.c \u91cc\u9762\u7684\u786c\u4ef6\u52a0\u901f\u903b\u8f91\u5b9e\u73b0\u3002 \u547d\u4ee4\u5982\u4e0b\uff1a [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.xianwaizhiyin.net\/?p=642\" \/>\n<meta property=\"og:site_name\" content=\"\u5f26\u5916\u4e4b\u97f3\" \/>\n<meta property=\"article:published_time\" content=\"2022-02-10T06:16:03+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-01-11T09:51:03+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.xianwaizhiyin.net\/wp-content\/uploads\/2022\/02\/cuda-code-1-1-1.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"loken\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.xianwaizhiyin.net\/#website\",\"url\":\"https:\/\/www.xianwaizhiyin.net\/\",\"name\":\"\u5f26\u5916\u4e4b\u97f3\",\"description\":\"FFmpeg\u3001WebRTC\uff0cSRS \u97f3\u89c6\u9891\u3001\u6d41\u5a92\u4f53\u6280\u672f\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.xianwaizhiyin.net\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.xianwaizhiyin.net\/?p=642#primaryimage\",\"inLanguage\":\"zh-Hans\",\"url\":\"\/wp-content\/uploads\/2022\/02\/cuda-code-1-1-1.png\",\"contentUrl\":\"\/wp-content\/uploads\/2022\/02\/cuda-code-1-1-1.png\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.xianwaizhiyin.net\/?p=642#webpage\",\"url\":\"https:\/\/www.xianwaizhiyin.net\/?p=642\",\"name\":\"FFmpeg\u786c\u4ef6\u52a0\u901f - \u5f26\u5916\u4e4b\u97f3\",\"isPartOf\":{\"@id\":\"https:\/\/www.xianwaizhiyin.net\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.xianwaizhiyin.net\/?p=642#primaryimage\"},\"datePublished\":\"2022-02-10T06:16:03+00:00\",\"dateModified\":\"2024-01-11T09:51:03+00:00\",\"author\":{\"@id\":\"https:\/\/www.xianwaizhiyin.net\/#\/schema\/person\/6605a70af752697df6b62f77c53298a3\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.xianwaizhiyin.net\/?p=642#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.xianwaizhiyin.net\/?p=642\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.xianwaizhiyin.net\/?p=642#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.xianwaizhiyin.net\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"FFmpeg\u786c\u4ef6\u52a0\u901f\"}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.xianwaizhiyin.net\/#\/schema\/person\/6605a70af752697df6b62f77c53298a3\",\"name\":\"loken\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.xianwaizhiyin.net\/#personlogo\",\"inLanguage\":\"zh-Hans\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/f6320b5256dc36ef4243e0acf26144b8ac2668b478302ad154e95ce3202bc421?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/f6320b5256dc36ef4243e0acf26144b8ac2668b478302ad154e95ce3202bc421?s=96&d=mm&r=g\",\"caption\":\"loken\"},\"sameAs\":[\"https:\/\/www.xianwaizhiyin.net\/\"],\"url\":\"https:\/\/www.xianwaizhiyin.net\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"FFmpeg\u786c\u4ef6\u52a0\u901f - \u5f26\u5916\u4e4b\u97f3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.xianwaizhiyin.net\/?p=642","og_locale":"zh_CN","og_type":"article","og_title":"FFmpeg\u786c\u4ef6\u52a0\u901f - \u5f26\u5916\u4e4b\u97f3","og_description":"\u672c\u6587 ffmpeg4.4.1 \u6e90\u7801\u4e3a\u51c6\uff0c\u7528\u4ee5\u4e0b\u547d\u4ee4\u5206\u6790 ffmpeg.c \u91cc\u9762\u7684\u786c\u4ef6\u52a0\u901f\u903b\u8f91\u5b9e\u73b0\u3002 \u547d\u4ee4\u5982\u4e0b\uff1a [&hellip;]","og_url":"https:\/\/www.xianwaizhiyin.net\/?p=642","og_site_name":"\u5f26\u5916\u4e4b\u97f3","article_published_time":"2022-02-10T06:16:03+00:00","article_modified_time":"2024-01-11T09:51:03+00:00","og_image":[{"url":"https:\/\/www.xianwaizhiyin.net\/wp-content\/uploads\/2022\/02\/cuda-code-1-1-1.png"}],"twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"loken","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"7 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebSite","@id":"https:\/\/www.xianwaizhiyin.net\/#website","url":"https:\/\/www.xianwaizhiyin.net\/","name":"\u5f26\u5916\u4e4b\u97f3","description":"FFmpeg\u3001WebRTC\uff0cSRS \u97f3\u89c6\u9891\u3001\u6d41\u5a92\u4f53\u6280\u672f","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.xianwaizhiyin.net\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"ImageObject","@id":"https:\/\/www.xianwaizhiyin.net\/?p=642#primaryimage","inLanguage":"zh-Hans","url":"\/wp-content\/uploads\/2022\/02\/cuda-code-1-1-1.png","contentUrl":"\/wp-content\/uploads\/2022\/02\/cuda-code-1-1-1.png"},{"@type":"WebPage","@id":"https:\/\/www.xianwaizhiyin.net\/?p=642#webpage","url":"https:\/\/www.xianwaizhiyin.net\/?p=642","name":"FFmpeg\u786c\u4ef6\u52a0\u901f - \u5f26\u5916\u4e4b\u97f3","isPartOf":{"@id":"https:\/\/www.xianwaizhiyin.net\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.xianwaizhiyin.net\/?p=642#primaryimage"},"datePublished":"2022-02-10T06:16:03+00:00","dateModified":"2024-01-11T09:51:03+00:00","author":{"@id":"https:\/\/www.xianwaizhiyin.net\/#\/schema\/person\/6605a70af752697df6b62f77c53298a3"},"breadcrumb":{"@id":"https:\/\/www.xianwaizhiyin.net\/?p=642#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.xianwaizhiyin.net\/?p=642"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.xianwaizhiyin.net\/?p=642#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.xianwaizhiyin.net\/"},{"@type":"ListItem","position":2,"name":"FFmpeg\u786c\u4ef6\u52a0\u901f"}]},{"@type":"Person","@id":"https:\/\/www.xianwaizhiyin.net\/#\/schema\/person\/6605a70af752697df6b62f77c53298a3","name":"loken","image":{"@type":"ImageObject","@id":"https:\/\/www.xianwaizhiyin.net\/#personlogo","inLanguage":"zh-Hans","url":"https:\/\/secure.gravatar.com\/avatar\/f6320b5256dc36ef4243e0acf26144b8ac2668b478302ad154e95ce3202bc421?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f6320b5256dc36ef4243e0acf26144b8ac2668b478302ad154e95ce3202bc421?s=96&d=mm&r=g","caption":"loken"},"sameAs":["https:\/\/www.xianwaizhiyin.net\/"],"url":"https:\/\/www.xianwaizhiyin.net\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/www.xianwaizhiyin.net\/index.php?rest_route=\/wp\/v2\/posts\/642","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xianwaizhiyin.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xianwaizhiyin.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xianwaizhiyin.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xianwaizhiyin.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=642"}],"version-history":[{"count":16,"href":"https:\/\/www.xianwaizhiyin.net\/index.php?rest_route=\/wp\/v2\/posts\/642\/revisions"}],"predecessor-version":[{"id":3083,"href":"https:\/\/www.xianwaizhiyin.net\/index.php?rest_route=\/wp\/v2\/posts\/642\/revisions\/3083"}],"wp:attachment":[{"href":"https:\/\/www.xianwaizhiyin.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=642"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xianwaizhiyin.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=642"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xianwaizhiyin.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=642"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}