ffprobe 多媒体分析工具教程 附急用脚本 2026 版 更新 5
“视频探针” ffprobe 是 ffmpeg 官方发布的 CLI 多媒体分析工具,主要适用于分析视频文件的格式。其最大特点是能在常见的视频格式中做到 GOP 级和帧级的信息读取,这使得 ffprobe 同时具有抗元数据异常,以及实现数据分析(如码率变化可视化)的能力。
ffprobe 的同类软件是 MediaInfo,后者主打多系统 GUI 软件的元数据读取解析。两者同时提供了动态链接库,以便软件开发使用(API)。
- “Probe” 可以译作任何探测、采集器具的名称,此处只因作者喜欢所以译为视频探针~
一般用途
ffprobe [参数] [输入]
ffprobe -i [输入] [参数]
急用版参数
ffprobe.exe -i ".\视频.mp4" -select_streams v:0 -v error -hide_banner -show_streams -show_frames -read_intervals "%+#1" -show_entries frame=top_field_first:stream=codec_long_name,width,coded_width,height,coded_height,field_order,r_frame_rate,avg_frame_rate,nb_frames,pix_fmt,color_range,color_space,color_transfer,color_primaries -of ini > "X:\文件夹\视频信息.txt"特急急用版参数(PowerShell 脚本)
<#
.SYNOPSIS
ffprobe 调用半自动化脚本
.DESCRIPTION
选择 ffprobe.exe 路径、要分析的视频文件、导出信息的路径与格式,从而获取视频信息
.AUTHOR
A@NAZOrip (https://nazorip.site)
.VERSION
0.3
#>
#region enablements
# 启用 WinForm
if (-not ("System.Windows.Forms.Form" -as [type])) {
Add-Type -AssemblyName System.Windows.Forms
}
# 高 DPI 支持(只注册一次)
if (-not ("DpiHelper" -as [type])) {
Add-Type @"
using System.Runtime.InteropServices;
public class DpiHelper {
[DllImport("user32.dll")]
public static extern bool SetProcessDPIAware();
}
"@
[void][DpiHelper]::SetProcessDPIAware()
}
#endregion
#region globals
$Global:utf8NoBOM = New-Object System.Text.UTF8Encoding($false) # UTF-8 No BOM
$Global:utf8BOM = New-Object System.Text.UTF8Encoding($true) # UTF-8 带 BOM,以便 CMD 正确识别
#endregion
#region console
# 用户交互信息
function Show-Error ($Message) { Write-Host " [错误]`r`n $Message" -ForegroundColor Red }
function Show-Warning ($Message) { Write-Host " [警告]`r`n $Message" -ForegroundColor Yellow }
function Show-Success ($Message) { Write-Host " [成功] $Message" -ForegroundColor Green }
function Show-Info ($Message) { Write-Host " [说明] $Message" -ForegroundColor Cyan }
function Show-Debug ($Message) { Write-Host " [捉虫] $Message" -ForegroundColor Magenta }
function Show-Border { Write-Host ("="*50) -ForegroundColor Blue }
#endregion
#region fileutils
# 检测文件名是否符合 Windows 命名规则
function Test-FilenameValid {
param([string]$Filename)
$invalid = [IO.Path]::GetInvalidFileNameChars()
return $Filename.IndexOfAny($invalid) -eq -1
}
# 安全的文件引用函数(确保有引号并转义)
function Get-QuotedPath {
param([string]$Path)
return "`"$Path`""
}
# 若文件名重复则确认是否删除
function Confirm-FileDelete {
param([string]$Path)
if (-not (Test-Path -LiteralPath $Path)) { return }
Show-Warning "Confirm-FileDelete——检测到已存在文件:$Path"
$confirm = Read-Host "Confirm-FileDelete——是否删除该文件以继续?输入 'y' 确认,其它任意键取消(永久删除)"
if ($confirm -ne 'y') {
Show-Info "Confirm-FileDelete——用户取消操作,脚本终止"
exit 1
}
Remove-Item $Path -Force
Show-Success "已删除旧文件:$Path"
}
function Select-File(
[string]$Title = "选择文件",
[string]$InitialDirectory = [Environment]::GetFolderPath('Desktop'),
[switch]$ExeOnly,
[switch]$AvsOnly,
[switch]$VpyOnly,
[switch]$DllOnly,
[switch]$IniOnly,
[switch]$BatOnly
) {
# 若是文件路径则取其父目录;如果路径不存在回到 Desktop
if ($InitialDirectory) {
if (Test-Path $InitialDirectory -PathType Leaf) {
$InitialDirectory = Split-Path $InitialDirectory -Parent
}
if (-not (Test-Path $InitialDirectory -PathType Container)) {
$InitialDirectory = [Environment]::GetFolderPath('Desktop')
}
}
else {
$InitialDirectory = [Environment]::GetFolderPath('Desktop')
}
$dialog = New-Object System.Windows.Forms.OpenFileDialog
$dialog.Title = $Title
$dialog.InitialDirectory = $InitialDirectory
$dialog.Multiselect = $false
# 后缀名过滤
if ($ExeOnly) { $dialog.Filter = 'exe files (*.exe)|*.exe' }
elseif ($AvsOnly) { $dialog.Filter = 'avs files (*.avs)|*.avs' }
elseif ($VpyOnly) { $dialog.Filter = 'vpy files (*.vpy)|*.vpy' }
elseif ($DllOnly) { $dialog.Filter = 'dll files (*.dll)|*.dll' }
elseif ($IniOnly) { $dialog.Filter = 'ini files (*.ini)|*.ini' }
elseif ($BatOnly) { $dialog.Filter = 'bat Files (*.bat)|*.bat' }
else { $dialog.Filter = 'All files (*.*)|*.*' }
Show-Info " 选窗可能会在本窗口后面打开,这里不要按回车"
while ($true) {
if ($dialog.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK) {
return $dialog.FileName
}
$choice = Read-Host "Select-Folder——未选择文件,按回车重试或输入 'q' 强制退出"
if ($choice -eq 'q') { exit 1 }
}
}
function Select-Folder([string]$Description = "选择文件夹", [string]$InitialPath = [Environment]::GetFolderPath('Desktop')) {
# (Put on top of script) Add-Type -AssemblyName System.Windows.Forms
$dialog = New-Object System.Windows.Forms.FolderBrowserDialog
$dialog.Description = $Description
$dialog.SelectedPath = $InitialPath
$dialog.ShowNewFolderButton = $true
Show-Info " 选窗可能会在本窗口后面打开,这里不要按回车"
while ($true) {
if ($dialog.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK) {
$path = $dialog.SelectedPath
if (-not $path.EndsWith('\')) { $path += '\' }
return $path
}
$choice = Read-Host "Select-Folder——未选择文件夹,按回车重试或输入 'q' 强制退出"
if ($choice -eq 'q') { exit 1 }
}
}
# 生成使用 Windows(CRLF 换行)、UTF-8 BOM 文本编码的批处理
function Write-TextFile { # 需在 Core.ps1 写入全局变量后运行
param(
[Parameter(Mandatory=$true)][string]$Path,
[Parameter(Mandatory=$true)][string]$Content,
[bool]$UseBOM = $true
)
if ([string]::IsNullOrWhiteSpace($Path)) {
Write-Error "Write-TextFile——文件写入失败:空路径"
return
}
if ([string]::IsNullOrWhiteSpace($Content)) {
Write-Error "Write-TextFile——文件写入失败:空内容"
return
}
# 必须使用 CRLF 换行符,否则 CMD 无法读取(乱码)
$normalizedContent = $Content -replace "`r?`n", "`r`n"
# 选择编码
$encoding = if ($UseBOM) { $Global:utf8BOM } else { $Global:utf8NoBOM }
# 写入文件
[System.IO.File]::WriteAllText($Path, $normalizedContent, $encoding)
Show-Debug "Write-TextFile——编码:$($encoding.EncodingName), 换行符:CRLF"
Show-Success "Write-TextFile——文件已写入:$Path"
}
#endregion
#region ffprobe
# 用 ffprobe 获取媒体流元数据
function Get-StreamMetadata {
param(
[Parameter(Mandatory = $true)][string]$FFprobePath,
[Parameter(Mandatory = $true)][string]$SourcePath,
[ValidateSet('v','a','s','t')][string]$StreamType = 'v',
[string]$OutputPath = '', # 留空则不导出文件
[ValidateSet('json','ini','xml','csv')][Parameter(Mandatory=$true)]$OutputFormat = 'json'
)
# 验证流文件/ffprobe存在
if (-not (Test-Path -LiteralPath $SourcePath)) {
Show-Error "Get-StreamMetadata——源文件不存在:$SourcePath"
return $null
}
if (-not (Test-Path -LiteralPath $FFprobePath)) {
Show-Error "Get-StreamMetadata——ffprobe 不存在:$FFprobePath"
return $null
}
# 构建 ffprobe 命令
try {
# & 运算符不支持 shell 重定向符(>),输出通过 PowerShell 捕获后再写文件
$arguments = @(
"-v", "quiet",
"-print_format", $OutputFormat, # 只需指定一次,-of 是别名,这里使用全名
"-show_streams",
"-select_streams", $StreamType,
"-show_frames",
"-read_intervals", "%+#1",
"-show_entries", "frame:stream",
$SourcePath # 路径直接作为末尾参数
)
# Show-Debug "ffprobe 命令:$FFprobePath"
# 执行 ffprobe 并捕获输出
# 2>&1 合并 stderr,从而以 $LASTEXITCODE 判断成败
$rawOutput = & $FFprobePath @arguments 2>&1
if ($LASTEXITCODE -ne 0) {
Show-Warning "ffprobe 执行失败(退出代码: $LASTEXITCODE)"
Show-Debug "ffprobe 输出:$rawOutput"
return $null
}
$outputText = $rawOutput | Out-String
# 可选的文件导出
if (-not [string]::IsNullOrWhiteSpace($OutputPath)) {
Confirm-FileDelete -Path $OutputPath
# json/xml 用 UTF-8 NoBOM;ini/csv 用 UTF-8 BOM(方便 Excel 打开)
$useBOM = ($OutputFormat -in @('ini','csv'))
Write-TextFile -Path $OutputPath -Content $outputText -UseBOM $useBOM
}
# 仅 JSON 格式支持结构化输出
if ($OutputFormat -ne 'json') {
Show-Info "输出格式为 $OutputFormat,跳过结构化解析,返回原始文本"
return $outputText
}
$metadata = $outputText | ConvertFrom-Json
# 如果没有找到指定类型的流则返回并退出
if (-not $metadata.streams -or $metadata.streams.Count -eq 0) {
Show-Info "未找到指定为 $StreamType 类型的流:$SourcePath"
return $null
}
$firstFrame = if ($metadata.frames -and $metadata.frames.Count -gt 0) { $metadata.frames[0] } else { $null }
# 构建返回对象
$stream = $metadata.streams[0]
$streamInfo = [PSCustomObject]@{
Index = if ($null -ne $stream.index) { [int]$stream.index } else { 0 }
CodecName = $stream.codec_long_name
CodecTag = $stream.codec_tag_string
CodecType = $stream.codec_type
# 帧率:分数格式(如 24000/1001);整除时化简为整数字符串
FrameRate = if ($stream.r_frame_rate) {
$fr = $stream.r_frame_rate.ToString()
if ($fr -match '^(\d+)/1$') { $Matches[1] } else { $fr }
} else { $null }
AvgFrameRate = if ($stream.avg_frame_rate) {
$afr = $stream.avg_frame_rate.ToString()
if ($afr -match '^(\d+)/1$') { $Matches[1] } else { $afr }
} else { $null }
TimeBase = if ($stream.time_base) {
$tb = $stream.time_base.ToString()
if ($tb -match '^(\d+)/1$') { $Matches[1] } else { $tb }
} else { $null }
StartPts = $stream.start_pts
StartTime = $stream.start_time
Width = if ($stream.width) { [int]$stream.width } else { $null }
Height = if ($stream.height) { [int]$stream.height } else { $null }
CodedWidth = if ($stream.coded_width) { [int]$stream.coded_width } else { $null }
CodedHeight = if ($stream.coded_height) { [int]$stream.coded_height } else { $null }
NbFrames = if ($stream.nb_frames) { [int]$stream.nb_frames } else { $null }
PixFmt = $stream.pix_fmt
FieldOrder = $stream.field_order
ColorRange = $stream.color_range
ColorSpace = $stream.color_space
ColorTransfer = $stream.color_transfer
ColorPrimaries= $stream.color_primaries
# 来自第一帧
TopFieldFirst = if ($firstFrame) { $firstFrame.top_field_first } else { $null }
Duration = if ($stream.duration) { [double]$stream.duration } else { $null }
BitRate = if ($stream.bit_rate) { [long]$stream.bit_rate } else { $null }
SampleRate = if ($stream.sample_rate) { [int]$stream.sample_rate } else { $null }
Channels = if ($stream.channels) { [int]$stream.channels } else { $null }
Language = if ($stream.tags -and $stream.tags.language) { $stream.tags.language } else { $null }
RawStream = $stream # 保留原始流数据
RawFrame = $firstFrame # 保留原始帧数据
}
return $streamInfo
}
catch {
Show-Error "解析 ffprobe 输出时出错:$_"
Show-Debug "错误堆栈:$($_.ScriptStackTrace)"
return $null
}
}
#endregion
#region main
Show-Border
Show-Info "ffprobe 元数据提取工具"
Show-Border
# 1. 选择 ffprobe.exe
Show-Info "请选择 ffprobe.exe"
$ffprobePath = Select-File -Title "选择 ffprobe.exe" -ExeOnly
Show-Success "ffprobe:$ffprobePath"
# 2. 选择源
Show-Info "请选择要分析的媒体文件"
$sourcePath = Select-File -Title "选择媒体文件"
Show-Success "源文件:$sourcePath"
# 3. 选择流
Show-Border
Write-Host " 请选择要分析的流类型:"
Write-Host " [v] 视频流(默认)"
Write-Host " [a] 音频流"
Write-Host " [s] 字幕流"
Write-Host " [t] 字体件"
$streamTypeInput = Read-Host " 输入流类型代码(直接回车默认 v)"
$streamTypeInput = $streamTypeInput.Trim().ToLower()
$validStreamTypes = @('v','a','s','t')
if ($streamTypeInput -notin $validStreamTypes) {
if ($streamTypeInput -ne '') {
Show-Warning "无效输入 '$streamTypeInput',已自动使用默认值 'v'"
}
$streamTypeInput = 'v'
}
Show-Info "已选流类型:$streamTypeInput"
# 4. 选择输出格式
Show-Border
Write-Host " 请选择输出格式:"
Write-Host " [1] json(默认)"
Write-Host " [2] xml"
Write-Host " [3] ini"
Write-Host " [4] csv"
$fmtInput = Read-Host " 输入编号(直接回车默认 json)"
$outputFormat = switch ($fmtInput.Trim()) {
'2' { 'xml' }
'3' { 'ini' }
'4' { 'csv' }
default { 'json' }
}
Show-Info "已选输出格式:$outputFormat"
Write-Host ""
# 5. 决定是否写入文件
Show-Border
$saveChoice = Read-Host " 是否将原始输出保存到文件?输入 'y' 确认,其它任意键跳过"
$outputPath = ""
if ($saveChoice -eq 'y') {
# 默认输出文件名:源文件名_stream_v.json
$sourceBase = [System.IO.Path]::GetFileNameWithoutExtension($sourcePath)
$defaultName = "${sourceBase}_stream_${streamTypeInput}.${outputFormat}"
$outputFolder = Select-Folder -Description "选择输出文件夹" -InitialPath (Split-Path $sourcePath -Parent)
$outputPath = Join-Path $outputFolder $defaultName
Show-Info "输出路径:$outputPath"
}
# 6. 自定义无效值
Show-Border
$placeholder = Read-Host " 输入元数据/属性值不存在时的自定义不可用字样(如 NA,直接回车则默认留空)"
# 6. 分析
Show-Border
Show-Info "开始分析……"
Write-Host ""
$result = Get-StreamMetadata `
-FFprobePath $ffprobePath `
-SourcePath $sourcePath `
-StreamType $streamTypeInput `
-OutputPath $outputPath `
-OutputFormat $outputFormat
# 7. 展示结果
Show-Border
if ($null -eq $result) {
Show-Error "未能获取流信息,请检查上述错误提示"
}
elseif ($result -is [string]) {
# 非 json 格式,直接打印原始文本
Show-Info "原始输出:"
Write-Host ""
Write-Host $result
}
else {
Show-Success "分析完成:"
Write-Host ""
# 遍历所有属性
foreach ($prop in $result.PSObject.Properties) {
$currentVal = $prop.Value
# 如果值存在(非空且不为 null),则打印值,否则打印 placeholder
if (-not [string]::IsNullOrWhiteSpace($currentVal)) {
Write-Host (" {0,-12} : {1}" -f $prop.Name, $currentVal)
}
else {
Write-Host (" {0,-12} : {1}" -f $prop.Name, $placeholder)
}
}
}
Show-Border
# Smarter pause
if ($host.name -notmatch 'ISE') { pause }
#endregion
写入
ffprobe [参数] [输入] >1.txt
叠加
>>1.txt
临时变量(.bat)
@ set 给出分辨率=ffprobe [参数1]
@ set 给出时长=ffprobe [参数2]
%给出时长% [输入1]
%给出分辨率% [输入2]
%给出分辨率% [输入3]
pause
临时变量(.sh)
#!/bin/Bash
给出分辨率=ffprobe [参数1]
给出时长=ffprobe [参数2]
$给出时长 [输入1]
$给出分辨率 [输入2]
$给出分辨率 [输入3]
read -rsp $'按任意键继续...\n' -n 1 key
问题
ffprobe 可能会输出 pix_fmt 为 "yuvj..." 而不是 "yuv..."(如 yuvj420p,yuv420p),这个 j 是被 ffmpeg 淘汰的完整色深 fullrange 写法,代表 jpeg。
在 ffmpeg 的 color_range 参数说明中,可以看到 jpeg 和完整色域是同义词
常用参数
-hide_banner<开关>不显示版权,编译源,配置,libav等信息(一般v error即可)
-v(-loglevel)<字符>quiet不报错,panic只报能崩溃的错,fatal只报能终止分析的错,error报错,warning警告+报错,info所有有效信息(警告,报错,版权,编译源,配置,libav等)
-pretty<开关>体积数据加单位(-unit),开始结束格式改0:00:00.000000 (-sexagesimal),总大小改Kib/MiB (-prefix),总码率改Kbps/Mbps (-byte_binary_prefix),只要不给机器读,建议一直使用此参数
-show_format<开关>输出视频元数据
-show_frames<开关>输出探测每 -read_intervals 帧视频帧得出的属性数据,包括了必须按需配置滤镜/编码器参数的值
-show_packets<开关>输出数据包的属性,其中的内容大多为时间戳和帧大小;-show_frames 输出的信息中已经包括了 -show_packets 的全部内容,因此只在不需要视频帧信息的情况下有用
-read_intervals "%+#1" 限制 show_frames 指输出第一帧的帧信息,避免大量重复信息输出,但也失去了检测坏帧(找出数据异常帧)的能力
-show_entries<开关>限制 show_format,show_frames,show_packets 输信息类别,如:
format=<attribute1>,<attribute2>- 限制
show_format输出两项指定属性
- 限制
format=<attribute1>:stream=<attribute1>,<attribute2>:frame=<attribute1>:packet=<attribute1>- 限制
-show_format输出一项指定属性、-show_stream输出两项指定属性、同时-show_packets输出一项指定属性
- 限制
-select_streams<a/v/a:#/v:#>用这个参数只输出封装中的一个流,a:0能选择封装中的第0号音频流,只有一个视频和音频的情况不用写":". 缺点是只能手动分离字幕流和视频流
格式:
-of(-print_format)<字符/字符+命令>default,json,xml,flat,csv,ini(of感觉应该是omit format,pf才是print format啊=_=)
???:???=1---------------用来选择default/json/xml/csv等等输出工具的选项
default:nokey=1------------只输出值和换行
default:noprint_wrappers=1-去掉[]和[/]两行字,html里相当于开始结束标记
default:nk=1:=nw=1---------两个一起
json--------------------写成json格式
json:c=1----------------使用精简compact写法
xml---------------------写成xml格式
xml:q=1-----------------输出fully_qualified,能通过XSD文件认证的xml
xml:x=1-----------------检查输出的xml是否能通过XSD文件认证
flat--------------------适合shell的值(streams.stream.0.codec_name="h264")
flat:s=~----------------自定分隔符(如streams~stream~0~codec_name="h264")
flat:h=1----------------用分叉hierarchical结构写子项目
csv---------------------使用精简compact写法,所有项目变成一行字串,用逗号分隔
csv:s=~-----------------自定分隔符,默认逗号
csv:nk=1----------------只输出值
csv:e=c-----------------用C语言换码符
ini---------------------使用ini格式(这个比默认还好看,建议替代默认哦)
ini:h=1-----------------用分叉hierarchical结构写子项目
信息输出
<参数>:
[标记]
参数--------------------翻译------------------进一步解释或例子
[/标记]
-show_format<开关>
[FORMAT]
filename----------------文件名和路径
nb_streams--------------流数量----------------视音频流总数
nb_programs-------------?程序数量?
format_name-------------封装格式名
format_long_name--------封装格式全名
start_time--------------开始------------------以秒显示,6位小数
duration----------------时长秒
size--------------------总大小----------------byte,3,000,000B = 3MB = 2.97MiB
bit_rate----------------总码率 ---------------bit,1,000,000b = 1Mb = 0.125MB = 0.119MiB
probe_score-------------探针得分--------------ffmpeg检查文件后缀+元数据的格式描述是否属实的判定,此处没用
[/FORMAT]
-show_programs<开关>具体功能未知
附: 视频技术的时间观念:
时尺Time Scale 60代表60帧每秒
时间戳Time Stamp/Base 分数显示每帧显示多长时间,1/60代表一帧出现六十分之一秒
显示时间戳Presentation TS 与时间戳相乘的倍数,按照规律变大(0,3,6,9...),算出来的数就是此帧在解码时的播放时间
显示戳时间PTS Time 显示时间戳pts×时间戳ts,算出来的数就是以秒为单位的播放时间
解码时间戳Decoding TS 与时间戳相乘的倍数,按照规律变大. 应比显示时间早
解码戳时间DTS Time 解码的执行时间,解码时间戳dts乘以时间戳ts
这么复杂有些原因是为支持可变帧率VFR技术. 没VFR,手机录像当场没电
时长秒Duration 可以用来精确(6位小数)得知流结尾时间
时长戳Duration_ts Dts不是DTS,却是造成混淆的原因之一,此处代表TS格式的时长
时长可以看做结束时间
-show_streams(视频流)
[STREAM]
index-------------------------------目录------------------------此封装中的第#个视/音频流
codec_name--------------------------编解码名
codec_long_name---------------------编解码全名
profile
codec_type--------------------------编解码类
codec_time_base---------------------编解码时基/时戳--------------解释见"视频技术的时间观念"
codec_tag_string--------------------编解码标签字符---------------如avc1(就是0x31 0x63 0x76 0x61翻译成字符)
codec_tag---------------------------编解码标签-------------------FourCC格式的字符串,0x31637661
width
height
has_b_frames------------------------B帧存在
coded_width-------------------------编码宽----------------------对比宽和高,可判断非方形像素视频
coded_height------------------------编码高
sample_aspect_ratio-----------------源宽高比
display_aspect_ratio----------------显示宽高比-------------------对比源宽高比,可算出拉伸比率
pxl_fmt-----------------------------像素格式
level
color_range-------------------------色彩范围---------------------pc/tv
color_space-------------------------色彩空间---------------------源用的色彩空间
color_transfer----------------------色彩空间转换-----------------播放用色彩空间
color_primaries---------------------三原色值标准-----------------播放用基色,指定给和播放器默认所不同的源
chroma_location---------------------色度采样位置
field_order-------------------------优先场
time_code---------------------------时间码
refs--------------------------------参考帧(不好使?)--------------视频的参考帧数量设定,数字通常算不对?
is_avc------------------------------AVC格式确认(未测试is_hevc, is_isom等)
nal_length_size---------------------NAL长度大小
ID
r_frame_rate------------------------率帧率
avg_frame_rate----------------------平均帧率
time_base---------------------------时基戳-----------------------用分数表示一帧出现多长时间(pts_time÷pts)
start_pts---------------------------起始显示时间戳
start_time--------------------------起始时间
duration_ts-------------------------时长戳
duration----------------------------时长秒
bit_rate----------------------------码率
max_bit_rate------------------------最大码率
bits_per_raw_sample-----------------采样内容深度(色深)
nb_frames---------------------------总帧数
nb_read_frames----------------------读取帧总数
nb_read_packets---------------------读取数据包总数
[/STREAM]
-show_streams(音频流)
[STREAM]
index-------------------------------目录----------------------此封装中的第#个视/音频流
codec_name--------------------------编解码名
codec_long_name---------------------编解码全名
profile
codec_type--------------------------编解码类
codec_time_base---------------------编解码时基/时间戳----------一般1/44100
codec_tag_string--------------------编解码标签字符-------------FourCC格式的字符串,特殊情况是PCM_S16LE标着0x0001
codec_tag---------------------------编解码标签
sample_fmt--------------------------采样格式
sample_rate-------------------------采样率
channels----------------------------声道数
channel_layout----------------------声道布置-------------------一般strero立体声
bits_per_sample---------------------位深
ID
r_frame_rate------------------------率帧率---------------------N/A
avg_frame_rate----------------------平均帧率-------------------N/A
time_base---------------------------时基戳---------------------一般1/44100
start_pts---------------------------起始显示时间戳-------------N/A
start_time--------------------------起始时间------------------N/A
duration_ts-------------------------时长戳
duration----------------------------时长秒
bit_rate----------------------------码率
max_bit_rate------------------------最大码率
bits_per_raw_sample-----------------采样内容深度--------------N/A
nb_frames---------------------------总帧数-------------------N/A
nb_read_frames----------------------读取帧总数---------------N/A
nb_read_packets---------------------读取数据包总数-----------N/A
[/STREAM]
-show_packets(视音频混合? 由于是网络数据包,所以一般会输出上千个packets)
[PACKET]
codec_type--------------------------编解码种类---------------视频/音频
stream_index------------------------目录--------------------此封装中的第#个视/音频流
pts---------------------------------显示时间戳
pts_time----------------------------显示戳时间
dts---------------------------------解码时间戳
dts_time----------------------------解码戳时间
duration----------------------------时长秒
duration_time-----------------------时长戳
convergence_duration----------------收敛时长戳--------------当前所有路由器对网络结构变动(增加减少路由器)而适应所需时间
convergence_duration_time-----------收敛时长秒
size--------------------------------大小
[/PACKET]
-show_frames(注意,音频里也有帧,如不希望音频信息则用select_streams过滤掉)。缺点:只能手动分离字幕流和视频流
[FRAME.<当前所处帧号>]
media_type--------------------------音/视/字幕流
stream_index------------------------目录--------------------此封装中的第#个视/音频流
key_frame---------------------------是否为关键帧-------------0=i/P/B帧,1=IDR帧
pkt_pts-----------------------------封装数据包的显示时间戳
pkt_pts_time------------------------封装数据包的显示戳时间
pkt_dts-----------------------------封装数据包的解码时间戳
pkt_dts_time------------------------封装数据包的解码戳时间
best_effort_timestamp---------------pts缺失下用帧号,avctx,pkt_dts推算的时间戳
pkt_duration------------------------封装数据包的时长秒
pkt_duration_time-------------------封装数据包的时长戳
pkt_pos-----------------------------封装数据包的所需号位
pkt_size----------------------------封装数据包的所需大小
width-------------------------------宽
height------------------------------高
pix_fmt-----------------------------像素排列格式
pict_type---------------------------帧类型(I/B/P)
coded_picture_number----------------编码帧号位
display_picture_number--------------显示帧号位
interlaced_frame--------------------是否交错(0/1)
top_field_first---------------------是否上场优先(0/1)
repeat_pict-------------------------重复帧(SEI标注padding)
color_range-------------------------full=pc,limited=tv
chroma_location---------------------色度采样朝向位置
[/FRAME]
输出多个信息:
-show_streams -show_format等参数并列写上即可
导出 1.mp4 的信息到 1.txt,隐藏标题,美化,用 ini 逐单元缩进格式书写:
ffprobe.exe -i "1.mp4" -hide_banner -pretty -of ini:h=1 >> 1.txt
那么就这样。如果觉得没啥用的话,那...来学学搭配Excel实现码率曲线,码率趋势,帧类型饼图的方法呗 <(。_。)>
附: Typecho无法使用大空格(TAB键)对齐,先用小空格将靠左单词长度同化也没用,只有-
转载要求: 在本文下方写上"转载+冒号+转载地址",或者下方发个评论... 但是真的会有人转载这玩意儿吗?
打赏信息
在线丢人,求个打赏,支持一下T_T
[...]CLI 视音频格式读取器,若检测所得信息与 MediaInfo 所异,则优先参考 ffprobe见基本使用,以及搭配 Excel 的视频数据可视化教程[...]
[...]附录 γ:ffprobe 教程 或 Github 副本[...]
[...]ffmpeg强大的 CLI 开源视音频处理工具。几乎所有的视音频处理都绕不开mpv开源,支持便携的现代视频播放器。见安装与配置教程Voukoder开源 Premiere Vegas After Effects 压制导出插件,分为 Voukoder 和 V-Connector 两部分OBS强大的开源直播框架和软件,设置略比传统录屏软件复杂,但效果也更好MediaInfo开源的 GUI 媒体元数据/视[...]
牛逼,有些很细的东西我在ffmpeg官方都没找到(可能是我太菜了),在这里解决了
ffmpeg官方文档的排版很迷的,看不懂很正常=_=