{"id":40274,"date":"2025-05-28T13:43:12","date_gmt":"2025-05-28T05:43:12","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/40274.html"},"modified":"2025-05-28T13:43:12","modified_gmt":"2025-05-28T05:43:12","slug":"%e3%80%90%e5%a4%87%e6%88%98%e7%a7%8b%e6%8b%9b%e3%80%91c%e9%9f%b3%e8%a7%86%e9%a2%91%e5%bc%80%e5%8f%91%e7%bb%8f%e5%85%b8%e9%9d%a2%e8%af%95%e9%a2%98%e6%95%b4%e7%90%86","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/40274.html","title":{"rendered":"\u3010\u5907\u6218\u79cb\u62db\u3011C++\u97f3\u89c6\u9891\u5f00\u53d1\u7ecf\u5178\u9762\u8bd5\u9898\u6574\u7406"},"content":{"rendered":"<h4>1\u3001\u7b80\u8981\u4ecb\u7ecd\u4e00\u4e0b\u5bf9 H.264 \u7684\u4e86\u89e3&#xff1f;<\/h4>\n<p>1&#xff09;\u57fa\u7840\u63cf\u8ff0<\/p>\n<p>H.264 \u662f\u7531\u56fd\u9645\u6807\u51c6\u7ec4\u7ec7\u673a\u6784&#xff08;ISO&#xff09;\u4e0b\u5c5e\u7684\u8fd0\u52a8\u56fe\u8c61\u4e13\u5bb6\u7ec4&#xff08;MPEG&#xff09;\u548c\u56fd\u9645\u7535\u4f20\u89c6\u8baf\u8054\u76df\u8fdc\u7a0b\u901a\u4fe1\u6807\u51c6\u5316\u7ec4\u7ec7&#xff08;ITU-T&#xff09;\u5f00\u53d1\u7684\u7cfb\u5217\u7f16\u7801\u6807\u51c6\u4e4b\u4e00\u3002<\/p>\n<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"244\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250528054310-6836a26ecd825.png\" width=\"720\" \/><\/p>\n<p>2&#xff09;\u7801\u6d41\u7ed3\u6784<\/p>\n<p>H.264 \u539f\u59cb\u7801\u6d41&#xff08;\u88f8\u6d41&#xff09;\u662f\u7531\u4e00\u4e2a\u63a5\u4e00\u4e2a NALU \u7ec4\u6210&#xff0c;\u5b83\u7684\u529f\u80fd\u5206\u4e3a\u4e24\u5c42&#xff1a;VCL&#xff08;\u89c6\u9891\u7f16\u7801\u5c42&#xff09;\u548c NAL&#xff08;\u7f51\u7edc\u62bd\u8c61\u5c42&#xff09;\u3002<\/p>\n<ul>\n<li>\n<p>\u89c6\u9891\u7f16\u7801\u5c42 VCL&#xff08;Video Coding Layer&#xff09;&#xff1a;\u662f\u5bf9\u89c6\u9891\u7f16\u7801\u6838\u5fc3\u7b97\u6cd5\u8fc7\u7a0b\u3001\u5b50\u5b8f\u5757\u3001\u5b8f\u5757\u3001\u7247\u7b49\u6982\u5ff5\u7684\u5b9a\u4e49\u3002\u8fd9\u5c42\u4e3b\u8981\u662f\u4e3a\u4e86\u5c3d\u53ef\u80fd\u7684\u72ec\u7acb\u4e8e\u7f51\u7edc\u6765\u9ad8\u6548\u7684\u5bf9\u89c6\u9891\u5185\u5bb9\u8fdb\u884c\u7f16\u7801\u3002<\/p>\n<\/li>\n<li>\n<p>\u7f51\u8def\u62bd\u8c61\u5c42 NAL&#xff08;Network Abstract Layer&#xff09;&#xff1a;\u8d1f\u8d23\u5c06 VCL \u4ea7\u751f\u7684\u6bd4\u7279\u5b57\u7b26\u4e32\u9002\u914d\u5230\u5404\u79cd\u5404\u6837\u7684\u7f51\u7edc\u548c\u591a\u5143\u73af\u5883\u4e2d&#xff0c;\u8986\u76d6\u4e86\u6240\u6709\u7247\u7ea7\u4ee5\u4e0a\u7684\u8bed\u6cd5\u7ea7\u522b\u3002<\/p>\n<\/li>\n<\/ul>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"159\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250528054310-6836a26ee5a39.png\" width=\"640\" \/><\/p>\n<p>3&#xff09;\u4e24\u79cd\u5c01\u88c5<\/p>\n<p>H.264 \u7684\u4e24\u79cd\u5c01\u88c5&#xff1a;AnnexB \u6a21\u5f0f\u548c AVCC \u6a21\u5f0f\u3002<\/p>\n<p>AnnexB \u6a21\u5f0f&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u4f20\u7edf\u6a21\u5f0f<\/p>\n<\/li>\n<li>\n<p>\u6709 startcode&#xff0c;startcode \u7801\u662f&#xff1a;00 00 01 \u6216 00 00 00 01 (3 \u5b57\u8282\u6216 4 \u5b57\u8282)<\/p>\n<\/li>\n<li>\n<p>SPS \u548c PPS \u5728\u7801\u6d41\u4e2d\u5206\u522b\u4f5c\u4e3a\u4e00\u4e2a NALU<\/p>\n<\/li>\n<\/ul>\n<p>AVCC \u6a21\u5f0f&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u6ca1\u6709 startcode&#xff0c;SPS \u548c PPS \u4ee5\u53ca\u5176\u5b83\u4fe1\u606f\u88ab\u5c01\u88c5\u5728 container \u4e2d&#xff0c;\u6bcf\u4e00\u4e2a frame \u524d\u9762 4 \u4e2a\u5b57\u8282\u662f\u8fd9\u4e2a frame \u7684\u957f\u5ea6<\/p>\n<\/li>\n<li>\n<p>\u4e00\u822c\u5728 mp4\u3001mkv \u683c\u5f0f\u4e2d\u5e38\u7528 AVCC \u6a21\u5f0f<\/p>\n<\/li>\n<\/ul>\n<p>\u5f88\u591a\u89e3\u7801\u5668\u53ea\u652f\u6301 AnnexB \u8fd9\u79cd\u6a21\u5f0f&#xff0c;\u56e0\u6b64\u9700\u8981\u5c06 AVCC \u6a21\u5f0f\u505a\u8f6c\u6362&#xff0c;\u5728 ffmpeg \u4e2d\u2f64 h264_mp4toannexb_filter \u53ef\u4ee5\u505a\u8f6c\u6362&#xff0c;\u5b9e\u73b0\u5982\u4e0b&#xff1a;<\/p>\n<p>const AVBitStreamFilter *bsfilter &#061; av_bsf_get_by_name(&#034;h264_mp4toannexb&#034;); <\/p>\n<p>AVBSFContext *bsf_ctx &#061; NULL;<br \/>\n\/\/ \u521d\u59cb\u5316\u8fc7\u6ee4\u5668\u4e0a\u4e0b\u2f42<br \/>\nav_bsf_alloc(bsfilter, &amp;bsf_ctx);<br \/>\n\/\/ \u6dfb\u52a0\u89e3\u7801\u5668\u5c5e\u6027<br \/>\navcodec_parameters_copy(bsf_ctx-&gt;par_in, ifmt_ctx-&gt;streams[videoindex]-&gt;cod ecpar);<br \/>\nav_bsf_init(bsf_ctx); <\/p>\n<h4>2\u3001H.264 \u7f16\u7801\u6846\u67b6\u5206\u5c42\u76ee\u7684\u662f\u4ec0\u4e48&#xff1f;<\/h4>\n<p>\u5bf9 H.264 \u7f16\u7801\u6846\u67b6\u8fdb\u884c\u5206\u5c42\u7684\u4e3b\u8981\u76ee\u6807\u662f\u4e3a\u4e86\u6709\u9ad8\u7684\u89c6\u9891\u538b\u7f29\u6bd4\u548c\u826f\u597d\u7684\u7f51\u7edc\u4eb2\u548c\u6027\u3002<\/p>\n<p>VCL \u5c42\u8d1f\u8d23\u89c6\u9891\u7684\u4fe1\u53f7\u5904\u7406&#xff0c;\u5305\u542b\u538b\u7f29&#xff0c;\u91cf\u5316\u7b49\u5904\u7406&#xff0c;NAL \u5c42\u5219\u8d1f\u8d23\u89e3\u51b3\u7f16\u7801\u540e\u6570\u636e\u7684\u7f51\u7edc\u4f20\u8f93\u3002<\/p>\n<p>\u8fd9\u6837\u53ef\u4ee5\u5c06 VCL \u548c NAL \u7684\u5904\u7406\u653e\u5230\u4e0d\u540c\u5e73\u53f0\u6765\u5904\u7406&#xff0c;\u53ef\u4ee5\u51cf\u5c11\u56e0\u4e3a\u7f51\u7edc\u73af\u5883\u4e0d\u540c\u5bf9 VCL \u7684\u6bd4\u7279\u6d41\u8fdb\u884c\u91cd\u6784\u548c\u91cd\u7f16\u7801\u3002<\/p>\n<p>\u8fd9\u6837\u5c06\u7f16\u7801\u548c\u7f51\u7edc\u4f20\u8f93\u8fdb\u884c\u9694\u79bb&#xff0c;\u4f7f\u529f\u80fd\u5355\u4e00\u3001\u4fbf\u4e8e\u7ef4\u62a4\u3002<\/p>\n<h4>3\u3001\u4ecb\u7ecd\u4e00\u4e0b I\u3001P\u3001B \u5e27\u7f16\u7801\u3001\u89e3\u7801\u3001\u663e\u793a\u987a\u5e8f&#xff1f;<\/h4>\n<p>\u6211\u4eec\u4ee5\u4e0b\u56fe\u4e3a\u4f8b\u6765\u4ecb\u7ecd\u4e00\u4e0b I\u3001P\u3001B \u5e27\u7684\u7f16\u7801\u8fc7\u7a0b&#xff1a;<\/p>\n<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"201\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250528054311-6836a26f0ffea.png\" width=\"567\" \/><\/p>\n<p>\u7f16\u7801\u5668\u7f16\u7801\u4e00\u4e2a I \u5e27&#xff0c;\u7136\u540e\u5411\u540e\u8df3\u8fc7\u51e0\u4e2a\u5e27&#xff0c;\u7528\u8fd9\u4e2a I \u5e27\u4f5c\u4e3a\u57fa\u51c6\u5e27\u5bf9\u4e00\u4e2a\u672a\u6765 P \u5e27\u8fdb\u884c\u7f16\u7801&#xff0c;\u7136\u540e\u8df3\u56de\u5230\u8fd9\u4e2a I \u5e27\u4e4b\u540e\u7684\u4e0b\u4e00\u4e2a\u5e27\u3002I \u5e27\u548c P \u5e27\u4e4b\u95f4\u7684\u5e27\u53ef\u4ee5\u88ab\u7f16\u7801\u4e3a B \u5e27\u3002\u4e4b\u540e&#xff0c;\u7f16\u7801\u5668\u4f1a\u518d\u6b21\u8df3\u8fc7\u51e0\u4e2a\u5e27&#xff0c;\u4f7f\u7528\u7b2c\u4e00\u4e2a P \u5e27\u4f5c\u4e3a\u57fa\u51c6\u5e27&#xff0c;\u7f16\u7801\u53e6\u5916\u4e00\u4e2a P \u5e27&#xff0c;\u7136\u540e\u518d\u6b21\u8df3\u56de&#xff0c;\u7528 B \u5e27\u586b\u5145\u663e\u793a\u5e8f\u5217\u4e2d\u7684\u7a7a\u9699\u3002\u8fd9\u4e2a\u8fc7\u7a0b\u4e0d\u65ad\u6301\u7eed&#xff0c;\u7136\u540e\u6bcf\u95f4\u9694\u4e00\u5b9a\u7684\u5e27\u6570\u540e\u63d2\u5165\u4e00\u4e2a\u65b0\u7684 I \u5e27\u3002<\/p>\n<p>\u7531\u4e8e\u5e27\u4e4b\u95f4\u5b58\u5728\u4f9d\u8d56\u5173\u7cfb&#xff0c;\u6240\u4ee5\u5404\u5e27\u7684\u89e3\u7801\u987a\u5e8f\u548c\u7f16\u7801\u987a\u5e8f\u662f\u4e00\u81f4\u7684&#xff0c;\u5148\u88ab\u7f16\u7801\u7684\u5e27\u5728\u89e3\u7801\u65f6\u5c31\u4f1a\u5148\u88ab\u89e3\u7801\u3002\u4e3a\u4e86\u5b9e\u73b0\u8fd9\u4e00\u70b9&#xff0c;\u7f16\u7801\u7684\u65f6\u5019\u9700\u8981\u6839\u636e\u6bcf\u5e27\u7684\u7f16\u7801\u987a\u5e8f\u4f1a\u4e3a\u5176\u8bb0\u5f55\u4e0a\u4e00\u4e2a DTS&#xff08;Decoding Time Stamp&#xff09;\u7528\u4e8e\u89e3\u7801\u65f6\u6309\u6b64\u987a\u5e8f\u8fdb\u884c\u89e3\u7801\u3002<\/p>\n<p>\u5982\u4e0a\u9762\u4ecb\u7ecd\u7684\u7f16\u7801\u8fc7\u7a0b&#xff0c;P \u5e27\u7531\u524d\u4e00\u4e2a I \u5e27\u6216 P \u5e27\u6765\u9884\u6d4b&#xff0c;\u800c B \u5e27\u7531\u524d\u540e\u7684\u4e24\u4e2a P \u5e27\u6216\u4e00\u4e2a I \u5e27\u548c\u4e00\u4e2a P \u5e27\u6765\u9884\u6d4b&#xff0c;\u56e0\u800c\u5f53\u5b58\u5728 B \u5e27\u65f6&#xff0c;\u5e27\u7684\u7f16\u89e3\u7801\u987a\u5e8f\u548c\u5e27\u7684\u663e\u793a\u987a\u5e8f\u4f1a\u6709\u6240\u4e0d\u540c&#xff0c;\u8fd9\u65f6\u5019\u5c31\u9700\u8981\u4e3a\u6bcf\u5e27\u8bb0\u5f55\u4e0a\u4e00\u4e2a PTS&#xff08;Presentation Time Stamp&#xff09;\u7528\u4e8e\u89e3\u7801\u540e\u6309\u987a\u5e8f\u663e\u793a\u3002<\/p>\n<h4>4\u3001H.264 \u4e0e H.265 \u6709\u4ec0\u4e48\u533a\u522b&#xff1f;<\/h4>\n<p>1&#xff09;\u4e3b\u8981\u533a\u522b<\/p>\n<ul>\n<li>\n<p>H.265 \u4e5f\u79f0\u4e3a\u9ad8\u6548\u89c6\u9891\u7f16\u7801 (HEVC)&#xff0c;\u662f H.264 \u7684\u5347\u7ea7\u548c\u66f4\u9ad8\u7ea7\u7684\u7248\u672c&#xff1b;<\/p>\n<\/li>\n<li>\n<p>H.265 \u7684\u7f16\u7801\u67b6\u6784\u5927\u81f4\u4e0a \u548c H.264 \u7684\u67b6\u6784\u76f8\u4f3c&#xff0c;\u4e3b\u8981\u4e5f\u5305\u542b&#xff1a;\u5e27\u5185\u9884\u6d4b&#xff08;intra prediction&#xff09;\u3001\u5e27\u95f4\u9884\u6d4b&#xff08;inter prediction&#xff09;\u3001\u8f6c\u6362&#xff08;transform&#xff09;\u3001\u91cf\u5316&#xff08;quantization&#xff09;\u3001\u53bb\u533a\u5757\u6ee4\u6ce2\u5668&#xff08;deblocking filter&#xff09;\u3001\u71b5\u7f16\u7801&#xff08;entropy coding&#xff09;\u7b49\u6a21\u5757\u3002\u4f46\u5728 H.265 \u7f16\u7801\u67b6\u6784\u4e2d&#xff0c;\u6574\u4f53\u88ab\u5206\u4e3a\u4e86\u4e09\u4e2a\u57fa\u672c\u5355\u4f4d&#xff0c;\u5206\u522b\u662f\u7f16\u7801\u5355\u4f4d&#xff08;coding unit, CU&#xff09;\u3001\u9884\u6d4b\u5355\u4f4d&#xff08;predict unit, PU&#xff09;\u548c\u8f6c\u6362\u5355\u4f4d&#xff08;transform unit, TU&#xff09;&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u6bd4\u8d77 H.264&#xff0c;H.265 \u63d0\u4f9b\u4e86\u66f4\u591a\u4e0d\u540c\u7684\u5de5\u5177\u6765\u964d\u4f4e\u7801\u7387&#xff0c;\u4ee5\u7f16\u7801\u5355\u4f4d\u6765\u8bf4&#xff0c;H.264 \u4e2d\u6bcf\u4e2a\u5b8f\u5757&#xff08;macroblock\/MB&#xff09;\u5927\u5c0f\u6700\u5927\u4e3a 16&#215;16 \u50cf\u7d20&#xff0c;\u800c H.265 \u7684\u7f16\u7801\u5355\u4f4d\u6700\u5927\u4e3a 64&#215;64&#xff1b;<\/p>\n<\/li>\n<li>\n<p>H.265 \u7684\u5e27\u5185\u9884\u6d4b\u6a21\u5f0f\u652f\u6301 35 \u79cd\u65b9\u5411&#xff08;\u800c H.264 \u53ea\u652f\u6301 8 \u79cd&#xff09;&#xff0c;\u5e76\u4e14\u63d0\u4f9b\u4e86\u66f4\u597d\u7684\u8fd0\u52a8\u8865\u507f\u5904\u7406\u548c\u77e2\u91cf\u9884\u6d4b\u65b9\u6cd5\u3002<\/p>\n<\/li>\n<\/ul>\n<h4>5\u3001RTMP \u548c RTSP \u6709\u4ec0\u4e48\u533a\u522b&#xff1f;\u4f7f\u7528 RTSP \u662f\u57fa\u4e8e UDP \u4f20\u8f93\u7684\u8bdd&#xff0c;\u6211\u4eec\u600e\u6837\u8fdb\u884c\u4e71\u5e8f\u91cd\u6392&#xff1f;<\/h4>\n<p>RTMP \u548c RTSP \u7684\u533a\u522b:<\/p>\n<p>RTMP \u4f7f\u7528 TCP \u4f5c\u4e3a\u4f20\u8f93\u5c42\u534f\u8bae&#xff0c;\u80fd\u4fdd\u8bc1\u4e0d\u4e22\u5305\u548c\u63a5\u6536\u987a\u5e8f&#xff0c;\u4f20\u8f93\u8d28\u91cf\u9ad8\u3002<\/p>\n<p>RTSP \u4f7f\u7528 RTP \u683c\u5f0f\u534f\u8bae\u548c RTCP \u63a7\u5236\u534f\u8bae&#xff0c;\u547d\u4ee4\u4e0e\u6570\u636e\u5206\u79bb\u3002\u4f20\u8f93\u5c42\u534f\u8bae\u4e00\u822c\u4f1a\u9009\u62e9 UDP&#xff0c;\u5ef6\u8fdf\u6bd4\u8f83\u4f4e&#xff0c;\u4f20\u8f93\u6548\u7387\u9ad8\u3002<\/p>\n<p>RTSP \u4e2d\u7684 RTP \u683c\u5f0f\u5934\u4e2d\u6709 SequenceNumber \u5b57\u6bb5&#xff0c;\u53ef\u4ee5\u901a\u8fc7\u8fd9\u4e2a\u5e8f\u53f7\u5b9e\u73b0\u6392\u5e8f\u3002<\/p>\n<h4>6\u3001\u5047\u5982\u7ed9\u4f60\u4e00\u5806\u4e71\u5e8f\u7684 RTP \u5305&#xff0c;\u5e94\u8be5\u600e\u6837\u5b9e\u73b0\u4e71\u5e8f\u91cd\u6392&#xff1f;<\/h4>\n<p>\u53ef\u4ee5\u5229\u7528\u63a5\u6536 RTP \u5305\u7f13\u51b2\u961f\u5217\u4f7f\u7528\u5305\u7684\u5e8f\u53f7\u8fdb\u884c\u6392\u5e8f\u3002<\/p>\n<p>\u5728\u4e22\u5305\u60c5\u51b5\u4e0b\u4e3a\u4fdd\u8bc1\u4f20\u8f93\u8d28\u91cf\u4f1a\u5f15\u5165 NACK \u548c FEC \u673a\u5236\u3002<\/p>\n<p>NACK \u8868\u793a\u63a5\u6536\u7aef\u901a\u77e5\u53d1\u9001\u7aef\u4e00\u4e9b\u5305\u4e22\u5931&#xff0c;\u53d1\u9001 NACK \u5305\u8bf7\u6c42\u91cd\u4f20&#xff1b;FEC \u524d\u5411\u7ea0\u9519\u503c\u7684\u662f\u6bcf\u4e2a\u5305\u643a\u5e26\u4e00\u4e9b\u5197\u4f59\u4fe1\u606f\u53ef\u4ee5\u5728\u90e8\u5206\u5305\u4e22\u5931\u7684\u65f6\u5019\u5229\u7528\u5176\u4ed6\u5305\u8fdb\u884c\u91cd\u5efa\u3002<\/p>\n<p>\u5982\u679c\u91cd\u4f20\u6b21\u6570\u8fc7\u591a&#xff0c;\u5305\u65e0\u6cd5\u91cd\u5efa&#xff0c;\u6216\u8005\u4e22\u7684\u5305\u8fc7\u591a&#xff0c;\u6b64\u65f6\u53ef\u4ee5\u4e22\u5e27\u76f4\u63a5\u8df3\u8fc7\u4e22\u5931\u7684\u90e8\u5206\u3002<\/p>\n<h4>7\u3001\u5bf9 YUV \u683c\u5f0f\u6709\u4e86\u89e3\u5417&#xff1f;YUV \u6570\u636e\u505a\u8f6c\u6362\u662f\u600e\u6837\u5b9e\u73b0\u7684&#xff0c;\u6bd4\u5982\u8bf4 YUV422 \u8f6c\u4e3a YUV420&#xff1f;<\/h4>\n<p>YUV \u683c\u5f0f\u662f\u4f20\u8f93\u89c6\u9891\u5e38\u7528\u7684\u683c\u5f0f&#xff0c;\u56e0\u4e3a\u76f8\u5bf9\u4e8e RGB \u683c\u5f0f\u5b83\u53ef\u4ee5\u8282\u7701\u66f4\u591a\u7a7a\u95f4\u3002<\/p>\n<p>YUV \u7684\u683c\u5f0f\u6709\u5f88\u591a&#xff0c;\u4f8b\u5982&#xff1a;YUV444\u3001YUV422\u3001YUV420&#xff0c;\u5e38\u7528\u7684 YUV \u683c\u5f0f\u662f YUV420 \u683c\u5f0f\u3002Y \u8868\u793a\u4eae\u5ea6\u4fe1\u606f&#xff0c;\u662f\u4eba\u773c\u6700\u654f\u611f\u7684\u5206\u91cf&#xff0c;UV \u5219\u8868\u793a\u8272\u5ea6\u4fe1\u606f\u3002<\/p>\n<p>YUV420 \u8868\u793a\u91c7\u6837\u65b9\u5f0f&#xff1a;UV \u5206\u91cf\u5177\u6709 2:1 \u7684\u6c34\u5e73\u91c7\u6837&#xff0c;2:1 \u7684\u5782\u76f4\u91c7\u6837&#xff0c;\u8fd9\u91cc\u5e76\u4e0d\u662f\u6307\u53ea\u6709 U&#xff0c;\u6ca1\u6709 V&#xff0c;\u800c\u662f\u5bf9\u4e8e\u6bcf\u4e00\u884c&#xff0c;\u53ea\u6709\u4e00\u4e2a U \u6216\u8005 V \u5206\u91cf&#xff0c;\u5982\u679c\u7b2c\u4e00\u884c\u662f 4:2:0&#xff0c;\u90a3\u4e48\u4e0b\u4e00\u884c\u5c31\u662f 4:0:2\u3002<\/p>\n<p>\u53ef\u4ee5\u7528\u5de5\u5177 YUVView \u76f4\u63a5\u6253\u5f00 YUV \u683c\u5f0f\u7684\u6570\u636e\u3002<\/p>\n<p>YUV \u6570\u636e\u56e0\u4e3a\u8ba1\u7b97\u91cf\u5927\u548c\u6570\u636e\u91cf\u5927\u53ef\u4ee5\u90fd\u653e\u5230 GPU \u5b58\u50a8\u548c\u8ba1\u7b97&#xff0c;YUV422 \u8f6c YUV420 \u53ef\u4ee5\u5229\u7528 OpenGL \u5c06 YUV422 \u7684 UV \u6570\u636e\u8f6c\u6362\u6210 texture \u7eb9\u7406&#xff0c;\u7f16\u5199 shader \u505a\u683c\u5f0f\u8f6c\u6362\u903b\u8f91\u7ee7\u800c\u751f\u6210 YUV420 \u7684 UV texture&#xff0c;\u518d\u901a\u8fc7 readPixel \u5c06\u663e\u5b58\u7684 UV \u6570\u636e\u8bfb\u53d6\u51fa\u6765\u3002\u8f6c\u6362\u903b\u8f91\u5373\u5c06\u7eb9\u7406 UV \u5206\u91cf\u9694\u884c\u91c7\u6837\u3002<\/p>\n<h4>8\u3001\u4f60\u5728\u9879\u76ee\u4e2d\u662f\u600e\u4e48\u964d\u4f4e\u7aef\u5230\u7aef\u7684\u5ef6\u65f6\u7684&#xff1f;<\/h4>\n<p>\u9762\u662f\u76f4\u64ad\u8d70 RTMP \u63a8\u6d41\u3001HTTP-FLV \u64ad\u653e\u65b9\u6848\u964d\u4f4e\u7aef\u5230\u7aef\u5ef6\u8fdf\u7684\u601d\u8def&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u63a8\u6d41\u7aef\u7684\u5ef6\u8fdf\u5305\u542b\u7f16\u7801\u5ef6\u8fdf\u548c\u53d1\u9001\u7f13\u5b58\u961f\u5217\u5f15\u5165\u7684\u5ef6\u8fdf\u3002\u53ef\u4ee5\u901a\u8fc7\u8c03\u8282\u7f16\u7801\u53c2\u6570&#xff08;B \u5e27\u3001\u7801\u7387\u3001\u5e27\u7387&#xff09;\u51cf\u5c0f\u7f16\u7801\u5ef6\u8fdf\u4f46\u4f1a\u5f71\u54cd\u753b\u8d28\u3002\u53e6\u5916\u53ef\u4ee5\u63d0\u9ad8\u4e0a\u4f20\u7684\u4f20\u8f93\u6027\u80fd\u6765\u51cf\u5c0f\u4f20\u8f93\u65f6\u957f\u3002<\/p>\n<\/li>\n<li>\n<p>CDN \u94fe\u8def\u4e0a\u7684\u4f20\u8f93\u5ef6\u8fdf\u3002\u5305\u62ec\u63a8\u6d41\u7684\u94fe\u8def\u548c\u64ad\u653e\u56de\u6e90\u7684\u94fe\u8def&#xff0c;\u8fd9\u90e8\u5206\u5ef6\u8fdf\u4e0d\u662f\u592a\u5927&#xff0c;\u4f46\u4f9d\u65e7\u4f1a\u5f15\u5165\u51e0\u767e ms \u7684\u5ef6\u8fdf\u3002<\/p>\n<\/li>\n<li>\n<p>CDN \u62c9\u6d41\u8fb9\u7f18\u8282\u70b9\u7684\u5410\u6d41\u7b56\u7565\u4f1a\u76f4\u63a5\u5f71\u54cd\u5ef6\u8fdf\u7684\u5927\u5c0f\u3002\u76f4\u64ad\u6d41\u7f16\u7801\u7684 GOP \u7684\u957f\u5ea6&#xff0c;CDN \u5728\u5ba2\u6237\u7aef\u62c9\u6d41\u65f6\u5410\u51e0\u79d2\u7684\u6570\u636e\u3001\u6309\u7167 GOP \u5206\u9694\u5982\u4f55\u4e22\u6570\u636e&#xff0c;\u8fd9\u4e9b\u7b56\u7565\u90fd\u4f1a\u5f71\u54cd\u5ef6\u65f6\u3002<\/p>\n<\/li>\n<li>\n<p>\u64ad\u653e\u7aef\u53ef\u4ee5\u901a\u8fc7\u5bf9\u5f53\u524d\u5df2\u4e0b\u8f7d\u7684 buffer \u8fdb\u884c\u500d\u901f\u64ad\u653e\u548c\u8df3\u5e27\u6765\u964d\u4f4e\u7f13\u5b58\u4ece\u800c\u8fbe\u5230\u964d\u4f4e\u5ef6\u8fdf\u3002\u6ce8\u610f\u5982\u679c\u500d\u901f\u8fc7\u5927&#xff0c;\u58f0\u97f3\u662f\u4f1a\u660e\u663e\u53d8\u8c03\u7684&#xff0c;\u9700\u8981\u901a\u8fc7\u7b97\u6cd5\u6765\u8c03\u6574\u3002\u8df3\u5e27\u4e00\u5b9a\u8981\u6ce8\u610f\u89c6\u9891\u8df3\u5230 I \u5e27&#xff0c;\u97f3\u9891\u5bf9\u9f50\u89c6\u9891\u8fdb\u884c\u4e22\u5f03\u3002<\/p>\n<\/li>\n<\/ul>\n<h4>9\u3001\u5982\u4f55\u76d1\u63a7\u89c6\u9891\u64ad\u653e\u9ed1\u5c4f\u3001\u82b1\u5c4f\u3001\u7eff\u5c4f\u7b49\u5f02\u5e38&#xff1f;<\/h4>\n<p>\u89c6\u9891\u64ad\u653e\u65f6\u5982\u679c\u9047\u5230\u9ed1\u5c4f\u3001\u82b1\u5c4f\u3001\u7eff\u5c4f\u901a\u5e38\u4f1a\u4f34\u6709\u89e3\u7801\u5668\u7684\u62a5\u9519\u6216\u5f02\u5e38\u4fe1\u606f&#xff0c;\u6211\u4eec\u53ef\u4ee5\u4e0a\u62a5\u8fd9\u4e9b\u5f02\u5e38\u4fe1\u606f\u6765\u5b9e\u73b0\u5bf9\u8fd9\u4e9b\u60c5\u51b5\u7684\u76d1\u63a7\u3002<\/p>\n<p>\u4f46\u662f\u4e5f\u6709\u4e00\u4e9b\u60c5\u51b5&#xff0c;\u5373\u4f7f\u51fa\u73b0\u9ed1\u5c4f\u3001\u82b1\u5c4f\u3001\u7eff\u5c4f\u7684\u60c5\u51b5\u4e86&#xff0c;\u89e3\u7801\u5668\u4e5f\u6ca1\u6709\u62a5\u9519\u6216\u5f02\u5e38&#xff0c;\u8fd9\u65f6\u5019\u5c31\u9700\u8981\u6211\u4eec\u5bf9\u89e3\u7801\u540e\u7684\u753b\u9762\u8fdb\u884c\u68c0\u6d4b\u6765\u8bc6\u522b\u8fd9\u4e9b\u95ee\u9898\u3002\u4e00\u822c\u53ef\u4ee5\u8fd9\u6837&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u7528\u4f20\u7edf\u7684\u56fe\u50cf\u5904\u7406\u7b97\u6cd5\u6765\u8bc6\u522b\u3002\u5bf9\u4e8e\u9ed1\u5c4f\u3001\u7eff\u5c4f\u53ef\u4ee5\u7528\u4f20\u7edf\u56fe\u50cf\u5904\u7406\u7b97\u6cd5\u6765\u8fdb\u884c\u8bc6\u522b&#xff0c;\u4f46\u8fd9\u91cc\u4e5f\u4f1a\u6709\u4e00\u4e9b\u8bef\u8bc6\u522b\u7684\u95ee\u9898&#xff0c;\u6bd4\u5982\u89c6\u9891\u672c\u8eab\u5c31\u6709\u4e9b\u4eae\u5ea6\u8f83\u4f4e\u3001\u6b63\u5e38\u5168\u9ed1\u5e27\u3001\u6b63\u5e38\u5168\u7eff\u5e27\u7684\u60c5\u51b5&#xff0c;\u53ef\u80fd\u4e5f\u4f1a\u88ab\u8bc6\u522b\u4e3a\u5f02\u5e38\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bad\u7ec3 AI \u6a21\u578b\u7c7b\u8bc6\u522b\u3002\u5bf9\u4e8e\u82b1\u5c4f&#xff0c;\u53ef\u4ee5\u8bad\u7ec3 AI \u6a21\u578b\u6765\u8fdb\u884c\u8bc6\u522b\u3002\u8bad\u7ec3\u8fc7\u7a0b\u53ef\u4ee5\u901a\u8fc7\u4eba\u5de5\u6784\u9020\u4e22\u5e27\u89c6\u9891\u7684\u65b9\u6cd5\u6765\u751f\u6210\u82b1\u5c4f\u6837\u672c&#xff0c;\u540c\u65f6\u7b5b\u9009\u51fa\u65e0\u82b1\u5c4f\u95ee\u9898\u7684\u6b63\u5e38\u6837\u672c&#xff0c;\u57fa\u4e8e\u8fd9\u4e24\u7c7b\u6837\u672c\u6765\u505a\u4e8c\u5206\u7c7b\u6a21\u578b\u7684\u8bad\u7ec3\u3002<\/p>\n<\/li>\n<\/ul>\n<h4>10\u3001\u4ecb\u7ecd\u4e00\u4e0b FFmpeg \u4e2d\u5173\u4e8e timebase \u7684\u57fa\u7840\u77e5\u8bc6\u4e0e\u5e94\u7528&#xff1f;<\/h4>\n<p>1&#xff09;timebase \u5b9a\u4e49<\/p>\n<p>\u5728 FFmpeg \u4e2d&#xff0c;time_base \u662f\u4e00\u4e2a\u5173\u952e\u6982\u5ff5&#xff0c;\u5b83\u7528\u4e8e\u8868\u793a\u65f6\u95f4\u5355\u4f4d\u3002\u5728\u5904\u7406\u97f3\u9891\u6216\u89c6\u9891\u6d41\u65f6&#xff0c;time_base \u53ef\u4ee5\u6839\u636e\u4e0d\u540c\u7684\u91c7\u6837\u9891\u7387\u6216\u5e27\u7387\u6765\u5b9a\u4e49\u3002timebase \u5728 FFmpeg \u7684\u5b9a\u4e49\u662f\u4e00\u4e2a AVRational \u7ed3\u6784\u4f53&#xff1a;<\/p>\n<p>typedef struct AVRational{<br \/>\n    int num; \/\/\/&lt; numerator<br \/>\n    int den; \/\/\/&lt; denominator<br \/>\n} AVRational; <\/p>\n<p>2&#xff09;timebase \u7684\u4f7f\u7528<\/p>\n<p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b&#xff0c;time_base \u662f\u6839\u636e\u91c7\u6837\u9891\u7387\u6765\u5b9a\u4e49\u7684\u3002\u4f8b\u5982&#xff1a;\u5bf9\u4e8e\u89c6\u9891\u91c7\u6837\u9891\u7387\u4e3a 90KHz&#xff08;90000Hz&#xff09;\u7684\u60c5\u51b5&#xff0c;time_base \u5c31\u76f8\u5f53\u4e8e 1\/90000 \u79d2\u3002\u53e6\u4e00\u79cd\u5b9a\u4e49 time_base \u7684\u65b9\u5f0f\u662f\u6839\u636e\u5e27\u7387\u3002\u4f8b\u5982&#xff1a;\u5bf9\u4e8e\u89c6\u9891\u5e27\u7387\u4e3a 24fps \u7684\u60c5\u51b5&#xff0c;time_base \u5c31\u76f8\u5f53\u4e8e 1\/24 \u79d2\u3002\u5728 FFmpeg \u7684\u5206\u5c42\u7ed3\u6784\u4e2d&#xff0c;\u539f\u59cb\u6570\u636e\u5c42\u3001\u7f16\u89e3\u7801\u5c42\u548c\u5c01\u88c5\u5c42\u90fd\u6709\u5bf9\u5e94\u7684 time_base\u3002\u539f\u59cb\u6570\u636e\u5c42\u548c\u5c01\u88c5\u5c42\u90fd\u901a\u8fc7 AVStream \u8fdb\u884c\u5904\u7406&#xff0c;\u800c\u7f16\u89e3\u7801\u5c42\u5219\u5bf9\u5e94 AVCodec\u3002<\/p>\n<p>3&#xff09;\u5c01\u88c5\u5c42 timebase&#xff0c;\u89c6\u9891\u6d41\/\u97f3\u9891\u6d41 timebase \u548c\u73b0\u5b9e\u65f6\u95f4\u6233\u7684\u7684\u5173\u7cfb\u548c\u8f6c\u6362<\/p>\n<p>\u5c01\u88c5\u5c42 tbn\u3001\u89c6\u9891 tbc \u548c\u97f3\u9891 tbc \u53ef\u4ee5\u5404\u4e0d\u76f8\u540c&#xff0c;\u76f8\u4e92\u4e0d\u5f71\u54cd\u3002\u73b0\u5b9e\u65f6\u95f4\u57fa\u6211\u4eec\u4e00\u822c\u9009\u7528 1us \u5373 (1\/1000000)s\u3002\u56e0\u4e3a\u6bcf\u4e00\u5c42\u7528\u7684\u65f6\u95f4\u57fa\u4e0d\u540c&#xff0c;\u5728\u51fd\u6570\u53c2\u6570\u4f20\u9012\u4e0a\u53ea\u4f1a\u4f7f\u7528\u65f6\u95f4\u57fa\u524d\u9762\u7684\u500d\u6570\u503c&#xff0c;timebase \u662f\u7edf\u4e00\u7684&#xff0c;\u56e0\u6b64\u65f6\u95f4\u5728\u4e0d\u540c\u7684\u65f6\u95f4\u57fa\u4e0a\u9762\u9700\u8981\u505a\u4e00\u5c42\u8f6c\u6362\u3002 \u4f8b\u5982&#xff1a;\u73b0\u5b9e\u65f6\u95f4 1s \u8f6c\u6362\u5230\u97f3\u9891\u6d41\u65f6\u95f4\u5b9e\u73b0\u4e3a 1000000 * (1\/1000000) &#061; 44100 * (1\/44100)&#xff0c;\u90a3\u4e48\u73b0\u5b9e\u65f6\u95f4 1000000 \u5728\u97f3\u9891\u6d41\u65f6\u95f4\u503c\u5219\u4e3a 44100\u3002\u4e3e\u4e00\u4e2a\u5f00\u53d1\u4e2d\u7684\u5b9e\u4f8b&#xff1a;\u5982\u679c\u60f3 seek \u89c6\u9891\u5230\u73b0\u5b9e\u65f6\u95f4\u7684 X ms\u3002<\/p>\n<p>int64_t seekTime &#061; (int64_t)(( X \/ 1000 )  \/ av_q2d(videoStream-&gt;time_base));<br \/>\nav_seek_frame(videoFormatCtx_, video_index_, seekTime, AVSEEK_FLAG_BACKWARD); <\/p>\n<p>\u56e0\u4e3a av_seek_frame \u662f\u5728\u89c6\u9891\u6d41\u5c42\u9762&#xff0c;\u65f6\u95f4\u57fa\u4e0e\u73b0\u5b9e\u65f6\u95f4\u4e0d\u540c&#xff0c;\u9700\u8981\u8f6c\u6362\u5e76\u5c06\u8f6c\u6362\u540e\u7684\u503c\u4f5c\u4e3a\u53c2\u6570\u624d\u80fd\u5f97\u5230\u6b63\u786e\u7684\u7ed3\u679c\u3002<\/p>\n<p>4&#xff09;\u8f6c\u6362\u51fd\u6570\u89e3\u6790<\/p>\n<p>double av_q2d(AVRational a) \/\/\u5c06AVRational \u5bf9\u8c61\u8f6c\u6362\u4e3a\u5c0f\u6570&#xff0c;\u4fbf\u4e8e\u8f6c\u6362<br \/>\n\/\/ \u5c06\u4e00\u4e2a\u65f6\u95f4\u6233a\u4ece\u65f6\u57fabq\u8f6c\u6362\u5230\u65f6\u57facq\u4e0b<br \/>\nint64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) <\/p>\n<p>\u4f8b\u5982&#xff0c;\u5c06\u89c6\u9891\u6d41\u7684\u4e00\u5e27 pts(a * atbr) \u8f6c\u6362\u5230\u5c01\u88c5\u5c42\u6253\u5305\u6210 AVPacket&#xff0c;\u5c01\u88c5\u5c42 timebase \u4e3a tbn&#xff0c;\u6b64\u65f6\u9700\u8981\u8f6c\u6362 int64 t &#061; av_rescale_q_rnd(a&#xff0c; atbr&#xff0c; tbn);\u3002<\/p>\n<p>\u5982\u679c\u8fd8\u4e0d\u77e5\u9053\u97f3\u89c6\u9891\u5f00\u53d1\u9700\u8981\u5b66\u4e60\u54ea\u4e9b\u5185\u5bb9\u7684\u540c\u5b66&#xff0c;\u53ef\u4ee5\u53c2\u8003\u7a0b\u5e8f\u5458\u8001\u5ed6\u7684\u5b66\u4e60\u8def\u7ebf&#xff0c;\u4e3b\u9875\u4e5f\u5206\u4eab\u4e86\u5f88\u591a\u97f3\u89c6\u9891\u7684\u9762\u8bd5\u9898\u548c\u9879\u76ee\u4f9b\u5927\u5bb6\u5b66\u4e60\u53c2\u8003<\/p>\n<p><span class=\"link-card-box\"><span class=\"link-title\">\u6700\u5168\u97f3\u89c6\u9891\u5b66\u4e60\u8def\u7ebf-\u4e92\u8054\u7f51\u97f3\u89c6\u9891-\u5d4c\u5165\u5f0f\u97f3\u89c6\u9891<\/span><span class=\"link-link\"><img decoding=\"async\" class=\"link-link-icon\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250528054311-6836a26f29af5.png\" \/>https:\/\/www.bilibili.com\/video\/BV138DoY7E74\/<\/span><\/span><\/p>\n<h4>11\u3001I \u5e27\u548c IDR \u5e27\u6709\u4ec0\u4e48\u533a\u522b&#xff1f;\u5728\u4ec0\u4e48\u60c5\u51b5\u4e0b I \u5e27\u4e0d\u662f IDR \u5e27&#xff1f;<\/h4>\n<p>I \u5e27&#xff1a;I \u5e27\u662f\u89c6\u9891\u5e8f\u5217\u4e2d\u7684\u5173\u952e\u5e27&#xff0c;\u5b83\u662f\u4e00\u4e2a\u5b8c\u6574\u7684\u56fe\u50cf\u5e27&#xff0c;\u7c7b\u4f3c\u4e8e JPEG \u6216 BMP \u56fe\u50cf\u6587\u4ef6\u3002I \u5e27\u4e0d\u4f9d\u8d56\u4e8e\u5176\u4ed6\u5e27&#xff0c;\u56e0\u6b64\u53ef\u4ee5\u72ec\u7acb\u89e3\u7801\u548c\u663e\u793a\u3002\u5728\u89c6\u9891\u5e8f\u5217\u4e2d&#xff0c;I \u5e27\u901a\u5e38\u7528\u4e8e\u968f\u673a\u8bbf\u95ee\u70b9&#xff0c;\u4e5f\u4f5c\u4e3a\u5176\u4ed6\u5e27\u89e3\u7801\u7684\u53c2\u8003\u3002<\/p>\n<p>IDR \u5e27&#xff1a;IDR \u5e27\u662f\u4e00\u79cd\u7279\u6b8a\u7684 I \u5e27&#xff0c;\u5b83\u5177\u6709\u5237\u65b0\u89e3\u7801\u5668\u7f13\u51b2\u533a\u7684\u529f\u80fd\u3002\u5f53\u89e3\u7801\u5668\u63a5\u6536\u5230 IDR \u5e27\u65f6&#xff0c;\u5b83\u4f1a\u6e05\u9664\u4e4b\u524d\u7684\u89e3\u7801\u72b6\u6001&#xff0c;\u786e\u4fdd\u4ece\u8be5\u5e27\u5f00\u59cb\u89e3\u7801&#xff0c;\u4ece\u800c\u907f\u514d\u9519\u8bef\u4f20\u64ad\u3002IDR \u5e27\u901a\u5e38\u7528\u4e8e\u89c6\u9891\u5e8f\u5217\u7684\u968f\u673a\u8bbf\u95ee\u70b9&#xff0c;\u4ee5\u53ca\u5728\u89c6\u9891\u4f20\u8f93\u6216\u5b58\u50a8\u4e2d\u7528\u4e8e\u9519\u8bef\u6062\u590d\u3002<\/p>\n<p>\u56e0\u6b64 IDR \u5e27\u4e00\u5b9a\u662f I \u5e27&#xff0c;\u4f46\u662f I \u5e27\u5219\u4e0d\u4e00\u5b9a\u662f IDR \u5e27\u3002\u5728\u9047\u5230 OpenGOP \u7684\u60c5\u51b5\u4e0b&#xff0c;\u5c31\u4f1a\u51fa\u73b0 I \u5e27\u4e3a\u975e IDR \u5e27\u7684\u60c5\u51b5\u3002<\/p>\n<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"433\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250528054311-6836a26f331a1.png\" width=\"720\" \/><\/p>\n<p>OpenGOP<\/p>\n<p>\u5982\u4e0a\u56fe\u6240\u793a\u53f3\u6570\u7b2c\u4e00\u4e2a I \u5e27\u5c31\u662f\u4e00\u4e2a\u975e IDR \u7684 I \u5e27&#xff0c;\u524d\u4e00\u4e2a GOP \u4e2d\u7684 B \u5e27\u4f9d\u8d56\u4e86\u5f53\u524d GOP \u7684 I \u5e27\u3002\u6240\u4ee5\u53f3\u6570\u7b2c\u4e00\u4e2a I \u5e27\u63a5\u53d7\u65f6&#xff0c;\u4e0d\u80fd\u5237\u65b0\u89e3\u7801\u5668&#xff0c;\u5426\u5219\u4e0a\u4e00\u4e2a GOP \u4e2d\u7684 B \u5e27\u65e0\u6cd5\u88ab\u6210\u529f\u89e3\u7801&#xff0c;\u53ef\u80fd\u4f1a\u51fa\u73b0\u82b1\u5c4f\u6216\u8005\u62a5\u9519\u3002<\/p>\n<h4>12\u3001\u5982\u679c\u8ba9\u4f60\u8bbe\u8ba1\u4e00\u4e2a\u64ad\u653e\u5668\u7684\u67b6\u6784&#xff0c;\u4f60\u4f1a\u5206\u54ea\u51e0\u5c42&#xff1f;<\/h4>\n<p>\u6211\u4eec\u53ef\u4ee5\u5206\u4e0b\u9762\u51e0\u5c42\u6765\u8bbe\u8ba1\u64ad\u653e\u5668\u7684\u67b6\u6784&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u97f3\u89c6\u9891\u6838\u5fc3\u5c42&#xff1a;\u804c\u8d23\u5728\u4e8e\u5904\u7406\u7f51\u7edc\u534f\u8bae\u3001\u97f3\u89c6\u9891\u89e3\u5c01\u88c5&#xff08;Demuxer&#xff09;\u3001\u97f3\u89c6\u9891\u89e3\u7801&#xff08;Decoder&#xff09;\u3001\u97f3\u89c6\u9891\u6570\u636e\u7ed3\u6784\u5c01\u88c5\u7b49\u7b49&#xff0c;\u901a\u5e38\u57fa\u4e8e FFmpeg \u6765\u5b9e\u73b0\u3002<\/p>\n<\/li>\n<li>\n<p>\u64ad\u653e\u5668\u5185\u6838\u5c42&#xff1a;\u57fa\u4e8e\u97f3\u89c6\u9891\u6838\u5fc3\u5c42\u7684\u80fd\u529b\u6765\u5c01\u88c5\u64ad\u653e\u5668\u5185\u6838\u80fd\u529b&#xff0c;\u5305\u62ec\u4f7f\u7528\u591a\u7ebf\u7a0b\u3001\u591a\u7f13\u51b2\u533a\u4e32\u8054\u7f51\u7edc\u3001\u89e3\u5c01\u88c5\u3001\u89e3\u7801\u3001\u6e32\u67d3\u7b49\u8282\u70b9&#xff1b;\u652f\u6301\u64ad\u653e\u3001\u6682\u505c\u3001seek\u3001\u5237\u65b0\u6570\u636e\u6e90\u7b49\u63a7\u5236\u80fd\u529b&#xff1b;\u63d0\u4f9b\u64ad\u653e\u72b6\u6001\u83b7\u53d6\u3001\u64ad\u653e\u4e8b\u4ef6\u56de\u8c03\u3001\u64ad\u653e\u5668\u9519\u8bef\u4e0a\u62a5\u7b49\u63a5\u53e3\u3002<\/p>\n<\/li>\n<li>\n<p>\u64ad\u653e\u5668\u5c01\u88c5\u5c42&#xff1a;\u57fa\u4e8e\u5e73\u53f0\u5f00\u53d1\u8bed\u8a00\u5bf9\u64ad\u653e\u5668\u5185\u6838\u8fdb\u884c\u5c01\u88c5&#xff0c;\u63d0\u4f9b\u9ad8\u5185\u805a\u4f4e\u8026\u5408\u7684\u64ad\u653e\u5668\u63a5\u53e3\u3002<\/p>\n<\/li>\n<li>\n<p>\u64ad\u653e\u5668\u5de5\u5177\u5c42&#xff1a;\u5728\u64ad\u653e\u5668\u6838\u5fc3\u80fd\u529b\u7684\u57fa\u7840\u4e0a\u7ec4\u88c5\u548c\u6269\u5c55\u5176\u4ed6\u64ad\u653e\u76f8\u5173\u7684\u5176\u4ed6\u80fd\u529b&#xff0c;\u6bd4\u5982&#xff1a;\u8fb9\u4e0b\u8fb9\u64ad\u89c6\u9891\u7f13\u5b58\u80fd\u529b\u3001\u64ad\u653e\u8fdc\u7a0b\u914d\u7f6e\u80fd\u529b\u3001\u64ad\u653e\u6570\u636e\u57cb\u70b9\u4e0a\u62a5\u80fd\u529b\u7b49\u7b49\u3002<\/p>\n<\/li>\n<li>\n<p>\u64ad\u653e\u4e1a\u52a1\u63a7\u5236\u5c42&#xff1a;\u57fa\u4e8e\u4e1a\u52a1\u5c5e\u6027\u8fdb\u884c\u64ad\u653e\u7b56\u7565\u63a7\u5236&#xff0c;\u6bd4\u5982&#xff1a;\u7801\u7387\u9009\u6863\u3001\u89e3\u7801\u65b9\u5f0f\u9009\u62e9\u3001\u7f51\u7edc\u94fe\u8def\u4f18\u9009\u7b49\u7b56\u7565\u3002<\/p>\n<\/li>\n<\/ul>\n<h4>13\u3001\u5982\u4f55\u964d\u4f4e\u5904\u7406\u97f3\u89c6\u9891\u94fe\u8def\u4e2d\u7684\u5185\u5b58\u5cf0\u503c&#xff1f;<\/h4>\n<p>\u97f3\u89c6\u9891\u5904\u7406\u94fe\u8def\u4e2d\u7684\u5185\u5b58\u5cf0\u503c\u4e00\u822c\u662f\u89c6\u9891\u6570\u636e\u5bfc\u81f4\u7684&#xff0c;\u8981\u964d\u4f4e\u5185\u5b58\u5cf0\u503c\u4e00\u822c\u53ef\u4ee5\u4ece\u4e24\u4e2a\u65b9\u9762\u5165\u624b&#xff1a;<\/p>\n<p>\u964d\u4f4e\u91c7\u96c6\u53c2\u6570&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u964d\u4f4e\u91c7\u96c6\u89c6\u9891\u5206\u8fa8\u7387<\/p>\n<\/li>\n<li>\n<p>\u964d\u4f4e\u91c7\u96c6\u89c6\u9891\u5e27\u7387<\/p>\n<\/li>\n<\/ul>\n<p>\u964d\u4f4e\u5e76\u53d1\u4efb\u52a1\u6570\u91cf&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u5c06\u4efb\u52a1\u5206\u4f18\u5148\u7ea7&#xff0c;\u6309\u7167\u4f18\u5148\u7ea7\u4e32\u884c\u6267\u884c&#xff0c;\u8fd9\u6837\u65e2\u80fd\u964d\u4f4e\u5185\u5b58\u5cf0\u503c&#xff0c;\u4e5f\u4f1a\u964d\u4f4e CPU \u5cf0\u503c<\/p>\n<\/li>\n<\/ul>\n<h4>14\u3001\u804a\u804a\u5bf9\u97f3\u89c6\u9891\u540c\u6b65\u7684\u7406\u89e3&#xff1f;<\/h4>\n<p>\u97f3\u89c6\u9891\u5bf9\u9f50\u65b9\u5f0f\u6709\u4e09\u79cd&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u4ee5\u97f3\u9891\u65f6\u949f\u4e3a\u57fa\u51c6<\/p>\n<\/li>\n<li>\n<p>\u4ee5\u89c6\u9891\u65f6\u949f\u4e3a\u57fa\u51c6<\/p>\n<\/li>\n<li>\n<p>\u4ee5\u7b2c\u4e09\u65b9\u65f6\u949f\u4e3a\u57fa\u51c6<\/p>\n<\/li>\n<\/ul>\n<p>\u7531\u4e8e\u97f3\u9891\u64ad\u653e\u90fd\u662f\u786c\u4ef6\u6765\u9a71\u52a8\u7684&#xff0c;\u76f8\u5bf9\u6bd4\u8f83\u7a33\u5b9a&#xff0c;\u53e6\u5916\u97f3\u9891 pts \u901a\u5e38\u662f\u5355\u8c03\u9012\u589e\u7684&#xff0c;\u6240\u4ee5\u4e00\u822c\u662f\u6309\u7167\u97f3\u89c6\u65f6\u949f\u4e3a\u51c6\u3002<\/p>\n<p>\u4ee5\u4e00\u4e2a 44.1KHz \u7684 AAC \u97f3\u9891\u6d41\u548c 24 FPS \u7684\u89c6\u9891\u6d41\u4e3a\u4f8b&#xff0c;\u7406\u60f3\u60c5\u51b5\u4e0b&#xff0c;\u97f3\u89c6\u9891\u5b8c\u5168\u540c\u6b65&#xff0c;\u97f3\u89c6\u9891\u64ad\u653e\u8fc7\u7a0b\u5982\u4e0b\u56fe\u6240\u793a&#xff1a;<\/p>\n<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"113\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250528054311-6836a26f4b054.png\" width=\"689\" \/><\/p>\n<p>\u97f3\u89c6\u9891\u540c\u6b65<\/p>\n<p>\u4f46\u5b9e\u9645\u60c5\u51b5\u4e0b&#xff0c;\u5982\u679c\u7528\u4e0a\u9762\u90a3\u79cd\u7b80\u5355\u7684\u65b9\u5f0f&#xff0c;\u6162\u6162\u7684\u5c31\u4f1a\u51fa\u73b0\u97f3\u89c6\u9891\u4e0d\u540c\u6b65\u7684\u60c5\u51b5&#xff0c;\u4e3b\u8981\u539f\u56e0\u662f\u540c\u6b65\u65f6&#xff0c;\u65f6\u95f4\u7c92\u5ea6\u592a\u5927\u4e86&#xff0c;\u96be\u4ee5\u7cbe\u51c6\u63a7\u5236\u3002\u6240\u4ee5\u9700\u8981\u5f15\u5165\u4e00\u4e2a\u53c2\u8003\u65f6\u949f&#xff08;\u8981\u6c42\u53c2\u8003\u65f6\u949f\u4e0a\u7684\u65f6\u95f4\u662f\u6052\u5b9a\u7ebf\u6027\u9012\u589e\u7684&#xff09;\u6765\u63d0\u9ad8\u97f3\u9891\u65f6\u949f\u7684\u65f6\u95f4\u7c92\u5ea6&#xff0c;\u6bd4\u5982&#xff1a;\u7cfb\u7edf\u65f6\u95f4&#xff0c;\u8fdb\u800c\u8fdb\u884c\u7cbe\u51c6\u65f6\u949f\u5bf9\u9f50\u3002\u6700\u540e\u4ee5\u97f3\u9891\u65f6\u949f\u4e3a\u51c6&#xff0c;\u89c6\u9891\u653e\u5feb\u4e86\u5c31\u51cf\u6162\u64ad\u653e\u901f\u5ea6&#xff0c;\u64ad\u653e\u5feb\u4e86\u5c31\u4e22\u5e27\u6216\u52a0\u5feb\u64ad\u653e\u7684\u901f\u5ea6\u3002<\/p>\n<h4>15\u3001\u4e3a\u4ec0\u4e48\u5728 YUV \u8f6c RGB \u8f6c\u6362\u4e2d UV \u5206\u91cf\u8981\u51cf\u53bb 0.5&#xff1f;<\/h4>\n<p>\u5728 YUV \u5230 RGB \u7684\u8f6c\u6362\u516c\u5f0f\u4e2d&#xff0c;U \u548c V \u5206\u91cf\u51cf\u53bb 0.5 \u7684\u539f\u56e0\u4e0e YUV \u989c\u8272\u7a7a\u95f4\u7684\u7f16\u7801\u65b9\u5f0f\u6709\u5173\u3002YUV \u683c\u5f0f\u901a\u5e38\u7528\u4e8e\u89c6\u9891\u538b\u7f29&#xff0c;\u5176\u4e2d Y \u4ee3\u8868\u4eae\u5ea6&#xff08;luminance&#xff09;&#xff0c;\u800c U \u548c V \u4ee3\u8868\u8272\u5ea6&#xff08;chrominance&#xff09;&#xff0c;\u4e5f\u5c31\u662f\u989c\u8272\u4fe1\u606f\u3002\u5728\u67d0\u4e9b YUV \u683c\u5f0f\u4e2d&#xff0c;U \u548c V \u7684\u53d6\u503c\u8303\u56f4\u662f\u6807\u51c6\u5316\u7684&#xff0c;\u4f8b\u5982\u5728 8 \u4f4d\u989c\u8272\u6df1\u5ea6\u4e2d&#xff0c;U \u548c V \u7684\u53d6\u503c\u8303\u56f4\u662f\u4ece -128 \u5230 127\u3002\u8fd9\u79cd\u8868\u793a\u65b9\u6cd5\u5c06\u8272\u5ea6\u7684\u4e2d\u5fc3\u70b9\u8bbe\u5728\u4e86 0&#xff0c;\u4f7f\u5f97\u8272\u5ea6\u4fe1\u53f7\u53ef\u4ee5\u8868\u793a\u6b63\u8d1f\u504f\u5dee\u3002<\/p>\n<p>\u5728\u8fdb\u884c YUV \u5230 RGB \u7684\u8f6c\u6362\u65f6&#xff0c;\u4e3a\u4e86\u5c06 U \u548c V \u7684\u53d6\u503c\u8303\u56f4\u4ece\u5bf9\u79f0\u7684 -128 \u5230 127 \u5f52\u4e00\u5316\u4e3a\u975e\u5bf9\u79f0\u7684 0 \u5230 255&#xff0c;\u5e76\u4e14\u5c06\u4e2d\u5fc3\u70b9\u4ece 128 \u79fb\u52a8\u5230 0&#xff0c;\u9700\u8981\u5bf9 U \u548c V \u8fdb\u884c\u504f\u79fb\u91cf\u7684\u51cf\u6cd5\u64cd\u4f5c\u3002\u5177\u4f53\u6765\u8bf4&#xff0c;\u901a\u8fc7\u51cf\u53bb 0.5&#xff08;\u6216 128 \u5bf9\u5e94\u7684\u5c0f\u6570\u5f62\u5f0f&#xff09;&#xff0c;\u53ef\u4ee5\u5c06 U \u548c V \u7684\u53d6\u503c\u8303\u56f4\u8f6c\u6362\u4e3a 0 \u5230 255&#xff0c;\u4ece\u800c\u4e0e RGB \u7684\u53d6\u503c\u8303\u56f4\u76f8\u5339\u914d\u3002<\/p>\n<p>\u4f8b\u5982&#xff0c;\u5982\u679c\u4f7f\u7528\u5982\u4e0b\u7684\u8f6c\u6362\u516c\u5f0f&#xff1a;<\/p>\n<p>[ R &#061; Y &#043; 1.4075 * (V &#8211; 128) ]<br \/>\n[ G &#061; Y &#8211; 0.34414 * (U &#8211; 128) &#8211; 0.71414 * (V &#8211; 128) ]<br \/>\n[ B &#061; Y &#043; 1.772 * (U &#8211; 128) ] <\/p>\n<p>\u5728\u8fd9\u4e2a\u516c\u5f0f\u4e2d&#xff0c;U \u548c V \u51cf\u53bb 128 \u5b9e\u9645\u4e0a\u5c31\u662f\u5c06\u8272\u5ea6\u4fe1\u53f7\u7684\u4e2d\u5fc3\u4ece 128 \u79fb\u52a8\u5230 0&#xff0c;\u7136\u540e\u518d\u8fdb\u884c\u7f29\u653e\u64cd\u4f5c\u4ee5\u5339\u914d RGB \u7684\u53d6\u503c\u8303\u56f4\u3002\u5982\u679c\u4e0d\u8fdb\u884c\u8fd9\u4e2a\u51cf\u6cd5\u64cd\u4f5c&#xff0c;\u8272\u5ea6\u4fe1\u53f7\u5c06\u4e0d\u4f1a\u6b63\u786e\u5730\u8f6c\u6362\u4e3a RGB \u989c\u8272\u7a7a\u95f4&#xff0c;\u5bfc\u81f4\u989c\u8272\u5931\u771f\u3002<\/p>\n<p>\u603b\u7ed3\u6765\u8bf4&#xff0c;U \u548c V \u5206\u91cf\u540e\u9762\u51cf\u53bb 0.5 \u662f\u4e3a\u4e86\u5c06\u8272\u5ea6\u4fe1\u53f7\u7684\u8868\u793a\u65b9\u5f0f\u4ece YUV \u989c\u8272\u7a7a\u95f4\u8f6c\u6362\u4e3a RGB \u989c\u8272\u7a7a\u95f4&#xff0c;\u786e\u4fdd\u989c\u8272\u4fe1\u606f\u7684\u51c6\u786e\u4f20\u9012\u3002<\/p>\n<h4>16\u3001\u5982\u4f55\u83b7\u53d6\u89c6\u9891\u6d41\u4e2d\u7684 QP \u503c&#xff1f;<\/h4>\n<p>\u5728 H.264 \u4e2d&#xff0c;\u91cf\u5316\u53c2\u6570&#xff08;QP&#xff09;\u7684\u83b7\u53d6\u6d89\u53ca\u5230\u51e0\u4e2a\u5c42\u7ea7&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u56fe\u50cf\u53c2\u6570\u96c6&#xff08;PPS&#xff09;&#xff1a;\u5305\u542b\u521d\u59cb\u91cf\u5316\u53c2\u6570 pic_init_qp_minus26&#xff0c;\u5176\u53d6\u503c\u8303\u56f4\u662f -26 \u5230 &#043;25\u3002<\/p>\n<\/li>\n<li>\n<p>\u7247\u5934&#xff08;Slice Header&#xff09;&#xff1a;\u6bcf\u4e2a\u7247&#xff08;Slice&#xff09;\u90fd\u6709\u81ea\u5df1\u7684\u7247\u5934&#xff0c;\u5176\u4e2d\u5305\u542b slice_qp_delta&#xff0c;\u8868\u793a\u5f53\u524d\u7247\u6240\u6709\u5b8f\u5757\u7684\u91cf\u5316\u53c2\u6570\u521d\u59cb\u503c QPy Slice&#xff0c;\u8ba1\u7b97\u516c\u5f0f\u4e3a&#xff1a;QPy Slice &#061; 26 &#043; pic_init_qp_minus26 &#043; slice_qp_delta&#xff0c;\u5176\u53d6\u503c\u8303\u56f4\u662f 0 \u5230 51\u3002<\/p>\n<\/li>\n<li>\n<p>\u5b8f\u5757&#xff08;Macroblock, MB&#xff09;&#xff1a;\u5b8f\u5757\u662f\u7f16\u7801\u7684\u57fa\u672c\u5355\u5143&#xff0c;\u5b8f\u5757\u91cf\u5316\u53c2\u6570\u504f\u79fb\u503c mb_qp_delta \u8868\u793a\u524d\u540e\u4e24\u4e2a\u5b8f\u5757\u4e4b\u95f4\u7684\u504f\u79fb&#xff0c;\u53d6\u503c\u8303\u56f4\u662f -26 \u5230 &#043;25\u3002\u7b2c\u4e00\u4e2a\u5b8f\u5757\u7684 QP \u503c\u7b49\u4e8e\u7247\u5934\u7684 QP \u503c&#xff0c;\u540e\u7eed\u5b8f\u5757\u7684 QP \u503c\u8ba1\u7b97\u65b9\u5f0f\u4e3a QP &#061; (QPprev &#043; mb_qp_delta &#043; 52) % 52\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u8981\u4ece H.264 \u7801\u6d41\u4e2d\u63d0\u53d6 QP \u503c&#xff0c;\u9700\u8981\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4&#xff1a;<\/p>\n<ul>\n<li>\n<p>1\u3001\u89e3\u6790 NALU&#xff1a;\u9996\u5148\u9700\u8981\u5b9a\u4f4d\u5e76\u63d0\u53d6 NALU&#xff0c;\u56e0\u4e3a QP \u503c\u4fe1\u606f\u5206\u5e03\u5728 PPS \u548c Slice Header \u4e2d\u3002<\/p>\n<\/li>\n<li>\n<p>2\u3001\u89e3\u6790 PPS&#xff1a;\u627e\u5230 PPS NALU \u5e76\u89e3\u6790\u51fa pic_init_qp_minus26\u3002<\/p>\n<\/li>\n<li>\n<p>3\u3001\u89e3\u6790 Slice Header&#xff1a;\u5bf9\u4e8e\u6bcf\u4e2a Slice&#xff0c;\u89e3\u6790 Slice Header \u4ee5\u83b7\u53d6 slice_qp_delta\u3002<\/p>\n<\/li>\n<li>\n<p>4\u3001\u8ba1\u7b97 QP \u503c&#xff1a;\u6839\u636e\u4e0a\u8ff0\u89e3\u6790\u51fa\u7684\u53c2\u6570\u548c\u5b8f\u5757\u4fe1\u606f&#xff0c;\u8ba1\u7b97\u6bcf\u4e2a\u5b8f\u5757\u7684 QP \u503c\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u4f7f\u7528\u5de5\u5177&#xff1a;\u53ef\u4ee5\u4f7f\u7528\u5982 ffmpeg \u7b49\u5de5\u5177\u6765\u8f85\u52a9\u89e3\u6790\u7801\u6d41\u548c\u63d0\u53d6 QP \u503c\u3002\u4f8b\u5982&#xff0c;ffmpeg \u63d0\u4f9b\u4e86 -showqp \u9009\u9879\u6765\u663e\u793a\u91cf\u5316\u53c2\u6570\u3002<\/p>\n<p>\u7f16\u7a0b\u5b9e\u73b0&#xff1a;\u4e5f\u53ef\u4ee5\u901a\u8fc7\u7f16\u7a0b\u65b9\u5f0f&#xff0c;\u5982\u4f7f\u7528 Python \u7ed3\u5408\u76f8\u5173\u5e93\u6765\u89e3\u6790 H.264 \u7801\u6d41\u5e76\u63d0\u53d6 QP \u503c\u3002<\/p>\n<p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d&#xff0c;\u53ef\u80fd\u9700\u8981\u7ed3\u5408\u5177\u4f53\u7684\u7f16\u7801\u573a\u666f\u548c\u9700\u6c42\u6765\u9009\u62e9\u5408\u9002\u7684\u5de5\u5177\u548c\u65b9\u6cd5&#xff0c;\u4ee5\u5b9e\u73b0\u5bf9 H.264 \u7801\u6d41\u4e2d QP \u503c\u7684\u63d0\u53d6\u3002<\/p>\n<h4>17\u3001\u89c6\u9891\u7f16\u7801\u5bf9 QP \u503c\u7684\u63a7\u5236\u6709\u54ea\u4e9b&#xff1f;<\/h4>\n<p>\u5728\u89c6\u9891\u7f16\u7801\u4e2d&#xff0c;QP&#xff08;Quantization Parameter&#xff09;\u503c\u662f\u4e00\u4e2a\u91cd\u8981\u7684\u6982\u5ff5&#xff0c;\u5b83\u5bf9\u7f16\u7801\u540e\u89c6\u9891\u7684\u8d28\u91cf\u548c\u7801\u7387\u6709\u7740\u76f4\u63a5\u7684\u5f71\u54cd\u3002\u89c6\u9891\u7f16\u7801\u4e2d\u7684\u91cf\u5316\u6b65\u9aa4\u662f\u5c06\u50cf\u7d20\u503c\u6620\u5c04\u5230\u4e00\u4e2a\u8f83\u5c0f\u7684\u6570\u503c\u8303\u56f4\u5185&#xff0c;\u8fd9\u4e00\u6b65\u9aa4\u4f1a\u635f\u5931\u4e00\u4e9b\u56fe\u50cf\u7ec6\u8282&#xff0c;\u4f46\u53ef\u4ee5\u663e\u8457\u51cf\u5c11\u7f16\u7801\u540e\u89c6\u9891\u7684\u6570\u636e\u91cf\u3002<\/p>\n<p>QP \u503c\u51b3\u5b9a\u4e86\u91cf\u5316\u8fc7\u7a0b\u4e2d\u7684\u91cf\u5316\u6b65\u957f&#xff0c;\u4ece\u800c\u5f71\u54cd\u91cf\u5316\u7684\u7cbe\u5ea6\u3002\u8f83\u5c0f\u7684 QP \u503c\u610f\u5473\u7740\u91cf\u5316\u6b65\u957f\u8f83\u5c0f&#xff0c;\u91cf\u5316\u8fc7\u7a0b\u66f4\u7cbe\u7ec6&#xff0c;\u7f16\u7801\u540e\u7684\u89c6\u9891\u8d28\u91cf\u66f4\u9ad8&#xff0c;\u4f46\u540c\u65f6\u4e5f\u4f1a\u5bfc\u81f4\u7801\u7387\u589e\u52a0&#xff1b; \u8f83\u5927\u7684 QP \u503c\u610f\u5473\u7740\u91cf\u5316\u6b65\u957f\u8f83\u5927&#xff0c;\u91cf\u5316\u8fc7\u7a0b\u66f4\u7c97\u7cd9&#xff0c;\u7f16\u7801\u540e\u7684\u89c6\u9891\u8d28\u91cf\u8f83\u4f4e&#xff0c;\u4f46\u7801\u7387\u4f1a\u51cf\u5c11\u3002<\/p>\n<p>\u5bf9\u4e8e\u90e8\u5206\u8f6f\u7f16\u5e93\u6765\u8bf4\u662f\u53ef\u4ee5\u8bbe\u7f6e\u5e73\u5747\/\u6700\u5927\/\u6700\u5c0f QP \u503c\u7684\u3002\u4e0b\u9762\u6211\u4eec\u91cd\u70b9\u8bf4\u4e0b\u5ba2\u6237\u7aef\u5982\u4f55\u8bbe\u7f6e QP\u3002<\/p>\n<ul>\n<li>\n<p>\u5728 iOS \u4e2d\u4f7f\u7528 VideoToolbox \u7f16\u7801\u89c6\u9891\u65f6\u901a\u8fc7\u5c5e\u6027\u503c\u8bbe\u7f6e\u6700\u5927 QP \u548c\u6700\u5c0f QP \u503c\u3002\u5c5e\u6027 key \u4e3a kVTCompressionPropertyKey_MinAllowedFrameQP\u3001kVTCompressionPropertyKey_MaxAllowedFrameQP\u3002 \u8fd9\u6837\u7f16\u7801\u5668\u5c31\u4f1a\u4fdd\u8bc1\u662f\u7f16\u7801\u51fa\u6765\u7684\u6587\u4ef6 QP \u503c\u5728\u8fd9\u4e2a\u8303\u56f4\u3002\u5176\u6b21\u5982\u679c\u4f60\u8bbe\u7f6e\u4e86\u7801\u7387&#xff0c;\u4ed6\u4e5f\u4f1a\u5728\u8fd9\u4e2a\u8303\u56f4\u5185\u5c3d\u91cf\u4f7f\u7528\u4f60\u8bbe\u7f6e\u7684\u7801\u7387\u3002\u4f46\u662f\u5982\u679c\u4f60\u8bbe\u7f6e\u7684\u7801\u7387\u8fc7\u9ad8\u6216\u8005\u8fc7\u4f4e&#xff0c;QP \u503c\u65e0\u6cd5\u6ee1\u8db3\u65f6&#xff0c;\u7f16\u7801\u5668\u5219\u6839\u636e\u4f18\u5148\u4ee5 QP \u503c\u81ea\u52a8\u8c03\u6574\u7801\u7387\u3002<\/p>\n<\/li>\n<li>\n<p>Android \u90e8\u5206\u673a\u578b\u7684\u7f16\u7801\u5668\u53ef\u4ee5\u5f00\u542f\u8d28\u91cf\u7f16\u7801\u6a21\u5f0f&#xff0c;\u5373 KEY_BITRATE_MODE \u4e3a BITRATE_MODE_CQ\u3002\u8d28\u91cf\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e\u53c2\u6570 KEY_VIDEO_QP_MAX\u3001KEY_VIDEO_QP_MIN\u3001KEY_VIDEO_QP_P_MAX\u3001KEY_VIDEO_QP_P_MIN\u3001KEY_VIDEO_QP_B_MAX\u3001KEY_VIDEO_QP_B_MIN \u7b49\u4e00\u7cfb\u5217\u53c2\u6570\u6765\u63a7\u5236\u5e27\u7684 QP \u503c\u3002<\/p>\n<\/li>\n<\/ul>\n<h4>18\u3001\u7eb9\u7406\u6709\u54ea\u4e9b\u73af\u7ed5\u65b9\u5f0f&#xff08;wrapping&#xff09;&#xff1f;<\/h4>\n<ul>\n<li>\n<p>\u91cd\u590d&#xff08;GL_Repeat&#xff09;&#xff1a;\u7eb9\u7406\u5728\u6bcf\u4e2a\u7eb9\u7406\u5750\u6807\u8f74\u4e0a\u91cd\u590d\u51fa\u73b0&#xff0c;\u5f53\u7eb9\u7406\u5750\u6807\u8d85\u51fa [0,1] \u8303\u56f4\u65f6&#xff0c;\u7eb9\u7406\u4f1a\u5728\u8be5\u8f74\u4e0a\u91cd\u590d\u51fa\u73b0\u3002\u8fd9\u79cd\u65b9\u5f0f\u9002\u7528\u4e8e\u521b\u5efa\u65e0\u7f1d\u5e73\u94fa\u6548\u679c\u3002\u8fd9\u662f\u5bf9\u7eb9\u7406\u7684\u9ed8\u8ba4\u884c\u4e3a\u3002<\/p>\n<\/li>\n<li>\n<p>\u955c\u50cf\u91cd\u590d&#xff08;GL_MIRRORED_REPEAT&#xff09;&#xff1a;\u4e0e\u91cd\u590d&#xff08;GL_Repeat&#xff09;\u65b9\u5f0f\u76f8\u4f3c&#xff0c;\u4f46\u5f53\u7eb9\u7406\u5750\u6807\u8d85\u51fa [0,1] \u8303\u56f4\u65f6&#xff0c;\u4f1a\u5c06\u5176\u955c\u50cf\u7ffb\u8f6c\u540e\u518d\u91cd\u590d\u51fa\u73b0\u3002\u8fd9\u53ef\u4ee5\u6709\u6548\u51cf\u5c11\u7eb9\u7406\u91cd\u590d\u9020\u6210\u7684\u89c6\u89c9\u75b2\u52b3\u3002<\/p>\n<\/li>\n<li>\n<p>\u5939\u53d6\u5230\u8fb9\u7f18&#xff08;GL_CLAMP_TO_EDGE&#xff09;&#xff1a;\u4e0e\u5939\u53d6\u65b9\u5f0f\u7c7b\u4f3c&#xff0c;\u4f46\u5728\u8d85\u51fa\u8303\u56f4\u65f6&#xff0c;\u4f1a\u4f7f\u7528\u8fb9\u7f18\u7eb9\u7d20\u7684\u989c\u8272&#xff0c;\u4ea7\u751f\u4e00\u79cd\u8fb9\u7f18\u88ab\u62c9\u4f38\u7684\u6548\u679c\u3002<\/p>\n<\/li>\n<li>\n<p>\u5939\u53d6\u5230\u8fb9\u6846&#xff08;GL_CLAMP_TO_BORDER&#xff09;&#xff1a;\u8d85\u51fa\u8303\u56f4\u65f6&#xff0c;\u4f7f\u7528\u6307\u5b9a\u7684\u8fb9\u6846\u989c\u8272\u3002\u8fd9\u79cd\u65b9\u5f0f\u901a\u5e38\u7528\u4e8e\u5728\u8d85\u51fa\u7eb9\u7406\u8303\u56f4\u65f6\u586b\u5145\u8fb9\u6846\u989c\u8272&#xff0c;\u907f\u514d\u9ed1\u8fb9\u3002<\/p>\n<\/li>\n<\/ul>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"203\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250528054311-6836a26f598d9.png\" width=\"720\" \/><\/p>\n<h4>19\u3001\u4e3a\u4ec0\u4e48\u89c6\u9891\u4f1a\u8bae\u7528 UDP&#xff1f;\u5982\u679c\u7528 TCP \u5b9e\u73b0\u97f3\u89c6\u9891&#xff0c;\u9700\u8981\u5efa\u7acb\u51e0\u6b21\u8fde\u63a5&#xff1f;\u7528 UDP \u5b9e\u73b0\u97f3\u89c6\u9891&#xff0c;\u6709\u4ec0\u4e48\u65b9\u6cd5\u53ef\u4ee5\u4fdd\u8bc1\u901a\u8bdd\u8d28\u91cf&#xff1f;<\/h4>\n<p>1&#xff09;\u4e3a\u4ec0\u4e48\u89c6\u9891\u4f1a\u8bae\u7528 UDP&#xff1f;<\/p>\n<p>\u89c6\u9891\u4f1a\u8bae\u573a\u666f\u6700\u91cd\u8981\u7684\u4f53\u9a8c\u6307\u6807\u4e00\u822c\u662f\u300e\u901a\u8bdd\u5ef6\u65f6\u300f\u548c\u300e\u8bed\u97f3\u97f3\u8d28\u300f\u4e24\u65b9\u9762\u3002<\/p>\n<p>\u5728\u4f20\u8f93\u5c42\u4f7f\u7528 UDP \u7684\u4e3b\u8981\u8003\u8651\u662f\u4e3a\u4e86\u964d\u4f4e\u901a\u8bdd\u5ef6\u65f6\u3002\u56e0\u4e3a UDP \u7684\u4e0d\u9700\u8981 TCP \u90a3\u6837\u7684\u9762\u5411\u8fde\u63a5\u3001\u53ef\u9760\u4f20\u8f93\u3001\u62e5\u585e\u63a7\u5236\u7b49\u673a\u5236&#xff0c;\u8fd9\u4e9b\u673a\u5236&#xff08;\u6bd4\u5982\u4e09\u6b21\u63e1\u624b\u5efa\u8fde\u3001\u4e22\u5305\u91cd\u4f20\u7b49&#xff09;\u901a\u5e38\u90fd\u4f1a\u5e26\u6765\u76f8\u5bf9 UDP \u66f4\u9ad8\u7684\u5ef6\u65f6\u3002<\/p>\n<p>\u5f53\u7136&#xff0c;\u53e6\u5916\u4e00\u65b9\u9762\u539f\u56e0\u662f\u4eba\u4eec\u5bf9\u89c6\u9891\u4f1a\u8bae\u4e2d\u56fe\u50cf\u4fe1\u606f\u7684\u635f\u5931\u5bb9\u5fcd\u5ea6\u662f\u6bd4\u8f83\u9ad8\u7684&#xff0c;\u8fd9\u6837\u5373\u4f7f UDP \u65e0\u6cd5\u4fdd\u8bc1\u53ef\u9760\u6027&#xff0c;\u6709\u65f6\u5019\u8fd8\u662f\u53ef\u4ee5\u63a5\u53d7\u7684\u3002<\/p>\n<p>2&#xff09;\u5982\u679c\u7528 TCP \u5b9e\u73b0\u97f3\u89c6\u9891&#xff0c;\u9700\u8981\u5efa\u7acb\u51e0\u6b21\u8fde\u63a5&#xff1f;<\/p>\n<p>\u53ef\u4ee5\u505a\u5230\u53ea\u5efa\u8fde\u4e00\u6b21&#xff0c;\u591a\u8def\u590d\u7528\u3002 \u4e5f\u53ef\u4ee5\u97f3\u9891\u548c\u89c6\u9891\u5404\u4f7f\u7528\u4e00\u8def\u8fde\u63a5\u3002<\/p>\n<p>3&#xff09;\u7528 UDP \u5b9e\u73b0\u97f3\u89c6\u9891&#xff0c;\u6709\u4ec0\u4e48\u65b9\u6cd5\u53ef\u4ee5\u4fdd\u8bc1\u901a\u8bdd\u8d28\u91cf&#xff1f;<\/p>\n<p>\u4f7f\u7528 UDP \u4eab\u53d7\u4e86\u4f4e\u5ef6\u65f6&#xff0c;\u727a\u7272\u4e86\u53ef\u9760\u6027\u3002\u4f46\u53ef\u9760\u6027\u727a\u7272\u592a\u591a\u5bfc\u81f4\u4e0d\u53ef\u7528\u4e5f\u662f\u4e0d\u53ef\u63a5\u53d7\u7684&#xff0c;\u6240\u4ee5\u8fd8\u9700\u8981\u505a\u4e00\u4e9b\u673a\u5236\u6765\u4fdd\u8bc1\u4e00\u5b9a\u7684\u53ef\u9760\u6027&#xff0c;\u6bd4\u5982\u6211\u4eec\u53ef\u4ee5\u53c2\u8003 WebRTC \u7684\u673a\u5236&#xff1a;<\/p>\n<ul>\n<li>\n<p>NACK&#xff1a;\u901a\u8fc7\u4e22\u5305\u91cd\u4f20\u89e3\u51b3\u4e22\u5305\u95ee\u9898&#xff0c;\u4f1a\u589e\u52a0\u5ef6\u65f6\u3002<\/p>\n<\/li>\n<li>\n<p>FEC&#xff1a;\u901a\u8fc7\u5197\u4f59\u6570\u636e\u89e3\u51b3\u4e22\u5305\u95ee\u9898&#xff0c;\u4f1a\u589e\u52a0\u5e26\u5bbd\u5360\u7528\u3002<\/p>\n<\/li>\n<li>\n<p>JitterBuffer&#xff1a;\u901a\u8fc7\u961f\u5217\u5bf9\u63a5\u6536\u5230\u7684\u6570\u636e\u8fdb\u884c\u7f13\u51b2&#xff0c;\u51fa\u961f\u65f6\u5c06\u6570\u636e\u5305\u5747\u5300\u5e73\u6ed1\u7684\u53d6\u51fa&#xff0c;\u89e3\u51b3\u89c6\u9891\u7684\u4e71\u5e8f\u4e0e\u6296\u52a8\u3002<\/p>\n<\/li>\n<li>\n<p>NetEQ&#xff1a;\u7c7b\u4f3c JitterBuffer&#xff0c;\u89e3\u51b3\u97f3\u9891\u7684\u4e71\u5e8f\u4e0e\u6296\u52a8\u3002<\/p>\n<\/li>\n<\/ul>\n<h4>20\u3001\u4e3a\u4ec0\u4e48\u4f1a\u6709 YUV \u8fd9\u79cd\u6570\u636e&#xff1f;\u5b83\u76f8\u6bd4 RGB \u6570\u636e\u6709\u4ec0\u4e48\u4f18\u70b9&#xff1f;<\/h4>\n<p>RGB \u5de5\u4e1a\u663e\u793a\u5668\u8981\u6c42\u4e00\u5e45\u5f69\u8272\u56fe\u50cf\u7531\u5206\u5f00\u7684 R\u3001G\u3001B \u4fe1\u53f7\u7ec4\u6210&#xff0c;\u800c\u7535\u89c6\u663e\u793a\u5668\u5219\u9700\u8981\u6df7\u5408\u4fe1\u53f7\u8f93\u5165&#xff0c;\u4e3a\u4e86\u5b9e\u73b0\u5bf9\u8fd9\u4e24\u79cd\u6807\u51c6\u7684\u517c\u5bb9&#xff0c;NTSC&#xff08;\u7f8e\u56fd\u56fd\u5bb6\u7535\u89c6\u7cfb\u7edf\u59d4\u5458\u4f1a&#xff09;\u5236\u5b9a\u4e86 YIQ \u989c\u8272\u6a21\u578b&#xff0c;\u5b83\u7684\u4e3b\u8981\u4f18\u70b9\u662f\u53ef\u4ee5\u5b9e\u73b0\u5bf9\u5f69\u8272\u7535\u89c6\u548c\u9ed1\u767d\u7535\u89c6\u7684\u517c\u5bb9&#xff0c;\u5373\u53ef\u4ee5\u7528\u9ed1\u767d\u7535\u89c6\u6536\u770b\u5f69\u8272\u7535\u89c6\u4fe1\u53f7\u3002YUV \u989c\u8272\u6a21\u578b\u5219\u662f\u5728 YIQ \u7684\u57fa\u7840\u4e0a\u53d1\u5c55\u800c\u6765\u3002<\/p>\n<p>YUV \u989c\u8272\u6a21\u578b\u4e2d\u7528\u4eae\u5ea6\u3001\u8272\u5ea6\u6765\u8868\u793a\u989c\u8272\u3002\u5b83\u7684\u4eae\u5ea6\u4fe1\u606f\u548c\u8272\u5ea6\u4fe1\u606f\u662f\u5206\u79bb\u7684&#xff0c;\u5176\u4e2d Y \u8868\u793a\u4eae\u5ea6\u901a\u9053&#xff0c;U \u548c V \u5219\u8868\u793a\u8272\u5ea6\u901a\u9053\u3002\u5982\u679c\u53ea\u6709 Y \u4fe1\u606f&#xff0c;\u6ca1\u6709 U\u3001V \u4fe1\u606f&#xff0c;\u90a3\u4e48\u8868\u793a\u7684\u56fe\u50cf\u5c31\u662f\u7070\u5ea6\u56fe\u50cf\u3002YUV \u5e38\u7528\u5728\u5404\u79cd\u5f71\u50cf\u5904\u7406\u573a\u666f\u4e2d\u3002YUV \u5728\u5bf9\u7167\u7247\u6216\u89c6\u9891\u7f16\u7801\u65f6&#xff0c;\u8003\u8651\u5230\u4eba\u773c\u5bf9\u4eae\u5ea6\u4fe1\u606f\u7684\u654f\u611f\u5ea6\u9ad8\u4e8e\u8272\u5ea6\u4fe1\u606f&#xff0c;\u5141\u8bb8\u964d\u4f4e\u8272\u5ea6\u7684\u5e26\u5bbd\u3002\u8fd9\u6837\u4e00\u6765\u5c31\u53ef\u4ee5\u5bf9\u8272\u5ea6\u4fe1\u606f\u8fdb\u884c\u538b\u7f29&#xff0c;\u6240\u4ee5 YUV \u53ef\u4ee5\u76f8\u5bf9 RGB \u4f7f\u7528\u66f4\u5c11\u7684\u6570\u636e\u5e26\u5bbd\u3002\u6bd4\u5982\u5e38\u89c1\u7684\u91c7\u6837\u683c\u5f0f\u6709&#xff1a;4:2:1\u30014:1:1\u30014:2:0 \u7b49&#xff0c;\u5b83\u4eec\u5206\u522b\u76f8\u5bf9 RGB \u538b\u7f29\u4e86 33.3%\u300150%\u300150% \u7684\u6570\u636e\u91cf\u3002<\/p>\n<h4>21\u3001RTMP \u6d88\u606f\u5206\u4f18\u5148\u7ea7\u7684\u8bbe\u8ba1\u6709\u4ec0\u4e48\u597d\u5904&#xff1f;<\/h4>\n<p>RTMP \u7684\u6d88\u606f\u4f18\u5148\u7ea7\u662f&#xff1a;\u63a7\u5236\u6d88\u606f &gt; \u97f3\u9891\u6d88\u606f &gt; \u89c6\u9891\u6d88\u606f\u3002\u5f53\u7f51\u7edc\u4f20\u8f93\u80fd\u529b\u53d7\u9650\u65f6&#xff0c;\u4f18\u5148\u4f20\u8f93\u9ad8\u4f18\u5148\u7ea7\u6d88\u606f\u7684\u6570\u636e\u3002<\/p>\n<p>\u8981\u4f7f\u4f18\u5148\u7ea7\u80fd\u591f\u6709\u6548\u6267\u884c&#xff0c;\u5206\u5757\u4e5f\u5f88\u5173\u952e&#xff1a;\u5c06\u5927\u6d88\u606f\u5207\u5272\u6210\u5c0f\u5757&#xff0c;\u53ef\u4ee5\u907f\u514d\u5927\u7684\u4f4e\u4f18\u5148\u7ea7\u7684\u6d88\u606f&#xff08;\u5982\u89c6\u9891\u6d88\u606f&#xff09;\u5835\u585e\u4e86\u53d1\u9001\u7f13\u51b2\u4ece\u800c\u963b\u585e\u4e86\u5c0f\u7684\u9ad8\u4f18\u5148\u7ea7\u7684\u6d88\u606f&#xff08;\u5982\u97f3\u9891\u6d88\u606f\u6216\u63a7\u5236\u6d88\u606f&#xff09;\u3002<\/p>\n<h4>22\u3001iOS \u4e2d\u5982\u4f55\u5224\u65ad\u4e00\u4e2a\u89c6\u9891\u5e27\u662f\u4e0d\u662f\u5173\u952e\u5e27&#xff1f;<\/h4>\n<p>\u5728 VideoToolbox \u4e2d&#xff0c;\u53ef\u4ee5\u901a\u8fc7\u68c0\u67e5\u7ed9\u5b9a\u7684 CMSampleBuffer \u662f\u5426\u662f\u89c6\u9891\u5e27&#xff0c;\u5e76\u4e14\u662f\u5426\u662f\u5173\u952e\u5e27\u3002\u901a\u8fc7\u68c0\u67e5 kCMSampleAttachmentKey_NotSync \u952e\u7684\u503c&#xff0c;\u5982\u679c\u5b83\u4e3a false &#xff0c;\u5219\u8bf4\u660e\u8fd9\u662f\u4e00\u4e2a\u5173\u952e\u5e27\u3002\u4ee5\u4e0b\u662f\u793a\u4f8b\u4ee3\u7801<\/p>\n<p>#import &lt;VideoToolbox\/VideoToolbox.h&gt;<\/p>\n<p>BOOL isKeyFrame(CMSampleBufferRef sampleBuffer) {<br \/>\n    CMFormatDescriptionRef formatDescription &#061; CMSampleBufferGetFormatDescription(sampleBuffer);<br \/>\n    if (!formatDescription) {<br \/>\n        return NO;<br \/>\n    }<\/p>\n<p>    CMMediaType mediaType &#061; CMFormatDescriptionGetMediaType(formatDescription);<br \/>\n    if (mediaType !&#061; kCMMediaType_Video) {<br \/>\n        return NO;<br \/>\n    }<\/p>\n<p>    CFArrayRef sampleAttachmentsArray &#061; CMSampleBufferGetSampleAttachmentsArray(sampleBuffer, true);<br \/>\n    CFDictionaryRef sampleAttachments &#061; (CFDictionaryRef)CFArrayGetValueAtIndex(sampleAttachmentsArray, 0);<br \/>\n    BOOL isKeyFrame &#061; !CFDictionaryContainsKey(sampleAttachments, kCMSampleAttachmentKey_NotSync);<br \/>\n    return isKeyFrame;<br \/>\n} <\/p>\n<h4>23\u3001iOS \u4e2d\u7cfb\u7edf API \u63d0\u4f9b\u4e86\u54ea\u4e9b\u89c6\u9891\u7f16\u7801\u7684\u65b9\u5f0f&#xff1f;<\/h4>\n<p>\u5728 iOS \u4e2d&#xff0c;\u5b9e\u73b0\u89c6\u9891\u7f16\u7801\u7684\u65b9\u5f0f\u4e3b\u8981\u5305\u62ec\u4ee5\u4e0b\u4e24\u79cd&#xff1a;<\/p>\n<ul>\n<li>\n<p>AVFoundation \u6846\u67b6&#xff1a;AVFoundation \u662f\u82f9\u679c\u63d0\u4f9b\u7684\u4e00\u4e2a\u7528\u4e8e\u5904\u7406\u97f3\u89c6\u9891\u6570\u636e\u7684\u6846\u67b6&#xff0c;\u5b83\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u7528\u4e8e\u6355\u83b7\u3001\u5904\u7406\u548c\u8f93\u51fa\u97f3\u89c6\u9891\u6570\u636e\u7684\u7c7b\u548c\u65b9\u6cd5\u3002\u901a\u8fc7 AVFoundation \u6846\u67b6&#xff0c;\u53ef\u4ee5\u4f7f\u7528 AVAssetWriter \u548c AVAssetWriterInput \u7c7b\u6765\u5b9e\u73b0\u7f16\u7801\u89c6\u9891\u3002<\/p>\n<\/li>\n<li>\n<p>VideoToolbox \u6846\u67b6&#xff1a;VideoToolbox \u662f\u82f9\u679c\u63d0\u4f9b\u7684\u4e00\u4e2a\u4e13\u95e8\u7528\u4e8e\u5904\u7406\u89c6\u9891\u6570\u636e\u7684\u6846\u67b6&#xff0c;\u5b83\u63d0\u4f9b\u4e86\u786c\u4ef6\u52a0\u901f\u7684\u89c6\u9891\u7f16\u7801\u548c\u89e3\u7801\u529f\u80fd\u3002\u4f7f\u7528 VideoToolbox&#xff0c;\u53ef\u4ee5\u5229\u7528 iOS \u8bbe\u5907\u4e0a\u7684\u786c\u4ef6\u7f16\u7801\u5668\u6765\u5b9e\u73b0\u9ad8\u6548\u7684\u89c6\u9891\u7f16\u7801\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u76f8\u6bd4\u800c\u8a00&#xff0c;AVFoundation \u6846\u67b6\u5219\u63d0\u4f9b\u4e86\u66f4\u52a0\u4e0a\u5c42\u7684\u63a5\u53e3&#xff0c;\u66f4\u7b80\u5355\u6613\u7528&#xff0c;\u4f46\u56e0\u6b64\u5bf9\u4e8e\u4e00\u4e9b\u7279\u6b8a\u9700\u6c42\u548c\u9ad8\u7ea7\u529f\u80fd&#xff0c;\u53ef\u80fd\u65e0\u6cd5\u6ee1\u8db3\u3002VideoToolbox \u5219\u63d0\u4f9b\u4e86\u66f4\u76f4\u63a5\u7684\u5bf9\u786c\u4ef6\u7f16\u7801\u5668\u7684\u8bbf\u95ee&#xff0c;\u5141\u8bb8\u5f00\u53d1\u8005\u80fd\u66f4\u7ec6\u81f4\u7684\u63a7\u5236\u7f16\u7801\u5668\u7684\u914d\u7f6e\u548c\u53c2\u6570&#xff0c;\u5e76\u4e14\u53ef\u4ee5\u76f4\u63a5\u64cd\u4f5c\u7f16\u7801\u5668\u7684\u8f93\u5165\u548c\u8f93\u51fa\u6570\u636e&#xff0c;\u7075\u6d3b\u6027\u66f4\u597d\u3002<\/p>\n<h4>24\u3001VideoToolbox \u89c6\u9891\u5e27\u89e3\u7801\u5931\u8d25\u4ee5\u540e\u5e94\u8be5\u5982\u4f55\u91cd\u8bd5&#xff1f;<\/h4>\n<ul>\n<li>\n<p>1\u3001\u91cd\u65b0\u521d\u59cb\u5316\u89e3\u7801\u5668&#xff1a;\u5c1d\u8bd5\u91cd\u65b0\u521d\u59cb\u5316 Videotoolbox \u89e3\u7801\u5668&#xff0c;\u6709\u65f6\u5019\u91cd\u65b0\u521d\u59cb\u5316\u53ef\u4ee5\u89e3\u51b3\u89e3\u7801\u8fc7\u7a0b\u4e2d\u7684\u4e00\u4e9b\u4e34\u65f6\u95ee\u9898\u3002<\/p>\n<\/li>\n<li>\n<p>2\u3001\u68c0\u67e5\u89c6\u9891\u6587\u4ef6&#xff1a;\u786e\u4fdd\u89c6\u9891\u6587\u4ef6\u6ca1\u6709\u635f\u574f\u6216\u8005\u683c\u5f0f\u4e0d\u6b63\u786e\u3002\u6709\u65f6\u5019\u89e3\u7801\u5931\u8d25\u662f\u56e0\u4e3a\u89c6\u9891\u6587\u4ef6\u672c\u8eab\u7684\u95ee\u9898&#xff0c;\u53ef\u4ee5\u5c1d\u8bd5\u4f7f\u7528\u5176\u4ed6\u5de5\u5177\u6216\u8005\u91cd\u65b0\u83b7\u53d6\u89c6\u9891\u6587\u4ef6\u3002<\/p>\n<\/li>\n<li>\n<p>3\u3001\u68c0\u67e5\u5f53\u524d\u5185\u5b58&#xff1a;\u5728\u89e3\u7801\u8fc7\u7a0b\u4e2d\u5982\u679c CMSampleBuffer \u4e0d\u53ca\u65f6\u91ca\u653e&#xff0c;\u53ef\u80fd\u4f1a\u5bfc\u81f4\u5185\u5b58\u8fc7\u9ad8\u5bfc\u81f4\u89e3\u7801\u5668\u62a5 -11800 \u901a\u7528\u9519\u8bef\u3002<\/p>\n<\/li>\n<li>\n<p>4\u3001\u5c1d\u8bd5\u91cd\u65b0\u89e3\u7801\u5f53\u524d\u5e27&#xff1a;\u5c06\u5f53\u524d\u5e27\u4ee5\u53ca\u5f53\u524d gop \u5185\u524d\u5e8f\u5e27\u90fd\u91cd\u65b0\u8f93\u5165\u7ed9\u89e3\u7801\u5668\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u6765\u6e90&#xff1a;\u5173\u952e\u5e27 &#8211; \u4e2a\u4eba\u4e2d\u5fc3<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb928\u6b21\uff0c\u70b9\u8d5e22\u6b21\uff0c\u6536\u85cf7\u6b21\u3002\u672c\u6587\u6458\u8981\u56f4\u7ed5\u97f3\u89c6\u9891\u7f16\u89e3\u7801\u6280\u672f\u5c55\u5f00\uff0c\u4e3b\u8981\u5305\u542b\u4ee5\u4e0b\u5185\u5bb9\uff1aH.264\u6807\u51c6\u89e3\u6790\uff1a\u8be6\u7ec6\u4ecb\u7ecdH.264\u7684\u7801\u6d41\u7ed3\u6784\uff08VCL\/NAL\u5206\u5c42\uff09\u3001\u5c01\u88c5\u6a21\u5f0f\uff08AnnexB\/AVCC\uff09\u53ca\u4e0eH.265\u7684\u533a\u522b\uff0c\u5305\u62ec\u7f16\u7801\u5355\u5143\u6269\u5c55\u81f364&#215;64\u50cf\u7d20\u7b49\u4f18\u5316\u3002\u5e27\u7c7b\u578b\u4e0e\u540c\u6b65\u673a\u5236\uff1a\u9610\u8ff0I\/P\/B\u5e27\u7684\u7f16\u89e3\u7801\u987a\u5e8f\u3001\u97f3\u89c6\u9891\u540c\u6b65\u7b56\u7565\uff08\u4ee5\u97f3\u9891\u65f6\u949f\u4e3a\u57fa\u51c6\uff09\u53caIDR\u5e27\u7684\u7279\u6b8a\u4f5c\u7528\u3002\u4f20\u8f93\u534f\u8bae\u5bf9\u6bd4\uff1a\u5206\u6790RTMP(TCP)\u4e0eRTSP(UDP)\u7684\u7279\u6027\u5dee\u5f02\uff0c\u63d0\u51faUDP\u73af\u5883\u4e0b\u901a\u8fc7NACK\/FEC\u4fdd\u8bc1\u4f20\u8f93\u8d28\u91cf\u7684\u65b9\u6848\u3002\u5173\u952e\u6280\u672f\u5b9e\u73b0\uff1a\u6db5\u76d6YUV\u683c\u5f0f\u8f6c\u6362\u539f\u7406\u3001QP\u503c\u63a7\u5236\u65b9\u6cd5\u3001<\/p>\n","protected":false},"author":2,"featured_media":40267,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[55,213,610,214,3686],"topic":[],"class_list":["post-40274","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-c","tag-ffmpeg","tag-rtmp","tag-214","tag-3686"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u3010\u5907\u6218\u79cb\u62db\u3011C++\u97f3\u89c6\u9891\u5f00\u53d1\u7ecf\u5178\u9762\u8bd5\u9898\u6574\u7406 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/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.wsisp.com\/helps\/40274.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u3010\u5907\u6218\u79cb\u62db\u3011C++\u97f3\u89c6\u9891\u5f00\u53d1\u7ecf\u5178\u9762\u8bd5\u9898\u6574\u7406 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb928\u6b21\uff0c\u70b9\u8d5e22\u6b21\uff0c\u6536\u85cf7\u6b21\u3002\u672c\u6587\u6458\u8981\u56f4\u7ed5\u97f3\u89c6\u9891\u7f16\u89e3\u7801\u6280\u672f\u5c55\u5f00\uff0c\u4e3b\u8981\u5305\u542b\u4ee5\u4e0b\u5185\u5bb9\uff1aH.264\u6807\u51c6\u89e3\u6790\uff1a\u8be6\u7ec6\u4ecb\u7ecdH.264\u7684\u7801\u6d41\u7ed3\u6784\uff08VCL\/NAL\u5206\u5c42\uff09\u3001\u5c01\u88c5\u6a21\u5f0f\uff08AnnexB\/AVCC\uff09\u53ca\u4e0eH.265\u7684\u533a\u522b\uff0c\u5305\u62ec\u7f16\u7801\u5355\u5143\u6269\u5c55\u81f364x64\u50cf\u7d20\u7b49\u4f18\u5316\u3002\u5e27\u7c7b\u578b\u4e0e\u540c\u6b65\u673a\u5236\uff1a\u9610\u8ff0I\/P\/B\u5e27\u7684\u7f16\u89e3\u7801\u987a\u5e8f\u3001\u97f3\u89c6\u9891\u540c\u6b65\u7b56\u7565\uff08\u4ee5\u97f3\u9891\u65f6\u949f\u4e3a\u57fa\u51c6\uff09\u53caIDR\u5e27\u7684\u7279\u6b8a\u4f5c\u7528\u3002\u4f20\u8f93\u534f\u8bae\u5bf9\u6bd4\uff1a\u5206\u6790RTMP(TCP)\u4e0eRTSP(UDP)\u7684\u7279\u6027\u5dee\u5f02\uff0c\u63d0\u51faUDP\u73af\u5883\u4e0b\u901a\u8fc7NACK\/FEC\u4fdd\u8bc1\u4f20\u8f93\u8d28\u91cf\u7684\u65b9\u6848\u3002\u5173\u952e\u6280\u672f\u5b9e\u73b0\uff1a\u6db5\u76d6YUV\u683c\u5f0f\u8f6c\u6362\u539f\u7406\u3001QP\u503c\u63a7\u5236\u65b9\u6cd5\u3001\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/40274.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-05-28T05:43:12+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250528054310-6836a26ecd825.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/40274.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/40274.html\",\"name\":\"\u3010\u5907\u6218\u79cb\u62db\u3011C++\u97f3\u89c6\u9891\u5f00\u53d1\u7ecf\u5178\u9762\u8bd5\u9898\u6574\u7406 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-05-28T05:43:12+00:00\",\"dateModified\":\"2025-05-28T05:43:12+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/40274.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/40274.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/40274.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u3010\u5907\u6218\u79cb\u62db\u3011C++\u97f3\u89c6\u9891\u5f00\u53d1\u7ecf\u5178\u9762\u8bd5\u9898\u6574\u7406\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u3010\u5907\u6218\u79cb\u62db\u3011C++\u97f3\u89c6\u9891\u5f00\u53d1\u7ecf\u5178\u9762\u8bd5\u9898\u6574\u7406 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","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.wsisp.com\/helps\/40274.html","og_locale":"zh_CN","og_type":"article","og_title":"\u3010\u5907\u6218\u79cb\u62db\u3011C++\u97f3\u89c6\u9891\u5f00\u53d1\u7ecf\u5178\u9762\u8bd5\u9898\u6574\u7406 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb928\u6b21\uff0c\u70b9\u8d5e22\u6b21\uff0c\u6536\u85cf7\u6b21\u3002\u672c\u6587\u6458\u8981\u56f4\u7ed5\u97f3\u89c6\u9891\u7f16\u89e3\u7801\u6280\u672f\u5c55\u5f00\uff0c\u4e3b\u8981\u5305\u542b\u4ee5\u4e0b\u5185\u5bb9\uff1aH.264\u6807\u51c6\u89e3\u6790\uff1a\u8be6\u7ec6\u4ecb\u7ecdH.264\u7684\u7801\u6d41\u7ed3\u6784\uff08VCL\/NAL\u5206\u5c42\uff09\u3001\u5c01\u88c5\u6a21\u5f0f\uff08AnnexB\/AVCC\uff09\u53ca\u4e0eH.265\u7684\u533a\u522b\uff0c\u5305\u62ec\u7f16\u7801\u5355\u5143\u6269\u5c55\u81f364x64\u50cf\u7d20\u7b49\u4f18\u5316\u3002\u5e27\u7c7b\u578b\u4e0e\u540c\u6b65\u673a\u5236\uff1a\u9610\u8ff0I\/P\/B\u5e27\u7684\u7f16\u89e3\u7801\u987a\u5e8f\u3001\u97f3\u89c6\u9891\u540c\u6b65\u7b56\u7565\uff08\u4ee5\u97f3\u9891\u65f6\u949f\u4e3a\u57fa\u51c6\uff09\u53caIDR\u5e27\u7684\u7279\u6b8a\u4f5c\u7528\u3002\u4f20\u8f93\u534f\u8bae\u5bf9\u6bd4\uff1a\u5206\u6790RTMP(TCP)\u4e0eRTSP(UDP)\u7684\u7279\u6027\u5dee\u5f02\uff0c\u63d0\u51faUDP\u73af\u5883\u4e0b\u901a\u8fc7NACK\/FEC\u4fdd\u8bc1\u4f20\u8f93\u8d28\u91cf\u7684\u65b9\u6848\u3002\u5173\u952e\u6280\u672f\u5b9e\u73b0\uff1a\u6db5\u76d6YUV\u683c\u5f0f\u8f6c\u6362\u539f\u7406\u3001QP\u503c\u63a7\u5236\u65b9\u6cd5\u3001","og_url":"https:\/\/www.wsisp.com\/helps\/40274.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-05-28T05:43:12+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250528054310-6836a26ecd825.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"8 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/40274.html","url":"https:\/\/www.wsisp.com\/helps\/40274.html","name":"\u3010\u5907\u6218\u79cb\u62db\u3011C++\u97f3\u89c6\u9891\u5f00\u53d1\u7ecf\u5178\u9762\u8bd5\u9898\u6574\u7406 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-05-28T05:43:12+00:00","dateModified":"2025-05-28T05:43:12+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/40274.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/40274.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/40274.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u3010\u5907\u6218\u79cb\u62db\u3011C++\u97f3\u89c6\u9891\u5f00\u53d1\u7ecf\u5178\u9762\u8bd5\u9898\u6574\u7406"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/40274","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=40274"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/40274\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/40267"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=40274"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=40274"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=40274"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=40274"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}