{"id":794,"date":"2026-01-25T09:51:20","date_gmt":"2026-01-25T01:51:20","guid":{"rendered":"https:\/\/ixriver.com\/?p=794"},"modified":"2026-01-25T09:51:20","modified_gmt":"2026-01-25T01:51:20","slug":"h-264%e7%a0%81%e6%b5%81%e7%bb%93%e6%9e%84","status":"publish","type":"post","link":"https:\/\/www.v.ixriver.com\/?p=794","title":{"rendered":"H.264\u7801\u6d41\u7ed3\u6784"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_65 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title \" >\u76ee\u5f55<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.v.ixriver.com\/?p=794\/#H264_%E7%A0%81%E6%B5%81%E7%BB%93%E6%9E%84\" title=\"H.264 \u7801\u6d41\u7ed3\u6784\">H.264 \u7801\u6d41\u7ed3\u6784<\/a><ul class='ez-toc-list-level-2' ><li class='ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.v.ixriver.com\/?p=794\/#%E6%A6%82%E8%BF%B0\" title=\"\u6982\u8ff0\">\u6982\u8ff0<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.v.ixriver.com\/?p=794\/#NAL_%E5%8D%95%E5%85%83%E7%BB%93%E6%9E%84\" title=\"NAL \u5355\u5143\u7ed3\u6784\">NAL \u5355\u5143\u7ed3\u6784<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.v.ixriver.com\/?p=794\/#%E5%9F%BA%E6%9C%AC%E7%BB%93%E6%9E%84\" title=\"\u57fa\u672c\u7ed3\u6784\">\u57fa\u672c\u7ed3\u6784<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.v.ixriver.com\/?p=794\/#NAL_Header_%E8%A7%A3%E6%9E%90%E7%A4%BA%E4%BE%8B\" title=\"NAL Header \u89e3\u6790\u793a\u4f8b\">NAL Header \u89e3\u6790\u793a\u4f8b<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.v.ixriver.com\/?p=794\/#NAL_%E5%8D%95%E5%85%83%E7%B1%BB%E5%9E%8B\" title=\"NAL \u5355\u5143\u7c7b\u578b\">NAL \u5355\u5143\u7c7b\u578b<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.v.ixriver.com\/?p=794\/#%E9%87%8D%E8%A6%81_NAL_%E5%8D%95%E5%85%83%E7%B1%BB%E5%9E%8B%E8%AF%A6%E8%A7%A3\" title=\"\u91cd\u8981 NAL \u5355\u5143\u7c7b\u578b\u8be6\u89e3\">\u91cd\u8981 NAL \u5355\u5143\u7c7b\u578b\u8be6\u89e3<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.v.ixriver.com\/?p=794\/#1_SPS%EF%BC%88Sequence_Parameter_Set%EF%BC%8C%E5%BA%8F%E5%88%97%E5%8F%82%E6%95%B0%E9%9B%86%EF%BC%89\" title=\"1. SPS\uff08Sequence Parameter Set\uff0c\u5e8f\u5217\u53c2\u6570\u96c6\uff09\">1. SPS\uff08Sequence Parameter Set\uff0c\u5e8f\u5217\u53c2\u6570\u96c6\uff09<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.v.ixriver.com\/?p=794\/#2_PPS%EF%BC%88Picture_Parameter_Set%EF%BC%8C%E5%9B%BE%E5%83%8F%E5%8F%82%E6%95%B0%E9%9B%86%EF%BC%89\" title=\"2. PPS\uff08Picture Parameter Set\uff0c\u56fe\u50cf\u53c2\u6570\u96c6\uff09\">2. PPS\uff08Picture Parameter Set\uff0c\u56fe\u50cf\u53c2\u6570\u96c6\uff09<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.v.ixriver.com\/?p=794\/#3_IDR_%E5%B8%A7%EF%BC%88Instantaneous_Decoder_Refresh%EF%BC%89\" title=\"3. IDR \u5e27\uff08Instantaneous Decoder Refresh\uff09\">3. IDR \u5e27\uff08Instantaneous Decoder Refresh\uff09<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.v.ixriver.com\/?p=794\/#4_%E9%9D%9EIDR%E5%9B%BE%E5%83%8F%EF%BC%88%E6%99%AE%E9%80%9A%E8%A7%86%E9%A2%91%E5%B8%A7%EF%BC%89\" title=\"4. \u975eIDR\u56fe\u50cf\uff08\u666e\u901a\u89c6\u9891\u5e27\uff09\">4. \u975eIDR\u56fe\u50cf\uff08\u666e\u901a\u89c6\u9891\u5e27\uff09<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/www.v.ixriver.com\/?p=794\/#5_SEI%EF%BC%88Supplemental_Enhancement_Information%EF%BC%8C%E8%A1%A5%E5%85%85%E5%A2%9E%E5%BC%BA%E4%BF%A1%E6%81%AF%EF%BC%89\" title=\"5. SEI\uff08Supplemental Enhancement Information\uff0c\u8865\u5145\u589e\u5f3a\u4fe1\u606f\uff09\">5. SEI\uff08Supplemental Enhancement Information\uff0c\u8865\u5145\u589e\u5f3a\u4fe1\u606f\uff09<\/a><\/li><\/ul><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/www.v.ixriver.com\/?p=794\/#%E7%A0%81%E6%B5%81%E6%A0%BC%E5%BC%8F\" title=\"\u7801\u6d41\u683c\u5f0f\">\u7801\u6d41\u683c\u5f0f<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/www.v.ixriver.com\/?p=794\/#1_Annex-B_%E6%A0%BC%E5%BC%8F\" title=\"1. Annex-B \u683c\u5f0f\">1. Annex-B \u683c\u5f0f<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/www.v.ixriver.com\/?p=794\/#2_AVCC_%E6%A0%BC%E5%BC%8F%EF%BC%88MP4_%E6%A0%BC%E5%BC%8F%EF%BC%89\" title=\"2. AVCC \u683c\u5f0f\uff08MP4 \u683c\u5f0f\uff09\">2. AVCC \u683c\u5f0f\uff08MP4 \u683c\u5f0f\uff09<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/www.v.ixriver.com\/?p=794\/#%E6%A0%BC%E5%BC%8F%E8%BD%AC%E6%8D%A2\" title=\"\u683c\u5f0f\u8f6c\u6362\">\u683c\u5f0f\u8f6c\u6362<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-17\" href=\"https:\/\/www.v.ixriver.com\/?p=794\/#%E7%A0%81%E6%B5%81%E7%BB%93%E6%9E%84%E7%A4%BA%E4%BE%8B\" title=\"\u7801\u6d41\u7ed3\u6784\u793a\u4f8b\">\u7801\u6d41\u7ed3\u6784\u793a\u4f8b<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-18\" href=\"https:\/\/www.v.ixriver.com\/?p=794\/#%E5%AE%8C%E6%95%B4%E7%9A%84_H264_%E7%A0%81%E6%B5%81%E7%BB%93%E6%9E%84%EF%BC%88Annex-B_%E6%A0%BC%E5%BC%8F%EF%BC%89\" title=\"\u5b8c\u6574\u7684 H.264 \u7801\u6d41\u7ed3\u6784\uff08Annex-B \u683c\u5f0f\uff09\">\u5b8c\u6574\u7684 H.264 \u7801\u6d41\u7ed3\u6784\uff08Annex-B \u683c\u5f0f\uff09<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-19\" href=\"https:\/\/www.v.ixriver.com\/?p=794\/#%E8%AE%BF%E9%97%AE%E5%8D%95%E5%85%83%EF%BC%88Access_Unit%EF%BC%89%E7%BB%93%E6%9E%84\" title=\"\u8bbf\u95ee\u5355\u5143\uff08Access Unit\uff09\u7ed3\u6784\">\u8bbf\u95ee\u5355\u5143\uff08Access Unit\uff09\u7ed3\u6784<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-20\" href=\"https:\/\/www.v.ixriver.com\/?p=794\/#%E7%A0%81%E6%B5%81%E8%A7%A3%E6%9E%90%E6%B5%81%E7%A8%8B\" title=\"\u7801\u6d41\u89e3\u6790\u6d41\u7a0b\">\u7801\u6d41\u89e3\u6790\u6d41\u7a0b<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-21\" href=\"https:\/\/www.v.ixriver.com\/?p=794\/#Annex-B_%E6%A0%BC%E5%BC%8F%E8%A7%A3%E6%9E%90\" title=\"Annex-B \u683c\u5f0f\u89e3\u6790\">Annex-B \u683c\u5f0f\u89e3\u6790<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-22\" href=\"https:\/\/www.v.ixriver.com\/?p=794\/#%E8%A7%A3%E6%9E%90%E6%AD%A5%E9%AA%A4%E8%AF%A6%E8%A7%A3\" title=\"\u89e3\u6790\u6b65\u9aa4\u8be6\u89e3\">\u89e3\u6790\u6b65\u9aa4\u8be6\u89e3<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-23\" href=\"https:\/\/www.v.ixriver.com\/?p=794\/#AVCC_%E6%A0%BC%E5%BC%8F%E8%A7%A3%E6%9E%90\" title=\"AVCC \u683c\u5f0f\u89e3\u6790\">AVCC \u683c\u5f0f\u89e3\u6790<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-24\" href=\"https:\/\/www.v.ixriver.com\/?p=794\/#%E5%85%B3%E9%94%AE%E8%A6%81%E7%82%B9\" title=\"\u5173\u952e\u8981\u70b9\">\u5173\u952e\u8981\u70b9<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-25\" href=\"https:\/\/www.v.ixriver.com\/?p=794\/#1_SPSPPS_%E7%9A%84%E9%87%8D%E8%A6%81%E6%80%A7\" title=\"1. SPS\/PPS \u7684\u91cd\u8981\u6027\">1. SPS\/PPS \u7684\u91cd\u8981\u6027<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-26\" href=\"https:\/\/www.v.ixriver.com\/?p=794\/#2_IDR_%E5%B8%A7%E7%9A%84%E4%BD%9C%E7%94%A8\" title=\"2. IDR \u5e27\u7684\u4f5c\u7528\">2. IDR \u5e27\u7684\u4f5c\u7528<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-27\" href=\"https:\/\/www.v.ixriver.com\/?p=794\/#3_NRI_%E5%80%BC%E7%9A%84%E5%90%AB%E4%B9%89\" title=\"3. NRI \u503c\u7684\u542b\u4e49\">3. NRI \u503c\u7684\u542b\u4e49<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-28\" href=\"https:\/\/www.v.ixriver.com\/?p=794\/#4_%E7%A0%81%E6%B5%81%E6%A0%BC%E5%BC%8F%E9%80%89%E6%8B%A9\" title=\"4. \u7801\u6d41\u683c\u5f0f\u9009\u62e9\">4. \u7801\u6d41\u683c\u5f0f\u9009\u62e9<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-29\" href=\"https:\/\/www.v.ixriver.com\/?p=794\/#5_%E9%94%99%E8%AF%AF%E5%A4%84%E7%90%86\" title=\"5. \u9519\u8bef\u5904\u7406\">5. \u9519\u8bef\u5904\u7406<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-30\" href=\"https:\/\/www.v.ixriver.com\/?p=794\/#%E5%AE%9E%E9%99%85%E5%BA%94%E7%94%A8\" title=\"\u5b9e\u9645\u5e94\u7528\">\u5b9e\u9645\u5e94\u7528<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-31\" href=\"https:\/\/www.v.ixriver.com\/?p=794\/#FFmpeg_%E5%A4%84%E7%90%86_H264_%E7%A0%81%E6%B5%81\" title=\"FFmpeg \u5904\u7406 H.264 \u7801\u6d41\">FFmpeg \u5904\u7406 H.264 \u7801\u6d41<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-32\" href=\"https:\/\/www.v.ixriver.com\/?p=794\/#%E4%BB%A3%E7%A0%81%E7%A4%BA%E4%BE%8B%EF%BC%9A%E8%A7%A3%E6%9E%90_H264_%E7%A0%81%E6%B5%81\" title=\"\u4ee3\u7801\u793a\u4f8b\uff1a\u89e3\u6790 H.264 \u7801\u6d41\">\u4ee3\u7801\u793a\u4f8b\uff1a\u89e3\u6790 H.264 \u7801\u6d41<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-33\" href=\"https:\/\/www.v.ixriver.com\/?p=794\/#%E7%9B%B8%E5%85%B3%E8%B5%84%E6%BA%90\" title=\"\u76f8\u5173\u8d44\u6e90\">\u76f8\u5173\u8d44\u6e90<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-34\" href=\"https:\/\/www.v.ixriver.com\/?p=794\/#%E6%A0%87%E5%87%86%E6%96%87%E6%A1%A3\" title=\"\u6807\u51c6\u6587\u6863\">\u6807\u51c6\u6587\u6863<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-35\" href=\"https:\/\/www.v.ixriver.com\/?p=794\/#%E5%8F%82%E8%80%83%E5%AE%9E%E7%8E%B0\" title=\"\u53c2\u8003\u5b9e\u73b0\">\u53c2\u8003\u5b9e\u73b0<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-36\" href=\"https:\/\/www.v.ixriver.com\/?p=794\/#%E7%9B%B8%E5%85%B3%E6%96%87%E6%A1%A3\" title=\"\u76f8\u5173\u6587\u6863\">\u76f8\u5173\u6587\u6863<\/a><\/li><\/ul><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h1><span class=\"ez-toc-section\" id=\"H264_%E7%A0%81%E6%B5%81%E7%BB%93%E6%9E%84\"><\/span>H.264 \u7801\u6d41\u7ed3\u6784<span class=\"ez-toc-section-end\"><\/span><\/h1>\n<h2><span class=\"ez-toc-section\" id=\"%E6%A6%82%E8%BF%B0\"><\/span>\u6982\u8ff0<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>H.264 \u7801\u6d41\u7531\u4e00\u7cfb\u5217 NAL\uff08Network Abstraction Layer\uff0c\u7f51\u7edc\u62bd\u8c61\u5c42\uff09\u5355\u5143\u7ec4\u6210\u3002\u6bcf\u4e2a NAL \u5355\u5143\u5305\u542b\u4e00\u4e2a\u5b8c\u6574\u7684\u7f16\u7801\u6570\u636e\u5355\u5143\uff0c\u53ef\u4ee5\u662f\u89c6\u9891\u5e27\u6570\u636e\u3001\u53c2\u6570\u96c6\u6216\u5176\u4ed6\u63a7\u5236\u4fe1\u606f\u3002\u7406\u89e3 H.264 \u7801\u6d41\u7ed3\u6784\u5bf9\u4e8e\u89c6\u9891\u7f16\u89e3\u7801\u3001\u4f20\u8f93\u548c\u5b58\u50a8\u90fd\u81f3\u5173\u91cd\u8981\u3002<\/p>\n<h2><span class=\"ez-toc-section\" id=\"NAL_%E5%8D%95%E5%85%83%E7%BB%93%E6%9E%84\"><\/span>NAL \u5355\u5143\u7ed3\u6784<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"%E5%9F%BA%E6%9C%AC%E7%BB%93%E6%9E%84\"><\/span>\u57fa\u672c\u7ed3\u6784<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>NAL \u5355\u5143\u662f H.264 \u7801\u6d41\u7684\u57fa\u672c\u7ec4\u6210\u5355\u4f4d\uff0c\u6bcf\u4e2a NAL \u5355\u5143\u7531\u4ee5\u4e0b\u90e8\u5206\u7ec4\u6210\uff1a<\/p>\n<pre><code>[Start Code] [NAL Header] [NAL Payload]\n<\/code><\/pre>\n<p><strong>1. Start Code\uff08\u8d77\u59cb\u7801\uff09<\/strong><br \/>\n&#8211; <strong>Annex-B \u683c\u5f0f<\/strong>\uff1a\u4f7f\u7528\u8d77\u59cb\u7801\u5206\u9694 NAL \u5355\u5143<br \/>\n  &#8211; 3 \u5b57\u8282\u8d77\u59cb\u7801\uff1a<code>0x00 0x00 0x01<\/code><br \/>\n  &#8211; 4 \u5b57\u8282\u8d77\u59cb\u7801\uff1a<code>0x00 0x00 0x00 0x01<\/code>\uff08\u63a8\u8350\uff0c\u907f\u514d\u4e0e\u6570\u636e\u51b2\u7a81\uff09<br \/>\n&#8211; <strong>AVCC \u683c\u5f0f<\/strong>\uff1a\u4f7f\u7528\u957f\u5ea6\u524d\u7f00\uff08Length Prefix\uff09\u4ee3\u66ff\u8d77\u59cb\u7801<br \/>\n  &#8211; 1 \u5b57\u8282\u957f\u5ea6\uff1a<code>0x00<\/code> &#8211; <code>0xFF<\/code>\uff08\u6700\u5927 255 \u5b57\u8282\uff09<br \/>\n  &#8211; 2 \u5b57\u8282\u957f\u5ea6\uff1a<code>0x0000<\/code> &#8211; <code>0xFFFF<\/code>\uff08\u6700\u5927 64KB\uff09<br \/>\n  &#8211; 4 \u5b57\u8282\u957f\u5ea6\uff1a<code>0x00000000<\/code> &#8211; <code>0xFFFFFFFF<\/code>\uff08\u6700\u5927 4GB\uff09<\/p>\n<p><strong>2. NAL Header\uff08NAL \u5934\uff09<\/strong><br \/>\n&#8211; \u56fa\u5b9a 1 \u5b57\u8282\uff0c\u5305\u542b NAL \u5355\u5143\u7c7b\u578b\u548c\u6807\u5fd7\u4f4d<br \/>\n&#8211; \u7ed3\u6784\uff1a<code>[F] [NRI] [Type]<\/code><br \/>\n  &#8211; <strong>F\uff08Forbidden bit\uff09<\/strong>\uff1a1 \u4f4d\uff0c\u901a\u5e38\u4e3a 0\uff0c\u8868\u793a\u65e0\u9519\u8bef<br \/>\n  &#8211; <strong>NRI\uff08NAL Reference IDC\uff09<\/strong>\uff1a2 \u4f4d\uff0c\u8868\u793a NAL \u5355\u5143\u7684\u91cd\u8981\u6027<br \/>\n    &#8211; <code>00<\/code>\uff1a\u975e\u53c2\u8003\u5e27\uff0c\u53ef\u4e22\u5f03<br \/>\n    &#8211; <code>01<\/code>\uff1a\u53c2\u8003\u5e27\uff0c\u4f46\u975e\u5173\u952e\u5e27<br \/>\n    &#8211; <code>10<\/code>\uff1a\u53c2\u8003\u5e27\uff0c\u91cd\u8981<br \/>\n    &#8211; <code>11<\/code>\uff1a\u5173\u952e\u5e27\uff08IDR\uff09\uff0c\u6700\u91cd\u8981<br \/>\n  &#8211; <strong>Type\uff08NAL \u5355\u5143\u7c7b\u578b\uff09<\/strong>\uff1a5 \u4f4d\uff0c\u8868\u793a NAL \u5355\u5143\u7c7b\u578b\uff080-31\uff09<\/p>\n<p><strong>3. NAL Payload\uff08NAL \u8d1f\u8f7d\uff09<\/strong><br \/>\n&#8211; \u5305\u542b\u5b9e\u9645\u7684\u7f16\u7801\u6570\u636e\uff08\u5982\u89c6\u9891\u5e27\u6570\u636e\u3001\u53c2\u6570\u96c6\u7b49\uff09<br \/>\n&#8211; \u5927\u5c0f\u53ef\u53d8\uff0c\u53d6\u51b3\u4e8e\u7f16\u7801\u5185\u5bb9\u548c\u7801\u7387<\/p>\n<h3><span class=\"ez-toc-section\" id=\"NAL_Header_%E8%A7%A3%E6%9E%90%E7%A4%BA%E4%BE%8B\"><\/span>NAL Header \u89e3\u6790\u793a\u4f8b<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<pre><code class=\"language-c\">\/\/ NAL Header \u89e3\u6790\u4f2a\u4ee3\u7801\nuint8_t nal_header = 0x67;  \/\/ \u793a\u4f8b\uff1aSPS \u7684 NAL Header\n\nuint8_t forbidden_bit = (nal_header &gt;&gt; 7) &amp; 0x01;      \/\/ \u6700\u9ad8\u4f4d\nuint8_t nri = (nal_header &gt;&gt; 5) &amp; 0x03;                 \/\/ \u4e2d\u95f42\u4f4d\nuint8_t nal_type = nal_header &amp; 0x1F;                   \/\/ \u4f4e5\u4f4d\n\n\/\/ 0x67 = 0110 0111\n\/\/ forbidden_bit = 0\n\/\/ nri = 3 (11)\n\/\/ nal_type = 7 (SPS)\n<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"NAL_%E5%8D%95%E5%85%83%E7%B1%BB%E5%9E%8B\"><\/span>NAL \u5355\u5143\u7c7b\u578b<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>H.264 \u6807\u51c6\u5b9a\u4e49\u4e86\u591a\u79cd NAL \u5355\u5143\u7c7b\u578b\uff0c\u6bcf\u79cd\u7c7b\u578b\u5bf9\u5e94\u4e0d\u540c\u7684\u6570\u636e\u5185\u5bb9\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th>NAL Type<\/th>\n<th>\u7c7b\u578b\u540d\u79f0<\/th>\n<th>\u8bf4\u660e<\/th>\n<th>NRI \u5178\u578b\u503c<\/th>\n<th>\u5e94\u7528\u573a\u666f<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><strong>0<\/strong><\/td>\n<td>\u672a\u6307\u5b9a<\/td>\n<td>\u4fdd\u7559\uff0c\u4e0d\u5e94\u4f7f\u7528<\/td>\n<td>&#8211;<\/td>\n<td>&#8211;<\/td>\n<\/tr>\n<tr>\n<td><strong>1<\/strong><\/td>\n<td>\u975eIDR\u56fe\u50cf<\/td>\n<td>\u666e\u901a\u89c6\u9891\u5e27\uff08I\/P\/B\u5e27\uff09<\/td>\n<td>01\/10\/11<\/td>\n<td>\u89c6\u9891\u6570\u636e<\/td>\n<\/tr>\n<tr>\n<td><strong>2<\/strong><\/td>\n<td>\u6570\u636e\u5206\u533aA<\/td>\n<td>\u6570\u636e\u5206\u533a\uff08\u5df2\u5e9f\u5f03\uff09<\/td>\n<td>&#8211;<\/td>\n<td>\u5df2\u5e9f\u5f03<\/td>\n<\/tr>\n<tr>\n<td><strong>3<\/strong><\/td>\n<td>\u6570\u636e\u5206\u533aB<\/td>\n<td>\u6570\u636e\u5206\u533a\uff08\u5df2\u5e9f\u5f03\uff09<\/td>\n<td>&#8211;<\/td>\n<td>\u5df2\u5e9f\u5f03<\/td>\n<\/tr>\n<tr>\n<td><strong>4<\/strong><\/td>\n<td>\u6570\u636e\u5206\u533aC<\/td>\n<td>\u6570\u636e\u5206\u533a\uff08\u5df2\u5e9f\u5f03\uff09<\/td>\n<td>&#8211;<\/td>\n<td>\u5df2\u5e9f\u5f03<\/td>\n<\/tr>\n<tr>\n<td><strong>5<\/strong><\/td>\n<td>IDR\u56fe\u50cf<\/td>\n<td>\u5173\u952e\u5e27\uff08Instantaneous Decoder Refresh\uff09<\/td>\n<td>11<\/td>\n<td>\u968f\u673a\u8bbf\u95ee\u70b9<\/td>\n<\/tr>\n<tr>\n<td><strong>6<\/strong><\/td>\n<td>SEI<\/td>\n<td>\u8865\u5145\u589e\u5f3a\u4fe1\u606f<\/td>\n<td>00<\/td>\n<td>\u5143\u6570\u636e\u3001\u65f6\u95f4\u6233<\/td>\n<\/tr>\n<tr>\n<td><strong>7<\/strong><\/td>\n<td>SPS<\/td>\n<td>\u5e8f\u5217\u53c2\u6570\u96c6<\/td>\n<td>11<\/td>\n<td>\u89e3\u7801\u914d\u7f6e<\/td>\n<\/tr>\n<tr>\n<td><strong>8<\/strong><\/td>\n<td>PPS<\/td>\n<td>\u56fe\u50cf\u53c2\u6570\u96c6<\/td>\n<td>11<\/td>\n<td>\u89e3\u7801\u914d\u7f6e<\/td>\n<\/tr>\n<tr>\n<td><strong>9<\/strong><\/td>\n<td>\u8bbf\u95ee\u5355\u5143\u5206\u9694\u7b26<\/td>\n<td>\u5e27\u8fb9\u754c\u6807\u8bb0<\/td>\n<td>00<\/td>\n<td>\u5e27\u540c\u6b65<\/td>\n<\/tr>\n<tr>\n<td><strong>10<\/strong><\/td>\n<td>\u5e8f\u5217\u7ed3\u675f<\/td>\n<td>\u5e8f\u5217\u7ed3\u675f\u6807\u8bb0<\/td>\n<td>00<\/td>\n<td>\u5e8f\u5217\u7ed3\u675f<\/td>\n<\/tr>\n<tr>\n<td><strong>11<\/strong><\/td>\n<td>\u6d41\u7ed3\u675f<\/td>\n<td>\u6d41\u7ed3\u675f\u6807\u8bb0<\/td>\n<td>00<\/td>\n<td>\u6d41\u7ed3\u675f<\/td>\n<\/tr>\n<tr>\n<td><strong>12<\/strong><\/td>\n<td>\u586b\u5145\u6570\u636e<\/td>\n<td>\u586b\u5145\u5b57\u8282<\/td>\n<td>00<\/td>\n<td>\u5bf9\u9f50\u586b\u5145<\/td>\n<\/tr>\n<tr>\n<td><strong>13-23<\/strong><\/td>\n<td>\u4fdd\u7559<\/td>\n<td>\u4fdd\u7559\u672a\u4f7f\u7528<\/td>\n<td>&#8211;<\/td>\n<td>&#8211;<\/td>\n<\/tr>\n<tr>\n<td><strong>24-31<\/strong><\/td>\n<td>\u672a\u6307\u5b9a<\/td>\n<td>\u4fdd\u7559\u672a\u4f7f\u7528<\/td>\n<td>&#8211;<\/td>\n<td>&#8211;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3><span class=\"ez-toc-section\" id=\"%E9%87%8D%E8%A6%81_NAL_%E5%8D%95%E5%85%83%E7%B1%BB%E5%9E%8B%E8%AF%A6%E8%A7%A3\"><\/span>\u91cd\u8981 NAL \u5355\u5143\u7c7b\u578b\u8be6\u89e3<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<h4><span class=\"ez-toc-section\" id=\"1_SPS%EF%BC%88Sequence_Parameter_Set%EF%BC%8C%E5%BA%8F%E5%88%97%E5%8F%82%E6%95%B0%E9%9B%86%EF%BC%89\"><\/span>1. SPS\uff08Sequence Parameter Set\uff0c\u5e8f\u5217\u53c2\u6570\u96c6\uff09<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p><strong>\u4f5c\u7528<\/strong>\uff1a\u5305\u542b\u6574\u4e2a\u89c6\u9891\u5e8f\u5217\u7684\u5168\u5c40\u53c2\u6570\uff0c\u89e3\u7801\u5668\u9700\u8981 SPS \u624d\u80fd\u6b63\u786e\u89e3\u7801\u89c6\u9891\u3002<\/p>\n<p><strong>\u5305\u542b\u4fe1\u606f<\/strong>\uff1a<br \/>\n&#8211; \u7f16\u7801 Profile \u548c Level<br \/>\n&#8211; \u56fe\u50cf\u5c3a\u5bf8\uff08\u5bbd\u5ea6\u3001\u9ad8\u5ea6\uff09<br \/>\n&#8211; \u8272\u5ea6\u683c\u5f0f\uff084:2:0\u30014:2:2\u30014:4:4\uff09<br \/>\n&#8211; \u5e27\u7387\u4fe1\u606f<br \/>\n&#8211; GOP \u7ed3\u6784\u53c2\u6570<br \/>\n&#8211; \u53c2\u8003\u5e27\u6570\u91cf<br \/>\n&#8211; \u71b5\u7f16\u7801\u65b9\u5f0f\uff08CAVLC\/CABAC\uff09<\/p>\n<p><strong>\u7279\u70b9<\/strong>\uff1a<br \/>\n&#8211; NAL Type = 7<br \/>\n&#8211; NRI = 11\uff08\u6700\u91cd\u8981\uff0c\u4e0d\u53ef\u4e22\u5f03\uff09<br \/>\n&#8211; \u901a\u5e38\u51fa\u73b0\u5728\u7801\u6d41\u5f00\u5934\uff0cIDR \u5e27\u4e4b\u524d<br \/>\n&#8211; \u5e8f\u5217\u53c2\u6570\u53d8\u5316\u65f6\u9700\u8981\u53d1\u9001\u65b0\u7684 SPS<\/p>\n<p><strong>\u793a\u4f8b<\/strong>\uff1a<\/p>\n<pre><code>Start Code: 00 00 00 01\nNAL Header: 67 (0110 0111)\n  - F = 0\n  - NRI = 11 (\u6700\u91cd\u8981)\n  - Type = 7 (SPS)\nPayload: [SPS \u6570\u636e...]\n<\/code><\/pre>\n<h4><span class=\"ez-toc-section\" id=\"2_PPS%EF%BC%88Picture_Parameter_Set%EF%BC%8C%E5%9B%BE%E5%83%8F%E5%8F%82%E6%95%B0%E9%9B%86%EF%BC%89\"><\/span>2. PPS\uff08Picture Parameter Set\uff0c\u56fe\u50cf\u53c2\u6570\u96c6\uff09<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p><strong>\u4f5c\u7528<\/strong>\uff1a\u5305\u542b\u56fe\u50cf\u7ea7\u522b\u7684\u89e3\u7801\u53c2\u6570\uff0c\u901a\u5e38\u4e0e SPS \u914d\u5408\u4f7f\u7528\u3002<\/p>\n<p><strong>\u5305\u542b\u4fe1\u606f<\/strong>\uff1a<br \/>\n&#8211; \u71b5\u7f16\u7801\u65b9\u5f0f\uff08CAVLC\/CABAC\uff09<br \/>\n&#8211; \u91cf\u5316\u53c2\u6570<br \/>\n&#8211; \u53bb\u5757\u6548\u5e94\u6ee4\u6ce2\u5668\u53c2\u6570<br \/>\n&#8211; \u53c2\u8003\u5e27\u5217\u8868\u53c2\u6570<br \/>\n&#8211; \u52a0\u6743\u9884\u6d4b\u53c2\u6570<\/p>\n<p><strong>\u7279\u70b9<\/strong>\uff1a<br \/>\n&#8211; NAL Type = 8<br \/>\n&#8211; NRI = 11\uff08\u6700\u91cd\u8981\uff0c\u4e0d\u53ef\u4e22\u5f03\uff09<br \/>\n&#8211; \u901a\u5e38\u51fa\u73b0\u5728\u7801\u6d41\u5f00\u5934\uff0cIDR \u5e27\u4e4b\u524d<br \/>\n&#8211; \u4e00\u4e2a SPS \u53ef\u4ee5\u5bf9\u5e94\u591a\u4e2a PPS<\/p>\n<p><strong>\u793a\u4f8b<\/strong>\uff1a<\/p>\n<pre><code>Start Code: 00 00 00 01\nNAL Header: 68 (0110 1000)\n  - F = 0\n  - NRI = 11 (\u6700\u91cd\u8981)\n  - Type = 8 (PPS)\nPayload: [PPS \u6570\u636e...]\n<\/code><\/pre>\n<h4><span class=\"ez-toc-section\" id=\"3_IDR_%E5%B8%A7%EF%BC%88Instantaneous_Decoder_Refresh%EF%BC%89\"><\/span>3. IDR \u5e27\uff08Instantaneous Decoder Refresh\uff09<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p><strong>\u4f5c\u7528<\/strong>\uff1a\u5173\u952e\u5e27\uff0c\u89e3\u7801\u5668\u53ef\u4ee5\u4ece IDR \u5e27\u5f00\u59cb\u72ec\u7acb\u89e3\u7801\uff0c\u4e0d\u4f9d\u8d56\u4e4b\u524d\u7684\u5e27\u3002<\/p>\n<p><strong>\u7279\u70b9<\/strong>\uff1a<br \/>\n&#8211; NAL Type = 5<br \/>\n&#8211; NRI = 11\uff08\u6700\u91cd\u8981\uff0c\u4e0d\u53ef\u4e22\u5f03\uff09<br \/>\n&#8211; \u662f\u968f\u673a\u8bbf\u95ee\u70b9\uff0c\u53ef\u4ee5\u7528\u4e8e Seek \u64cd\u4f5c<br \/>\n&#8211; IDR \u5e27\u4e4b\u524d\u901a\u5e38\u4f1a\u91cd\u590d\u53d1\u9001 SPS\/PPS\uff08\u786e\u4fdd\u89e3\u7801\u5668\u80fd\u6b63\u786e\u89e3\u7801\uff09<br \/>\n&#8211; \u6240\u6709\u53c2\u8003\u5e27\u7f13\u51b2\u533a\u5728 IDR \u5e27\u540e\u6e05\u7a7a<\/p>\n<p><strong>\u793a\u4f8b<\/strong>\uff1a<\/p>\n<pre><code>Start Code: 00 00 00 01\nNAL Header: 65 (0110 0101)\n  - F = 0\n  - NRI = 11 (\u6700\u91cd\u8981)\n  - Type = 5 (IDR)\nPayload: [IDR \u5e27\u6570\u636e...]\n<\/code><\/pre>\n<h4><span class=\"ez-toc-section\" id=\"4_%E9%9D%9EIDR%E5%9B%BE%E5%83%8F%EF%BC%88%E6%99%AE%E9%80%9A%E8%A7%86%E9%A2%91%E5%B8%A7%EF%BC%89\"><\/span>4. \u975eIDR\u56fe\u50cf\uff08\u666e\u901a\u89c6\u9891\u5e27\uff09<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p><strong>\u4f5c\u7528<\/strong>\uff1a\u5305\u542b\u5b9e\u9645\u7684\u89c6\u9891\u5e27\u6570\u636e\uff08I\u5e27\u3001P\u5e27\u3001B\u5e27\uff09\u3002<\/p>\n<p><strong>\u7279\u70b9<\/strong>\uff1a<br \/>\n&#8211; NAL Type = 1<br \/>\n&#8211; NRI \u503c\u53d6\u51b3\u4e8e\u5e27\u7c7b\u578b\uff1a<br \/>\n  &#8211; I\u5e27\uff1aNRI = 10 \u6216 11<br \/>\n  &#8211; P\u5e27\uff1aNRI = 01 \u6216 10<br \/>\n  &#8211; B\u5e27\uff1aNRI = 00 \u6216 01<br \/>\n&#8211; \u5305\u542b Slice \u6570\u636e\uff08\u4e00\u4e2a\u6216\u591a\u4e2a Slice\uff09<\/p>\n<p><strong>\u793a\u4f8b<\/strong>\uff1a<\/p>\n<pre><code>Start Code: 00 00 00 01\nNAL Header: 41 (0100 0001)  \/\/ P\u5e27\u793a\u4f8b\n  - F = 0\n  - NRI = 01 (\u53c2\u8003\u5e27)\n  - Type = 1 (\u975eIDR\u56fe\u50cf)\nPayload: [Slice \u6570\u636e...]\n<\/code><\/pre>\n<h4><span class=\"ez-toc-section\" id=\"5_SEI%EF%BC%88Supplemental_Enhancement_Information%EF%BC%8C%E8%A1%A5%E5%85%85%E5%A2%9E%E5%BC%BA%E4%BF%A1%E6%81%AF%EF%BC%89\"><\/span>5. SEI\uff08Supplemental Enhancement Information\uff0c\u8865\u5145\u589e\u5f3a\u4fe1\u606f\uff09<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p><strong>\u4f5c\u7528<\/strong>\uff1a\u5305\u542b\u989d\u5916\u7684\u5143\u6570\u636e\u4fe1\u606f\uff0c\u4e0d\u5f71\u54cd\u89e3\u7801\uff0c\u4f46\u53ef\u7528\u4e8e\u64ad\u653e\u4f18\u5316\u3002<\/p>\n<p><strong>\u5e38\u89c1 SEI \u7c7b\u578b<\/strong>\uff1a<br \/>\n&#8211; <strong>\u7528\u6237\u6570\u636e SEI<\/strong>\uff1a\u81ea\u5b9a\u4e49\u6570\u636e\uff08\u5982\u65f6\u95f4\u6233\u3001\u7248\u6743\u4fe1\u606f\uff09<br \/>\n&#8211; <strong>\u7f13\u51b2\u5468\u671f SEI<\/strong>\uff1aHRD\uff08Hypothetical Reference Decoder\uff09\u53c2\u6570<br \/>\n&#8211; <strong>\u56fe\u50cf\u65f6\u5e8f SEI<\/strong>\uff1a\u5e27\u7387\u3001\u65f6\u95f4\u6233\u4fe1\u606f<br \/>\n&#8211; <strong>\u6062\u590d\u70b9 SEI<\/strong>\uff1a\u968f\u673a\u8bbf\u95ee\u70b9\u4fe1\u606f<\/p>\n<p><strong>\u7279\u70b9<\/strong>\uff1a<br \/>\n&#8211; NAL Type = 6<br \/>\n&#8211; NRI = 00\uff08\u53ef\u4e22\u5f03\uff0c\u4e0d\u5f71\u54cd\u89e3\u7801\uff09<br \/>\n&#8211; \u53ef\u9009\uff0c\u89e3\u7801\u5668\u53ef\u4ee5\u5ffd\u7565<\/p>\n<h2><span class=\"ez-toc-section\" id=\"%E7%A0%81%E6%B5%81%E6%A0%BC%E5%BC%8F\"><\/span>\u7801\u6d41\u683c\u5f0f<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>H.264 \u7801\u6d41\u6709\u4e24\u79cd\u4e3b\u8981\u683c\u5f0f\uff1a<\/p>\n<h3><span class=\"ez-toc-section\" id=\"1_Annex-B_%E6%A0%BC%E5%BC%8F\"><\/span>1. Annex-B \u683c\u5f0f<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><strong>\u7279\u70b9<\/strong>\uff1a<br \/>\n&#8211; \u4f7f\u7528\u8d77\u59cb\u7801\uff08Start Code\uff09\u5206\u9694 NAL \u5355\u5143<br \/>\n&#8211; \u8d77\u59cb\u7801\uff1a<code>0x00 0x00 0x01<\/code> \u6216 <code>0x00 0x00 0x00 0x01<\/code><br \/>\n&#8211; \u6587\u4ef6\u683c\u5f0f\uff1a<code>.264<\/code>\u3001<code>.h264<\/code><br \/>\n&#8211; \u4f20\u8f93\u683c\u5f0f\uff1aRTP\u3001TS \u6d41<\/p>\n<p><strong>\u4f18\u70b9<\/strong>\uff1a<br \/>\n&#8211; \u7ed3\u6784\u7b80\u5355\uff0c\u6613\u4e8e\u89e3\u6790<br \/>\n&#8211; \u652f\u6301\u6d41\u5f0f\u4f20\u8f93<br \/>\n&#8211; \u5e7f\u6cdb\u7528\u4e8e\u5b9e\u65f6\u4f20\u8f93<\/p>\n<p><strong>\u7f3a\u70b9<\/strong>\uff1a<br \/>\n&#8211; \u9700\u8981\u626b\u63cf\u8d77\u59cb\u7801\uff0c\u89e3\u6790\u76f8\u5bf9\u590d\u6742<br \/>\n&#8211; \u8d77\u59cb\u7801\u53ef\u80fd\u4e0e\u6570\u636e\u51b2\u7a81\uff08\u867d\u7136\u6982\u7387\u5f88\u4f4e\uff09<\/p>\n<p><strong>\u793a\u4f8b\u7801\u6d41<\/strong>\uff1a<\/p>\n<pre><code>00 00 00 01 67 64 00 1E AC ...  \/\/ SPS\n00 00 00 01 68 E9 78 2C 8B ...  \/\/ PPS\n00 00 00 01 65 88 84 00 10 ...  \/\/ IDR \u5e27\n00 00 00 01 41 9A 26 01 10 ...  \/\/ P \u5e27\n00 00 00 01 01 9A 26 01 10 ...  \/\/ B \u5e27\n<\/code><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"2_AVCC_%E6%A0%BC%E5%BC%8F%EF%BC%88MP4_%E6%A0%BC%E5%BC%8F%EF%BC%89\"><\/span>2. AVCC \u683c\u5f0f\uff08MP4 \u683c\u5f0f\uff09<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><strong>\u7279\u70b9<\/strong>\uff1a<br \/>\n&#8211; \u4f7f\u7528\u957f\u5ea6\u524d\u7f00\uff08Length Prefix\uff09\u4ee3\u66ff\u8d77\u59cb\u7801<br \/>\n&#8211; \u957f\u5ea6\u524d\u7f00\uff1a1\/2\/4 \u5b57\u8282\uff08\u5728\u5bb9\u5668\u4e2d\u914d\u7f6e\uff09<br \/>\n&#8211; \u6587\u4ef6\u683c\u5f0f\uff1a<code>.mp4<\/code>\u3001<code>.mov<\/code>\u3001<code>.mkv<\/code><br \/>\n&#8211; SPS\/PPS \u5b58\u50a8\u5728\u5bb9\u5668\u5143\u6570\u636e\u4e2d\uff08<code>avcC<\/code> box\uff09<\/p>\n<p><strong>\u4f18\u70b9<\/strong>\uff1a<br \/>\n&#8211; \u89e3\u6790\u901f\u5ea6\u5feb\uff08\u76f4\u63a5\u8bfb\u53d6\u957f\u5ea6\uff0c\u65e0\u9700\u626b\u63cf\uff09<br \/>\n&#8211; \u9002\u5408\u968f\u673a\u8bbf\u95ee\uff08\u53ef\u4ee5\u5feb\u901f\u5b9a\u4f4d\u5e27\uff09<br \/>\n&#8211; \u5bb9\u5668\u683c\u5f0f\u652f\u6301\u5b8c\u5584<\/p>\n<p><strong>\u7f3a\u70b9<\/strong>\uff1a<br \/>\n&#8211; \u9700\u8981\u5bb9\u5668\u683c\u5f0f\u652f\u6301<br \/>\n&#8211; \u4e0d\u9002\u5408\u7eaf\u6d41\u5f0f\u4f20\u8f93<\/p>\n<p><strong>\u793a\u4f8b\u7801\u6d41<\/strong>\uff084\u5b57\u8282\u957f\u5ea6\u524d\u7f00\uff09\uff1a<\/p>\n<pre><code>00 00 00 23 67 64 00 1E AC ...  \/\/ SPS (\u957f\u5ea6 0x23 = 35 \u5b57\u8282)\n00 00 00 05 68 E9 78 2C 8B ...  \/\/ PPS (\u957f\u5ea6 0x05 = 5 \u5b57\u8282)\n00 00 01 23 65 88 84 00 10 ...  \/\/ IDR \u5e27 (\u957f\u5ea6 0x123 = 291 \u5b57\u8282)\n00 00 00 45 41 9A 26 01 10 ...  \/\/ P \u5e27 (\u957f\u5ea6 0x45 = 69 \u5b57\u8282)\n<\/code><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"%E6%A0%BC%E5%BC%8F%E8%BD%AC%E6%8D%A2\"><\/span>\u683c\u5f0f\u8f6c\u6362<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><strong>Annex-B \u2192 AVCC<\/strong>\uff1a<br \/>\n1. \u79fb\u9664\u8d77\u59cb\u7801<br \/>\n2. \u6dfb\u52a0\u957f\u5ea6\u524d\u7f00<br \/>\n3. \u5c06 SPS\/PPS \u63d0\u53d6\u5230\u5bb9\u5668\u5143\u6570\u636e<\/p>\n<p><strong>AVCC \u2192 Annex-B<\/strong>\uff1a<br \/>\n1. \u79fb\u9664\u957f\u5ea6\u524d\u7f00<br \/>\n2. \u6dfb\u52a0\u8d77\u59cb\u7801<br \/>\n3. \u5c06 SPS\/PPS \u63d2\u5165\u5230 IDR \u5e27\u4e4b\u524d<\/p>\n<h2><span class=\"ez-toc-section\" id=\"%E7%A0%81%E6%B5%81%E7%BB%93%E6%9E%84%E7%A4%BA%E4%BE%8B\"><\/span>\u7801\u6d41\u7ed3\u6784\u793a\u4f8b<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"%E5%AE%8C%E6%95%B4%E7%9A%84_H264_%E7%A0%81%E6%B5%81%E7%BB%93%E6%9E%84%EF%BC%88Annex-B_%E6%A0%BC%E5%BC%8F%EF%BC%89\"><\/span>\u5b8c\u6574\u7684 H.264 \u7801\u6d41\u7ed3\u6784\uff08Annex-B \u683c\u5f0f\uff09<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<pre><code>\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502  Start Code: 00 00 00 01               \u2502\n\u2502  NAL Header: 67 (SPS)                   \u2502\n\u2502  SPS Payload: [\u5e8f\u5217\u53c2\u6570...]              \u2502\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502  Start Code: 00 00 00 01               \u2502\n\u2502  NAL Header: 68 (PPS)                   \u2502\n\u2502  PPS Payload: [\u56fe\u50cf\u53c2\u6570...]              \u2502\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502  Start Code: 00 00 00 01               \u2502\n\u2502  NAL Header: 06 (SEI, \u53ef\u9009)             \u2502\n\u2502  SEI Payload: [\u8865\u5145\u4fe1\u606f...]              \u2502\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502  Start Code: 00 00 00 01               \u2502\n\u2502  NAL Header: 65 (IDR \u5e27)                \u2502\n\u2502  IDR Payload: [\u5173\u952e\u5e27\u6570\u636e...]            \u2502\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502  Start Code: 00 00 00 01               \u2502\n\u2502  NAL Header: 41 (P \u5e27)                  \u2502\n\u2502  P Payload: [P\u5e27\u6570\u636e...]                \u2502\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502  Start Code: 00 00 00 01               \u2502\n\u2502  NAL Header: 01 (B \u5e27)                  \u2502\n\u2502  B Payload: [B\u5e27\u6570\u636e...]                \u2502\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n... (\u66f4\u591a\u5e27)\n<\/code><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"%E8%AE%BF%E9%97%AE%E5%8D%95%E5%85%83%EF%BC%88Access_Unit%EF%BC%89%E7%BB%93%E6%9E%84\"><\/span>\u8bbf\u95ee\u5355\u5143\uff08Access Unit\uff09\u7ed3\u6784<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u4e00\u4e2a\u8bbf\u95ee\u5355\u5143\uff08Access Unit\uff09\u5bf9\u5e94\u4e00\u4e2a\u5b8c\u6574\u7684\u89c6\u9891\u5e27\uff0c\u53ef\u80fd\u5305\u542b\u591a\u4e2a NAL \u5355\u5143\uff1a<\/p>\n<pre><code>\u8bbf\u95ee\u5355\u5143\uff08\u4e00\u5e27\uff09:\n\u251c\u2500 SPS (\u53ef\u9009\uff0c\u901a\u5e38\u53ea\u5728\u5e8f\u5217\u5f00\u59cb\u6216\u53c2\u6570\u53d8\u5316\u65f6)\n\u251c\u2500 PPS (\u53ef\u9009\uff0c\u901a\u5e38\u53ea\u5728\u5e8f\u5217\u5f00\u59cb\u6216\u53c2\u6570\u53d8\u5316\u65f6)\n\u251c\u2500 SEI (\u53ef\u9009)\n\u251c\u2500 IDR\/I\/P\/B \u5e27 (\u5fc5\u9700\uff0c\u4e00\u4e2a\u6216\u591a\u4e2a Slice)\n\u2514\u2500 \u8bbf\u95ee\u5355\u5143\u5206\u9694\u7b26 (\u53ef\u9009\uff0cNAL Type 9)\n<\/code><\/pre>\n<p><strong>\u6ce8\u610f<\/strong>\uff1a<br \/>\n&#8211; IDR \u5e27\u524d\u901a\u5e38\u4f1a\u91cd\u590d\u53d1\u9001 SPS\/PPS\uff08\u786e\u4fdd\u89e3\u7801\u5668\u80fd\u6b63\u786e\u89e3\u7801\uff09<br \/>\n&#8211; \u4e00\u4e2a\u5e27\u53ef\u80fd\u5305\u542b\u591a\u4e2a Slice\uff08\u5206\u7247\u7f16\u7801\uff09\uff0c\u6bcf\u4e2a Slice \u662f\u4e00\u4e2a\u72ec\u7acb\u7684 NAL \u5355\u5143<br \/>\n&#8211; \u8bbf\u95ee\u5355\u5143\u5206\u9694\u7b26\u7528\u4e8e\u660e\u786e\u6807\u8bb0\u5e27\u8fb9\u754c<\/p>\n<h2><span class=\"ez-toc-section\" id=\"%E7%A0%81%E6%B5%81%E8%A7%A3%E6%9E%90%E6%B5%81%E7%A8%8B\"><\/span>\u7801\u6d41\u89e3\u6790\u6d41\u7a0b<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"Annex-B_%E6%A0%BC%E5%BC%8F%E8%A7%A3%E6%9E%90\"><\/span>Annex-B \u683c\u5f0f\u89e3\u6790<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<pre><code class=\"language-mermaid\">flowchart TD\n    A[\u5f00\u59cb\u89e3\u6790] --&gt; B[\u67e5\u627e\u8d77\u59cb\u7801]\n    B --&gt; C{\u627e\u5230\u8d77\u59cb\u7801?}\n    C --&gt;|\u5426| D[\u7ee7\u7eed\u626b\u63cf]\n    D --&gt; B\n    C --&gt;|\u662f| E[\u8bfb\u53d6 NAL Header]\n    E --&gt; F[\u89e3\u6790 NAL Type]\n    F --&gt; G{\u7c7b\u578b\u5224\u65ad}\n    G --&gt;|SPS| H[\u4fdd\u5b58 SPS]\n    G --&gt;|PPS| I[\u4fdd\u5b58 PPS]\n    G --&gt;|IDR\/I\/P\/B| J[\u89e3\u7801\u89c6\u9891\u5e27]\n    G --&gt;|SEI| K[\u5904\u7406\u5143\u6570\u636e]\n    G --&gt;|\u5176\u4ed6| L[\u8df3\u8fc7\u6216\u5904\u7406]\n    H --&gt; M[\u7ee7\u7eed\u89e3\u6790\u4e0b\u4e00\u4e2a NAL]\n    I --&gt; M\n    J --&gt; M\n    K --&gt; M\n    L --&gt; M\n    M --&gt; B\n<\/code><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"%E8%A7%A3%E6%9E%90%E6%AD%A5%E9%AA%A4%E8%AF%A6%E8%A7%A3\"><\/span>\u89e3\u6790\u6b65\u9aa4\u8be6\u89e3<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><strong>1. \u67e5\u627e\u8d77\u59cb\u7801<\/strong><\/p>\n<pre><code class=\"language-c\">\/\/ \u67e5\u627e\u8d77\u59cb\u7801\u4f2a\u4ee3\u7801\nuint8_t* find_start_code(uint8_t* data, size_t size) {\n    for (size_t i = 0; i &lt; size - 3; i++) {\n        \/\/ \u67e5\u627e 3 \u5b57\u8282\u8d77\u59cb\u7801\n        if (data[i] == 0x00 &amp;&amp; data[i+1] == 0x00 &amp;&amp; data[i+2] == 0x01) {\n            return data + i;\n        }\n        \/\/ \u67e5\u627e 4 \u5b57\u8282\u8d77\u59cb\u7801\n        if (i &lt; size - 4 &amp;&amp; \n            data[i] == 0x00 &amp;&amp; data[i+1] == 0x00 &amp;&amp; \n            data[i+2] == 0x00 &amp;&amp; data[i+3] == 0x01) {\n            return data + i;\n        }\n    }\n    return NULL;\n}\n<\/code><\/pre>\n<p><strong>2. \u89e3\u6790 NAL Header<\/strong><\/p>\n<pre><code class=\"language-c\">\/\/ \u89e3\u6790 NAL Header\ntypedef struct {\n    uint8_t forbidden_bit;  \/\/ 1 bit\n    uint8_t nri;            \/\/ 2 bits\n    uint8_t type;           \/\/ 5 bits\n} NALHeader;\n\nNALHeader parse_nal_header(uint8_t header_byte) {\n    NALHeader nal;\n    nal.forbidden_bit = (header_byte &gt;&gt; 7) &amp; 0x01;\n    nal.nri = (header_byte &gt;&gt; 5) &amp; 0x03;\n    nal.type = header_byte &amp; 0x1F;\n    return nal;\n}\n<\/code><\/pre>\n<p><strong>3. \u5904\u7406\u4e0d\u540c\u7c7b\u578b\u7684 NAL \u5355\u5143<\/strong><br \/>\n&#8211; <strong>SPS\/PPS<\/strong>\uff1a\u4fdd\u5b58\u5230\u89e3\u7801\u5668\u914d\u7f6e\u4e2d<br \/>\n&#8211; <strong>IDR \u5e27<\/strong>\uff1a\u6e05\u7a7a\u53c2\u8003\u5e27\u7f13\u51b2\u533a\uff0c\u5f00\u59cb\u65b0\u5e8f\u5217<br \/>\n&#8211; <strong>\u666e\u901a\u5e27<\/strong>\uff1a\u6839\u636e\u5e27\u7c7b\u578b\u8fdb\u884c\u89e3\u7801<br \/>\n&#8211; <strong>SEI<\/strong>\uff1a\u63d0\u53d6\u5143\u6570\u636e\u4fe1\u606f\uff08\u53ef\u9009\uff09<\/p>\n<h3><span class=\"ez-toc-section\" id=\"AVCC_%E6%A0%BC%E5%BC%8F%E8%A7%A3%E6%9E%90\"><\/span>AVCC \u683c\u5f0f\u89e3\u6790<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<pre><code class=\"language-mermaid\">flowchart TD\n    A[\u5f00\u59cb\u89e3\u6790] --&gt; B[\u8bfb\u53d6\u957f\u5ea6\u524d\u7f00]\n    B --&gt; C[\u6839\u636e\u957f\u5ea6\u8bfb\u53d6 NAL \u5355\u5143]\n    C --&gt; D[\u89e3\u6790 NAL Header]\n    D --&gt; E[\u5904\u7406 NAL \u5355\u5143]\n    E --&gt; F{\u8fd8\u6709\u6570\u636e?}\n    F --&gt;|\u662f| B\n    F --&gt;|\u5426| G[\u89e3\u6790\u5b8c\u6210]\n<\/code><\/pre>\n<p><strong>\u89e3\u6790\u6b65\u9aa4<\/strong>\uff1a<br \/>\n1. \u8bfb\u53d6\u957f\u5ea6\u524d\u7f00\uff081\/2\/4 \u5b57\u8282\uff0c\u7531\u5bb9\u5668\u914d\u7f6e\u51b3\u5b9a\uff09<br \/>\n2. \u6839\u636e\u957f\u5ea6\u8bfb\u53d6\u5b8c\u6574\u7684 NAL \u5355\u5143<br \/>\n3. \u89e3\u6790 NAL Header \u548c\u5904\u7406\u6570\u636e<br \/>\n4. \u91cd\u590d\u76f4\u5230\u6570\u636e\u7ed3\u675f<\/p>\n<h2><span class=\"ez-toc-section\" id=\"%E5%85%B3%E9%94%AE%E8%A6%81%E7%82%B9\"><\/span>\u5173\u952e\u8981\u70b9<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"1_SPSPPS_%E7%9A%84%E9%87%8D%E8%A6%81%E6%80%A7\"><\/span>1. SPS\/PPS \u7684\u91cd\u8981\u6027<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li><strong>\u5fc5\u987b\u4fdd\u5b58<\/strong>\uff1a\u89e3\u7801\u5668\u5fc5\u987b\u4fdd\u5b58 SPS\/PPS \u624d\u80fd\u6b63\u786e\u89e3\u7801<\/li>\n<li><strong>\u53ca\u65f6\u66f4\u65b0<\/strong>\uff1a\u5f53\u5e8f\u5217\u53c2\u6570\u53d8\u5316\u65f6\uff0c\u9700\u8981\u53d1\u9001\u65b0\u7684 SPS\/PPS<\/li>\n<li><strong>IDR \u524d\u53d1\u9001<\/strong>\uff1aIDR \u5e27\u524d\u901a\u5e38\u4f1a\u91cd\u590d\u53d1\u9001 SPS\/PPS\uff0c\u786e\u4fdd\u89e3\u7801\u5668\u80fd\u6b63\u786e\u89e3\u7801<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"2_IDR_%E5%B8%A7%E7%9A%84%E4%BD%9C%E7%94%A8\"><\/span>2. IDR \u5e27\u7684\u4f5c\u7528<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li><strong>\u968f\u673a\u8bbf\u95ee\u70b9<\/strong>\uff1a\u53ef\u4ee5\u4ece IDR \u5e27\u5f00\u59cb\u72ec\u7acb\u89e3\u7801<\/li>\n<li><strong>\u6e05\u7a7a\u7f13\u51b2\u533a<\/strong>\uff1aIDR \u5e27\u540e\u6240\u6709\u53c2\u8003\u5e27\u7f13\u51b2\u533a\u6e05\u7a7a<\/li>\n<li><strong>Seek \u652f\u6301<\/strong>\uff1a\u89c6\u9891\u64ad\u653e\u5668\u7684 Seek \u64cd\u4f5c\u901a\u5e38\u5b9a\u4f4d\u5230 IDR \u5e27<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"3_NRI_%E5%80%BC%E7%9A%84%E5%90%AB%E4%B9%89\"><\/span>3. NRI \u503c\u7684\u542b\u4e49<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li><strong>NRI = 11<\/strong>\uff1a\u5173\u952e\u5e27\uff08IDR\uff09\u6216\u53c2\u6570\u96c6\uff08SPS\/PPS\uff09\uff0c\u4e0d\u53ef\u4e22\u5f03<\/li>\n<li><strong>NRI = 10<\/strong>\uff1a\u91cd\u8981\u53c2\u8003\u5e27\uff08I\u5e27\u3001\u91cd\u8981P\u5e27\uff09\uff0c\u4e0d\u5e94\u4e22\u5f03<\/li>\n<li><strong>NRI = 01<\/strong>\uff1a\u53c2\u8003\u5e27\uff08P\u5e27\uff09\uff0c\u53ef\u4ee5\u4e22\u5f03\u4f46\u4f1a\u5f71\u54cd\u540e\u7eed\u5e27<\/li>\n<li><strong>NRI = 00<\/strong>\uff1a\u975e\u53c2\u8003\u5e27\uff08B\u5e27\uff09\u6216\u53ef\u4e22\u5f03\u6570\u636e\uff08SEI\uff09\uff0c\u53ef\u4ee5\u5b89\u5168\u4e22\u5f03<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"4_%E7%A0%81%E6%B5%81%E6%A0%BC%E5%BC%8F%E9%80%89%E6%8B%A9\"><\/span>4. \u7801\u6d41\u683c\u5f0f\u9009\u62e9<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li><strong>\u5b9e\u65f6\u4f20\u8f93<\/strong>\uff08RTP\u3001RTMP\u3001WebRTC\uff09\uff1a\u4f7f\u7528 Annex-B \u683c\u5f0f<\/li>\n<li><strong>\u6587\u4ef6\u5b58\u50a8<\/strong>\uff08MP4\u3001MOV\u3001MKV\uff09\uff1a\u4f7f\u7528 AVCC \u683c\u5f0f<\/li>\n<li><strong>\u6d41\u5a92\u4f53<\/strong>\uff08HLS\u3001DASH\uff09\uff1a\u6839\u636e\u5bb9\u5668\u683c\u5f0f\u9009\u62e9<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"5_%E9%94%99%E8%AF%AF%E5%A4%84%E7%90%86\"><\/span>5. \u9519\u8bef\u5904\u7406<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li><strong>\u8d77\u59cb\u7801\u51b2\u7a81<\/strong>\uff1a\u867d\u7136\u6982\u7387\u5f88\u4f4e\uff0c\u4f46\u9700\u8981\u5904\u7406\uff08\u4f7f\u7528 4 \u5b57\u8282\u8d77\u59cb\u7801\u53ef\u964d\u4f4e\u6982\u7387\uff09<\/li>\n<li><strong>NAL \u5355\u5143\u635f\u574f<\/strong>\uff1a\u6839\u636e NRI \u503c\u51b3\u5b9a\u662f\u5426\u4e22\u5f03<\/li>\n<li><strong>\u53c2\u6570\u96c6\u4e22\u5931<\/strong>\uff1a\u65e0\u6cd5\u89e3\u7801\uff0c\u9700\u8981\u91cd\u65b0\u83b7\u53d6\u6216\u4f7f\u7528\u9ed8\u8ba4\u53c2\u6570<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"%E5%AE%9E%E9%99%85%E5%BA%94%E7%94%A8\"><\/span>\u5b9e\u9645\u5e94\u7528<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"FFmpeg_%E5%A4%84%E7%90%86_H264_%E7%A0%81%E6%B5%81\"><\/span>FFmpeg \u5904\u7406 H.264 \u7801\u6d41<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><strong>\u63d0\u53d6 SPS\/PPS<\/strong>\uff1a<\/p>\n<pre><code class=\"language-bash\"># \u4ece MP4 \u6587\u4ef6\u63d0\u53d6 SPS\/PPS\nffmpeg -i input.mp4 -vcodec copy -bsf:v h264_mp4toannexb -f h264 output.264\n\n# \u67e5\u770b NAL \u5355\u5143\u4fe1\u606f\nffprobe -v error -show_entries packet=pts_time,dts_time,flags -select_streams v:0 input.mp4\n<\/code><\/pre>\n<p><strong>\u8f6c\u6362\u683c\u5f0f<\/strong>\uff1a<\/p>\n<pre><code class=\"language-bash\"># Annex-B \u8f6c AVCC\uff08MP4\uff09\nffmpeg -i input.264 -c:v copy output.mp4\n\n# AVCC \u8f6c Annex-B\nffmpeg -i input.mp4 -vcodec copy -bsf:v h264_mp4toannexb output.264\n<\/code><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"%E4%BB%A3%E7%A0%81%E7%A4%BA%E4%BE%8B%EF%BC%9A%E8%A7%A3%E6%9E%90_H264_%E7%A0%81%E6%B5%81\"><\/span>\u4ee3\u7801\u793a\u4f8b\uff1a\u89e3\u6790 H.264 \u7801\u6d41<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<pre><code class=\"language-c\">\/\/ \u7b80\u5316\u7684 H.264 \u7801\u6d41\u89e3\u6790\u793a\u4f8b\ntypedef struct {\n    uint8_t* data;\n    size_t size;\n    size_t pos;\n} H264Stream;\n\nint parse_h264_stream(H264Stream* stream) {\n    uint8_t* start_code = NULL;\n\n    while ((start_code = find_start_code(stream-&gt;data + stream-&gt;pos, \n                                         stream-&gt;size - stream-&gt;pos)) != NULL) {\n        \/\/ \u8df3\u8fc7\u8d77\u59cb\u7801\n        stream-&gt;pos = (start_code - stream-&gt;data) + 4;\n\n        \/\/ \u67e5\u627e\u4e0b\u4e00\u4e2a\u8d77\u59cb\u7801\u6216\u6570\u636e\u7ed3\u675f\n        uint8_t* next_start = find_start_code(stream-&gt;data + stream-&gt;pos, \n                                              stream-&gt;size - stream-&gt;pos);\n        size_t nal_size = (next_start ? (next_start - stream-&gt;data) : stream-&gt;size) - stream-&gt;pos;\n\n        \/\/ \u8bfb\u53d6 NAL Header\n        if (nal_size &lt; 1) break;\n        uint8_t nal_header = stream-&gt;data[stream-&gt;pos];\n        NALHeader nal = parse_nal_header(nal_header);\n\n        \/\/ \u5904\u7406\u4e0d\u540c\u7c7b\u578b\u7684 NAL \u5355\u5143\n        switch (nal.type) {\n            case 7:  \/\/ SPS\n                handle_sps(stream-&gt;data + stream-&gt;pos + 1, nal_size - 1);\n                break;\n            case 8:  \/\/ PPS\n                handle_pps(stream-&gt;data + stream-&gt;pos + 1, nal_size - 1);\n                break;\n            case 5:  \/\/ IDR\n                handle_idr(stream-&gt;data + stream-&gt;pos + 1, nal_size - 1);\n                break;\n            case 1:  \/\/ \u975eIDR\u56fe\u50cf\n                handle_frame(stream-&gt;data + stream-&gt;pos + 1, nal_size - 1, nal.nri);\n                break;\n            default:\n                \/\/ \u5176\u4ed6\u7c7b\u578b\n                break;\n        }\n\n        stream-&gt;pos += nal_size;\n    }\n\n    return 0;\n}\n<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"%E7%9B%B8%E5%85%B3%E8%B5%84%E6%BA%90\"><\/span>\u76f8\u5173\u8d44\u6e90<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"%E6%A0%87%E5%87%86%E6%96%87%E6%A1%A3\"><\/span>\u6807\u51c6\u6587\u6863<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li><strong>ITU-T H.264<\/strong>\uff1aITU-T Recommendation H.264 (Advanced Video Coding)<\/li>\n<li><strong>ISO\/IEC 14496-10<\/strong>\uff1aISO\/IEC 14496-10 (MPEG-4 Part 10, AVC)<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"%E5%8F%82%E8%80%83%E5%AE%9E%E7%8E%B0\"><\/span>\u53c2\u8003\u5b9e\u73b0<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li><strong>x264<\/strong>\uff1aH.264 \u7f16\u7801\u5668\u53c2\u8003\u5b9e\u73b0<\/li>\n<li><strong>FFmpeg<\/strong>\uff1aH.264 \u7f16\u89e3\u7801\u548c\u683c\u5f0f\u8f6c\u6362<\/li>\n<li><strong>OpenH264<\/strong>\uff1aCisco \u5f00\u6e90\u7684 H.264 \u7f16\u89e3\u7801\u5668<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"%E7%9B%B8%E5%85%B3%E6%96%87%E6%A1%A3\"><\/span>\u76f8\u5173\u6587\u6863<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li><a href=\".\/encode.md\">\u89c6\u9891\u7f16\u7801<\/a>\uff1aH.264 \u7f16\u7801\u539f\u7406\u548c\u53c2\u6570\u914d\u7f6e<\/li>\n<li><a href=\".\/decode.md\">\u89c6\u9891\u89e3\u7801<\/a>\uff1aH.264 \u89e3\u7801\u6d41\u7a0b\u548c\u4f18\u5316<\/li>\n<li><a href=\".\/video_container.md\">\u89c6\u9891\u5bb9\u5668<\/a>\uff1aH.264 \u5728\u5bb9\u5668\u683c\u5f0f\u4e2d\u7684\u5b58\u50a8<\/li>\n<\/ul>\n<hr \/>\n<p>\u6700\u540e\u66f4\u65b0\uff1a2026-01-20<\/p>\n","protected":false},"excerpt":{"rendered":"<p>H.264 \u7801\u6d41\u7ed3\u6784 \u6982\u8ff0 H.264 \u7801\u6d41\u7531\u4e00\u7cfb\u5217 NAL\uff08Network Abstraction Laye [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[28],"tags":[],"blocksy_meta":[],"featured_image_urls":{"full":"","thumbnail":"","medium":"","medium_large":"","large":"","1536x1536":"","2048x2048":""},"post_excerpt_stackable":"<p>\u76ee\u5f55 Toggle H.264 \u7801\u6d41\u7ed3\u6784\u6982\u8ff0NAL \u5355\u5143\u7ed3\u6784\u57fa\u672c\u7ed3\u6784NAL Header \u89e3\u6790\u793a\u4f8bNAL \u5355\u5143\u7c7b\u578b\u91cd\u8981 NAL \u5355\u5143\u7c7b\u578b\u8be6\u89e31. SPS\uff08Sequence Parameter Set\uff0c&hellip;<\/p>\n","category_list":"<a href=\"https:\/\/www.v.ixriver.com\/?cat=28\" rel=\"category\">\u89c6\u9891<\/a>","author_info":{"name":"admin","url":"https:\/\/www.v.ixriver.com\/?author=1"},"comments_num":"0 comments","_links":{"self":[{"href":"https:\/\/www.v.ixriver.com\/index.php?rest_route=\/wp\/v2\/posts\/794"}],"collection":[{"href":"https:\/\/www.v.ixriver.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.v.ixriver.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.v.ixriver.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.v.ixriver.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=794"}],"version-history":[{"count":0,"href":"https:\/\/www.v.ixriver.com\/index.php?rest_route=\/wp\/v2\/posts\/794\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.v.ixriver.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=794"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.v.ixriver.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=794"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.v.ixriver.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=794"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}