{"id":3355,"date":"2025-07-29T13:33:49","date_gmt":"2025-07-29T05:33:49","guid":{"rendered":"http:\/\/www.51cos.com\/?p=3355"},"modified":"2025-07-29T13:34:55","modified_gmt":"2025-07-29T05:34:55","slug":"%e5%a6%82%e4%bd%95%e7%94%a8ffprobe%e5%88%86%e6%9e%90%e8%a7%86%e9%a2%91%e6%a0%bc%e5%bc%8f%ef%bc%9a-ffprobe%e7%9a%84%e5%9f%ba%e6%9c%ac%e7%94%a8%e6%b3%95%e5%92%8c%e5%b8%b8%e8%a7%81%e5%9c%ba%e6%99%af","status":"publish","type":"post","link":"http:\/\/www.51cos.com\/?p=3355","title":{"rendered":"\u5982\u4f55\u7528ffprobe\u5206\u6790\u89c6\u9891\u683c\u5f0f\uff1a ffprobe\u7684\u57fa\u672c\u7528\u6cd5\u548c\u5e38\u89c1\u573a\u666f"},"content":{"rendered":"<p><code>ffprobe<\/code> \u662f FFmpeg \u5de5\u5177\u96c6\u4e2d\u7684\u4e00\u4e2a\u591a\u5a92\u4f53\u5206\u6790\u5de5\u5177\uff0c\u7528\u4e8e\u63d0\u53d6\u97f3\u89c6\u9891\u6587\u4ef6\u7684\u5143\u6570\u636e\u3001\u683c\u5f0f\u4fe1\u606f\u3001\u6d41\u4fe1\u606f\u7b49\u3002\u4ee5\u4e0b\u662f <code>ffprobe<\/code> \u7684\u57fa\u672c\u7528\u6cd5\u548c\u5e38\u89c1\u573a\u666f\uff1a<\/p>\n<hr \/>\n<h3><strong>1. \u663e\u793a\u6587\u4ef6\u57fa\u672c\u4fe1\u606f<\/strong><\/h3>\n<pre><code class=\"language-bash line-numbers\">ffprobe input.mp4\n<\/code><\/pre>\n<ul>\n<li>\u8f93\u51fa\u6587\u4ef6\u7684\u5bb9\u5668\u683c\u5f0f\u3001\u65f6\u957f\u3001\u7801\u7387\u3001\u6d41\u4fe1\u606f\uff08\u89c6\u9891\/\u97f3\u9891\/\u5b57\u5e55\u7b49\uff09\u7b49\u57fa\u7840\u4fe1\u606f\u3002<\/li>\n<\/ul>\n<hr \/>\n<h3><strong>2. \u4ee5 JSON \u683c\u5f0f\u8f93\u51fa\u8be6\u7ec6\u4fe1\u606f<\/strong><\/h3>\n<pre><code class=\"language-bash line-numbers\">ffprobe -v error -show_format -show_streams -print_format json input.mp4\n<\/code><\/pre>\n<ul>\n<li><code>-show_format<\/code>\uff1a\u663e\u793a\u5bb9\u5668\u683c\u5f0f\u4fe1\u606f\uff08\u5982\u65f6\u957f\u3001\u6587\u4ef6\u5927\u5c0f\u3001\u6bd4\u7279\u7387\u7b49\uff09\u3002<\/li>\n<li><code>-show_streams<\/code>\uff1a\u663e\u793a\u6240\u6709\u6d41\uff08\u89c6\u9891\u3001\u97f3\u9891\u3001\u5b57\u5e55\u7b49\uff09\u7684\u8be6\u7ec6\u4fe1\u606f\u3002<\/li>\n<li><code>-print_format json<\/code>\uff1a\u4ee5 JSON \u683c\u5f0f\u8f93\u51fa\uff0c\u4fbf\u4e8e\u7a0b\u5e8f\u89e3\u6790\u3002<\/li>\n<\/ul>\n<hr \/>\n<h3><strong>3. \u663e\u793a\u7279\u5b9a\u4fe1\u606f\u5b57\u6bb5<\/strong><\/h3>\n<pre><code class=\"language-bash line-numbers\">ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 input.mp4\n<\/code><\/pre>\n<ul>\n<li>\u8f93\u51fa\u6587\u4ef6\u7684<strong>\u603b\u65f6\u957f<\/strong>\uff08\u79d2\uff09\uff1a\n<ul>\n<li><code>-show_entries format=duration<\/code>\uff1a\u4ec5\u663e\u793a\u65f6\u957f\u5b57\u6bb5\u3002<\/li>\n<li><code>-of default=noprint_wrappers=1:nokey=1<\/code>\uff1a\u4ec5\u8f93\u51fa\u6570\u503c\uff0c\u53bb\u9664\u5197\u4f59\u4fe1\u606f\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<hr \/>\n<h3><strong>4. \u67e5\u770b\u89c6\u9891\u6d41\u4fe1\u606f<\/strong><\/h3>\n<pre><code class=\"language-bash line-numbers\">ffprobe -v error -select_streams v:0 -show_entries stream=width,height,codec_name -of csv=p=0 input.mp4\n<\/code><\/pre>\n<ul>\n<li>\u8f93\u51fa\u89c6\u9891\u7684<strong>\u5bbd\u5ea6\u3001\u9ad8\u5ea6\u3001\u7f16\u7801\u683c\u5f0f<\/strong>\uff1a\n<ul>\n<li><code>-select_streams v:0<\/code>\uff1a\u4ec5\u9009\u62e9\u7b2c\u4e00\u4e2a\u89c6\u9891\u6d41\u3002<\/li>\n<li><code>-of csv=p=0<\/code>\uff1a\u4ee5 CSV \u683c\u5f0f\u8f93\u51fa\uff0c\u4e0d\u663e\u793a\u8868\u5934\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<hr \/>\n<h3><strong>5. \u67e5\u770b\u97f3\u9891\u6d41\u4fe1\u606f<\/strong><\/h3>\n<pre><code class=\"language-bash line-numbers\">ffprobe -v error -select_streams a:0 -show_entries stream=sample_rate,channels,codec_name -of csv=p=0 input.mp4\n<\/code><\/pre>\n<ul>\n<li>\u8f93\u51fa\u97f3\u9891\u7684<strong>\u91c7\u6837\u7387\u3001\u58f0\u9053\u6570\u3001\u7f16\u7801\u683c\u5f0f<\/strong>\u3002<\/li>\n<\/ul>\n<hr \/>\n<h3><strong>6. \u663e\u793a\u5173\u952e\u5e27\u65f6\u95f4\u6233<\/strong><\/h3>\n<pre><code class=\"language-bash line-numbers\">ffprobe -v error -select_streams v:0 -show_frames -show_entries frame=pts_time,key_frame -of csv=p=0 input.mp4\n<\/code><\/pre>\n<ul>\n<li>\u8f93\u51fa\u6240\u6709\u5e27\u7684\u65f6\u95f4\u6233\u548c\u662f\u5426\u4e3a\u5173\u952e\u5e27\uff08<code>1<\/code> \u662f\u5173\u952e\u5e27\uff0c<code>0<\/code> \u4e0d\u662f\uff09\u3002<\/li>\n<\/ul>\n<h3><strong>\u547d\u4ee4\u89e3\u6790<\/strong><\/h3>\n<pre><code class=\"language-bash line-numbers\">ffprobe -v error -show_frames -select_streams v:0 test.h264 | findstr \"pict_type\"\n<\/code><\/pre>\n<h4><strong>\u4f5c\u7528<\/strong><\/h4>\n<ol>\n<li><strong><code>ffprobe<\/code> \u90e8\u5206<\/strong>\uff1a\n<ul>\n<li><code>-v error<\/code>\uff1a\u4ec5\u663e\u793a\u9519\u8bef\u4fe1\u606f\uff08\u6291\u5236\u5197\u4f59\u8f93\u51fa\uff09\u3002<\/li>\n<li><code>-show_frames<\/code>\uff1a\u8f93\u51fa\u6bcf\u4e00\u5e27\u7684\u8be6\u7ec6\u4fe1\u606f\u3002<\/li>\n<li><code>-select_streams v:0<\/code>\uff1a\u4ec5\u5206\u6790\u7b2c\u4e00\u4e2a\u89c6\u9891\u6d41\uff08<code>v:0<\/code>\uff09\u3002<\/li>\n<li><code>test.h264<\/code>\uff1a\u8f93\u5165\u7684\u89c6\u9891\u6587\u4ef6\uff08\u88f8 H.264 \u6d41\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u7ba1\u9053 <code>|<\/code> + <code>findstr<\/code> \/ <code>grep<\/code><\/strong>\uff1a\n<ul>\n<li>\u8fc7\u6ee4\u8f93\u51fa\u7ed3\u679c\uff0c\u4ec5\u4fdd\u7559\u5305\u542b <code>pict_type<\/code> \u7684\u884c\uff08\u5373\u5e27\u7c7b\u578b\u6807\u8bb0\uff09\u3002<\/li>\n<li><code>pict_type<\/code> \u7684\u53ef\u80fd\u503c\uff1a\n<ul>\n<li><code>I<\/code>\uff1a\u5173\u952e\u5e27\uff08Intra-coded frame\uff09\u3002<\/li>\n<li><code>P<\/code>\uff1a\u9884\u6d4b\u5e27\uff08Predicted frame\uff09\u3002<\/li>\n<li><code>B<\/code>\uff1a\u53cc\u5411\u9884\u6d4b\u5e27\uff08Bi-directional frame\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h4><strong>\u8f93\u51fa\u793a\u4f8b<\/strong><\/h4>\n<pre><code class=\"line-numbers\">pict_type=I\npict_type=P\npict_type=B\n...\n<\/code><\/pre>\n<hr \/>\n<h3><strong>Windows \u4e0e Linux \u5e73\u53f0\u7528\u6cd5\u5bf9\u6bd4<\/strong><\/h3>\n<h4><strong>1. Windows \u5e73\u53f0<\/strong><\/h4>\n<ul>\n<li>\u76f4\u63a5\u4f7f\u7528 <code>findstr<\/code>\uff08Windows \u539f\u751f\u547d\u4ee4\uff09\uff1a\n<pre><code class=\"language-cmd line-numbers\">ffprobe -v error -show_frames -select_streams v:0 test.h264 | findstr \"pict_type\"\n<\/code><\/pre>\n<\/li>\n<\/ul>\n<h4><strong>2. Linux\/macOS \u5e73\u53f0<\/strong><\/h4>\n<ul>\n<li>\u5c06 <code>findstr<\/code> \u66ff\u6362\u4e3a <code>grep<\/code>\uff1a\n<pre><code class=\"language-bash line-numbers\">ffprobe -v error -show_frames -select_streams v:0 test.h264 | grep \"pict_type\"\n<\/code><\/pre>\n<\/li>\n<\/ul>\n<hr \/>\n<h3><strong>\u6ce8\u610f\u4e8b\u9879<\/strong><\/h3>\n<ol>\n<li><strong>\u6587\u4ef6\u683c\u5f0f<\/strong>\uff1a\n<ul>\n<li><code>test.h264<\/code> \u662f\u88f8 H.264 \u6d41\u6587\u4ef6\uff0c\u5982\u679c\u8f93\u5165\u662f MP4\/MKV \u7b49\u5bb9\u5668\u683c\u5f0f\uff0c\u547d\u4ee4\u540c\u6837\u9002\u7528\u3002<\/li>\n<li>\u82e5\u6587\u4ef6\u662f\u5176\u4ed6\u683c\u5f0f\uff08\u5982 <code>.mp4<\/code>\uff09\uff0c\u9700\u786e\u4fdd\u89c6\u9891\u6d41\u7684\u7f16\u7801\u662f H.264\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u6027\u80fd\u95ee\u9898<\/strong>\uff1a\n<ul>\n<li><code>-show_frames<\/code> \u4f1a\u9010\u5e27\u5206\u6790\u6587\u4ef6\uff0c\u5927\u6587\u4ef6\u53ef\u80fd\u8f83\u6162\u3002<\/li>\n<li>\u5982\u679c\u53ea\u9700\u5173\u952e\u5e27\u4fe1\u606f\uff0c\u53ef\u4ee5\u7528\u66f4\u9ad8\u6548\u7684\u65b9\u5f0f\uff1a\n<pre><code class=\"language-bash line-numbers\">ffprobe -v error -show_frames -select_streams v:0 -show_entries frame=pict_type -of csv test.h264 | grep -n I\n<\/code><\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u8f93\u51fa\u683c\u5f0f\u63a7\u5236<\/strong>\uff1a\n<ul>\n<li>\u5982\u9700\u66f4\u7b80\u6d01\u7684\u8f93\u51fa\uff08\u4ec5\u5e27\u7c7b\u578b\uff09\uff0c\u53ef\u6dfb\u52a0 <code>-of csv<\/code>\uff1a\n<pre><code class=\"language-bash line-numbers\">ffprobe -v error -show_frames -select_streams v:0 -show_entries frame=pict_type -of csv test.h264\n<\/code><\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<hr \/>\n<h3><strong>\u5b9e\u9645\u5e94\u7528\u573a\u666f<\/strong><\/h3>\n<ul>\n<li><strong>\u68c0\u67e5\u5173\u952e\u5e27\u5206\u5e03<\/strong>\uff1a\u786e\u8ba4\u89c6\u9891\u4e2d\u662f\u5426\u6709\u89c4\u5f8b\u7684\u5173\u952e\u5e27\uff08\u5f71\u54cd\u89c6\u9891\u7f16\u8f91\u548c\u6d41\u5a92\u4f53\u5206\u7247\uff09\u3002<\/li>\n<li><strong>\u8c03\u8bd5\u7f16\u7801\u95ee\u9898<\/strong>\uff1a\u9a8c\u8bc1\u662f\u5426\u7f3a\u5c11\u5173\u952e\u5e27\uff08\u4f8b\u5982\u76f4\u64ad\u6d41\u4e22\u5e27\u95ee\u9898\uff09\u3002<\/li>\n<li><strong>\u81ea\u52a8\u5316\u811a\u672c<\/strong>\uff1a\u63d0\u53d6\u5e27\u7c7b\u578b\u7528\u4e8e\u540e\u7eed\u5904\u7406\uff08\u5982\u8fc7\u6ee4\u975e\u5173\u952e\u5e27\uff09\u3002<\/li>\n<\/ul>\n<hr \/>\n<h3><strong>7. \u68c0\u67e5\u6587\u4ef6\u662f\u5426\u635f\u574f<\/strong><\/h3>\n<pre><code class=\"language-bash line-numbers\">ffprobe -v error -i input.mp4\n<\/code><\/pre>\n<ul>\n<li>\u5982\u679c\u6587\u4ef6\u635f\u574f\u6216\u65e0\u6cd5\u89e3\u7801\uff0c\u4f1a\u8f93\u51fa\u9519\u8bef\u4fe1\u606f\uff1b\u65e0\u8f93\u51fa\u5219\u8868\u793a\u6587\u4ef6\u6b63\u5e38\u3002<\/li>\n<\/ul>\n<hr \/>\n<h3><strong>8. \u8f93\u51fa\u5e27\u6570\u7edf\u8ba1<\/strong><\/h3>\n<pre><code class=\"language-bash line-numbers\">ffprobe -v error -count_frames -select_streams v:0 -show_entries stream=nb_read_frames -of csv=p=0 input.mp4\n<\/code><\/pre>\n<ul>\n<li>\u7edf\u8ba1\u89c6\u9891\u6d41\u7684<strong>\u603b\u5e27\u6570<\/strong>\uff08\u6ce8\u610f\uff1a\u53ef\u80fd\u9700\u8981\u5b8c\u6574\u89e3\u7801\u6587\u4ef6\uff0c\u8017\u65f6\u8f83\u957f\uff09\u3002<\/li>\n<\/ul>\n<hr \/>\n<h3><strong>\u5e38\u7528\u53c2\u6570\u8bf4\u660e<\/strong><\/h3>\n<table>\n<thead>\n<tr>\n<th>\u53c2\u6570<\/th>\n<th>\u4f5c\u7528<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>-v error<\/code><\/td>\n<td>\u9690\u85cf\u5197\u4f59\u65e5\u5fd7\uff0c\u4ec5\u663e\u793a\u9519\u8bef<\/td>\n<\/tr>\n<tr>\n<td><code>-show_format<\/code><\/td>\n<td>\u663e\u793a\u5bb9\u5668\u683c\u5f0f\u4fe1\u606f<\/td>\n<\/tr>\n<tr>\n<td><code>-show_streams<\/code><\/td>\n<td>\u663e\u793a\u6240\u6709\u6d41\u4fe1\u606f<\/td>\n<\/tr>\n<tr>\n<td><code>-select_streams v:0<\/code><\/td>\n<td>\u9009\u62e9\u7b2c\u4e00\u4e2a\u89c6\u9891\u6d41<\/td>\n<\/tr>\n<tr>\n<td><code>-select_streams a:0<\/code><\/td>\n<td>\u9009\u62e9\u7b2c\u4e00\u4e2a\u97f3\u9891\u6d41<\/td>\n<\/tr>\n<tr>\n<td><code>-of json<\/code>\/<code>-of csv<\/code><\/td>\n<td>\u6307\u5b9a\u8f93\u51fa\u683c\u5f0f<\/td>\n<\/tr>\n<tr>\n<td><code>-print_format json<\/code><\/td>\n<td>\u540c <code>-of json<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h3><strong>\u5178\u578b\u5e94\u7528\u573a\u666f<\/strong><\/h3>\n<ol>\n<li><strong>\u811a\u672c\u5904\u7406<\/strong>\uff1a\u7528 JSON \u683c\u5f0f\u8f93\u51fa\u5e76\u89e3\u6790\u5143\u6570\u636e\u3002<\/li>\n<li><strong>\u8d28\u91cf\u63a7\u5236<\/strong>\uff1a\u68c0\u67e5\u89c6\u9891\u5206\u8fa8\u7387\u3001\u7f16\u7801\u683c\u5f0f\u662f\u5426\u7b26\u5408\u8981\u6c42\u3002<\/li>\n<li><strong>\u8c03\u8bd5<\/strong>\uff1a\u5206\u6790\u6587\u4ef6\u662f\u5426\u635f\u574f\u6216\u7f16\u7801\u53c2\u6570\u5f02\u5e38\u3002<\/li>\n<\/ol>\n<p>\u5982\u679c\u9700\u8981\u66f4\u590d\u6742\u7684\u529f\u80fd\uff08\u5982\u5206\u6790\u5e27\u5185\u5bb9\uff09\uff0c\u53ef\u4ee5\u7ed3\u5408 <code>ffmpeg<\/code> \u6216\u5176\u4ed6\u5de5\u5177\u4f7f\u7528\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>ffprobe \u662f FFmpeg \u5de5\u5177\u96c6\u4e2d\u7684\u4e00\u4e2a\u591a\u5a92\u4f53\u5206\u6790\u5de5\u5177\uff0c\u7528\u4e8e\u63d0\u53d6\u97f3\u89c6\u9891\u6587\u4ef6\u7684\u5143\u6570\u636e\u3001\u683c\u5f0f\u4fe1\u606f\u3001\u6d41\u4fe1\u606f\u7b49 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3355","post","type-post","status-publish","format-standard","hentry","category-life"],"_links":{"self":[{"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/posts\/3355","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.51cos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3355"}],"version-history":[{"count":2,"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/posts\/3355\/revisions"}],"predecessor-version":[{"id":3357,"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/posts\/3355\/revisions\/3357"}],"wp:attachment":[{"href":"http:\/\/www.51cos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3355"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.51cos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3355"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.51cos.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3355"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}