FFmpeg:从mp4读取配置文件级别信息
我有一个mp4文件,需要它的配置文件级别。FFmpeg说,它有基线配置文件,这是我需要的,但我也需要 以下是我从FFmpeg获得的信息:FFmpeg:从mp4读取配置文件级别信息,ffmpeg,h.264,mp4,Ffmpeg,H.264,Mp4,我有一个mp4文件,需要它的配置文件级别。FFmpeg说,它有基线配置文件,这是我需要的,但我也需要 以下是我从FFmpeg获得的信息: ffmpeg version 0.8, Copyright (c) 2000-2011 the FFmpeg developers built on Jul 20 2011 13:32:19 with gcc 4.4.3 configuration: --enable-gpl --enable-version3 --enable-nonfree --e
ffmpeg version 0.8, Copyright (c) 2000-2011 the FFmpeg developers
built on Jul 20 2011 13:32:19 with gcc 4.4.3
configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264
libavutil 51. 9. 1 / 51. 9. 1
libavcodec 53. 7. 0 / 53. 7. 0
libavformat 53. 4. 0 / 53. 4. 0
libavdevice 53. 1. 1 / 53. 1. 1
libavfilter 2. 23. 0 / 2. 23. 0
libswscale 2. 0. 0 / 2. 0. 0
libpostproc 51. 2. 0 / 51. 2. 0
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test-show.mp4':
Metadata:
major_brand : f4v
minor_version : 0
compatible_brands: isommp42m4v
creation_time : 2012-03-21 16:00:00
Duration: 00:56:07.40, start: 0.000000, bitrate: 2004 kb/s
Stream #0.0(eng): Video: h264 (Baseline), yuv420p, 854x480 [PAR 1:1 DAR 427:240], 1904 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
Metadata:
creation_time : 2012-03-21 16:00:00
Stream #0.1(eng): Audio: aac, 48000 Hz, stereo, s16, 96 kb/s
Metadata:
creation_time : 2012-03-21 16:00:00
At least one output file must be specified
除了
-i
之外,还有其他选项可以用来获取级别信息吗?试试ffprobe-show\u streams
ffprobe
与FFmpeg捆绑在一起,提供了大量有关视频文件的信息,包括级别信息,例如:
$ ffprobe -loglevel error -show_streams Test.mp4
[STREAM]
index=0
codec_name=h264
codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
codec_type=video
codec_time_base=1001/48000
codec_tag_string=avc1
codec_tag=0x31637661
width=704
height=400
has_b_frames=0
sample_aspect_ratio=N/A
display_aspect_ratio=N/A
pix_fmt=yuv420p
level=51 <== level!
timecode=N/A
is_avc=1
nal_length_size=4
id=N/A
r_frame_rate=24000/1001
avg_frame_rate=1384898760/57761819
time_base=1/44100
start_time=0.000000
duration=6548.959070
bit_rate=701946
nb_frames=157018
nb_read_frames=N/A
nb_read_packets=N/A
TAG:creation_time=2006-08-17 18:14:49
TAG:language=eng
TAG:handler_name=
[/STREAM]
$ffprobe-日志级别错误-显示\u streams Test.mp4
[流]
索引=0
编解码器名称=h264
编解码器_long_name=H.264/AVC/MPEG-4 AVC/MPEG-4第10部分
编解码器类型=视频
编解码器时间基数=1001/48000
编解码器\标签\字符串=avc1
编解码器标签=0x31637661
宽度=704
高度=400
具有_b_帧=0
样本长宽比=不适用
显示纵横比=不适用
pix_fmt=yuv420p
level=51对于此类输出,您可以与option-info一起使用:
Track # 2 Info - TrackID 2 - TimeScale 25000 - Duration 01:29:42.160
Media Info: Language "Undetermined" - Type "vide:avc1" - 134554 samples
MPEG-4 Config: Visual Stream - ObjectTypeIndication 0x21
AVC/H264 Video - Visual Size 1280 x 720 - **Profile High @ Level 3.1**
NAL Unit length bits: 32
Pixel Aspect Ratio 1:1 - Indicated track size 1280 x 720
Synchronized on stream 1
请尝试以下内容以获取更详细的json输出
$ ffprobe -print_format json -show_streams -show_format <filepath>
$ffprobe-print\u format json-show\u streams-show\u format
ffprobe带有show\u条目的命令应该更快,并且它有更多的选项来仅显示相关数据和仅过滤视频流
仅过滤视频(添加:0仅过滤第一个视频流)
在MS批处理文件中(作为假函数):
调用:ffprobeGetFormatProfile ffprobe.exe file.mp4 txtFormat
:ffprobeGetFormatProfile <exe> <infile> <outStr>
echo.
echo FILE: %2
set tmpProfile=
set tmpLevel=
for /f "usebackq delims== tokens=1-2" %%a in (`%~s1 -v error -select_streams v:0 -show_entries stream^=profile^,level -of default^=noprint_wrappers^=1 %2`) do (
if /I %%a == profile set tmpProfile=%%b
if /I %%a == level set tmpLevel=%%b
)
if not defined tmpLevel set tmpLevel=??
echo on
set %3=%tmpProfile%@%tmpLevel:~0,1%.%tmpLevel:~1%
@echo off
exit /b %errorlevel%
:ffprobeGetFormatProfile
回声。
回显文件:%2
设置tmpProfile=
设置tmpLevel=
对于/f“usebackq delims==tokens=1-2”%%a in(`%s1-v错误-选择\u流v:0-显示\u条目流^=profile^,默认级别^=noprint\u包装器^=1%2`)do(
如果/I%%a==配置文件集tmpProfile=%%b
如果/I%%a==水平集tmpLevel=%%b
)
如果未定义tmpLevel,则设置tmpLevel=??
呼应
设置%3=%tMProfile%@%tmpLevel:~0,1%。%tmpLevel:~1%
@回音
退出/b%errorlevel%
e、 g.输出(在作为第三个参数传递的变量txtFormat中):
High@4.1
您可以从中获得更多想法是的,这给了我更多的信息,但比您从文件中获得的信息要少,而不是级别信息:/Hm,如果ffprobe没有显示它,那么我想知道它是否真的存在。您是否能够使用任何其他(非CLI)工具(如VLC)获取文件的级别信息?@Martin,想知道您所说的“比您从文件中获得的少,而不是级别信息”是什么意思。视频流部分的级别不是你们想要的吗?但它也包括音频流,有些也有级别信息。此外,解析多个文件很困难,而且速度很慢。也许你想在个人资料中看到它:High@L4.0格式。查看我的答案。@blahdiblah但是ffprobe
确实显示了级别
值-它有点隐藏在发布的输出中,但是查找Level=51
-show_格式将除了-show_流打印容器信息之外,那里没有配置文件信息,但是json输出可能对某些人很方便
ffprobe -v error -select_streams v:0 -show_entries stream=level -of default=noprint_wrappers=1:nokey=1 <filepath>
ffprobe -v error -select_streams v:0 -show_entries stream=profile,level -of default=noprint_wrappers=1 <filepath>
ffprobe -v error -select_streams v:0 -show_entries stream=profile,level -of json <filepath>
{
"programs": [
],
"streams": [
{
"profile": "High",
"level": 41
}
]
}
:ffprobeGetFormatProfile <exe> <infile> <outStr>
echo.
echo FILE: %2
set tmpProfile=
set tmpLevel=
for /f "usebackq delims== tokens=1-2" %%a in (`%~s1 -v error -select_streams v:0 -show_entries stream^=profile^,level -of default^=noprint_wrappers^=1 %2`) do (
if /I %%a == profile set tmpProfile=%%b
if /I %%a == level set tmpLevel=%%b
)
if not defined tmpLevel set tmpLevel=??
echo on
set %3=%tmpProfile%@%tmpLevel:~0,1%.%tmpLevel:~1%
@echo off
exit /b %errorlevel%