如何获取h264视频信息?

发布于 2024-12-28 11:51:12 字数 60 浏览 0 评论 0原文

如何从视频文件中获取特定的h264视频信息?我需要了解配置文件(基线/主要/高)以及电影中是否有 B 帧?

How can I get specific h264 video information from video file? I need to know profile (Baseline/Main/High) and is there B-Frames in movie?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

画尸师 2025-01-04 11:51:12

我发现最好的方法是使用 FFprobe-show_streams 参数。它显示了电影视频流的 h.264 配置文件和 B 帧使用情况。

ffprobe -show_streams -i“file.mp4”

[STREAM]
index=0
codec_name=h264
codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
profile=High
codec_type=video
codec_time_base=1001/48000
codec_tag_string=avc1
codec_tag=0x31637661
width=1920
height=1080
has_b_frames=0
sample_aspect_ratio=0:1
display_aspect_ratio=0:1
pix_fmt=yuv420p
level=40
timecode=N/A
is_avc=1
nal_length_size=4
id=N/A
r_frame_rate=24000/1001
avg_frame_rate=24000/1001
time_base=1/48000
start_time=0.000000
duration=252.168583
bit_rate=5617233
nb_frames=6046
nb_read_frames=N/A
nb_read_packets=N/A
TAG:creation_time=1970-01-01 00:00:00
TAG:language=und
TAG:handler_name=VideoHandler
[/STREAM]

I've found out that the best way for this is using FFprobe with -show_streams parameter. It shows both h.264 profile and B-frames usage for video streams of the movie.

ffprobe -show_streams -i "file.mp4"

[STREAM]
index=0
codec_name=h264
codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
profile=High
codec_type=video
codec_time_base=1001/48000
codec_tag_string=avc1
codec_tag=0x31637661
width=1920
height=1080
has_b_frames=0
sample_aspect_ratio=0:1
display_aspect_ratio=0:1
pix_fmt=yuv420p
level=40
timecode=N/A
is_avc=1
nal_length_size=4
id=N/A
r_frame_rate=24000/1001
avg_frame_rate=24000/1001
time_base=1/48000
start_time=0.000000
duration=252.168583
bit_rate=5617233
nb_frames=6046
nb_read_frames=N/A
nb_read_packets=N/A
TAG:creation_time=1970-01-01 00:00:00
TAG:language=und
TAG:handler_name=VideoHandler
[/STREAM]
早茶月光 2025-01-04 11:51:12

mediainfo 是否提供您需要的输出?
http://mediainfo.sourceforge.net/en

(如果您使用的是 Mac,则可以使用 brew 轻松安装。> ; 酿造安装媒体信息)

$ mediainfo Dream.House.sample.mkv 
General
Unique ID                        : 247222296143464620093895254679791638636 (0xB9FD4845398D136BB4A1628DB750986C)
Complete name                    : Dream.House.sample.mkv
Format                           : Matroska
Format version                   : Version 2
File size                        : 126 MiB
Duration                         : 1mn 56s
Overall bit rate                 : 9 042 Kbps
Encoded date                     : UTC 2011-12-15 03:44:07
Writing application              : mkvmerge v3.0.0 ('Hang up your Hang-Ups') built on Dec 12 2009 15:20:35
Writing library                  : libebml v0.7.9 + libmatroska v0.8.1

Video
ID                               : 1
Format                           : AVC
Format/Info                      : Advanced Video Codec
Format profile                   : [email protected]
Format settings, CABAC           : Yes
Format settings, ReFrames        : 4 frames
Codec ID                         : V_MPEG4/ISO/AVC
Duration                         : 1mn 56s
Bit rate                         : 5 843 Kbps
Width                            : 1 280 pixels
Height                           : 544 pixels
Display aspect ratio             : 2.40:1
Frame rate                       : 23.976 fps
Color space                      : YUV
Chroma subsampling               : 4:2:0
Bit depth                        : 8 bits
Scan type                        : Progressive
Bits/(Pixel*Frame)               : 0.350
Stream size                      : 81.5 MiB (65%)
Language                         : English

Audio #1
ID                               : 2
Format                           : DTS
Format/Info                      : Digital Theater Systems
Codec ID                         : A_DTS
Duration                         : 1mn 56s
Bit rate mode                    : Constant
Bit rate                         : 1 510 Kbps
Channel(s)                       : 6 channels
Channel positions                : Front: L C R, Side: L R, LFE
Sampling rate                    : 48.0 KHz
Bit depth                        : 24 bits
Compression mode                 : Lossy
Delay relative to video          : 67ms
Stream size                      : 21.1 MiB (17%)
Language                         : Russian

Audio #2
ID                               : 3
Format                           : DTS
Format/Info                      : Digital Theater Systems
Codec ID                         : A_DTS
Duration                         : 1mn 56s
Bit rate mode                    : Constant
Bit rate                         : 1 510 Kbps
Channel(s)                       : 6 channels
Channel positions                : Front: L C R, Side: L R, LFE
Sampling rate                    : 48.0 KHz
Bit depth                        : 24 bits
Compression mode                 : Lossy
Delay relative to video          : 67ms
Stream size                      : 21.1 MiB (17%)
Language                         : English

Does mediainfo provide the output you need?
http://mediainfo.sourceforge.net/en

(if you're on a Mac, you can install easily with brew. > brew install media-info)

$ mediainfo Dream.House.sample.mkv 
General
Unique ID                        : 247222296143464620093895254679791638636 (0xB9FD4845398D136BB4A1628DB750986C)
Complete name                    : Dream.House.sample.mkv
Format                           : Matroska
Format version                   : Version 2
File size                        : 126 MiB
Duration                         : 1mn 56s
Overall bit rate                 : 9 042 Kbps
Encoded date                     : UTC 2011-12-15 03:44:07
Writing application              : mkvmerge v3.0.0 ('Hang up your Hang-Ups') built on Dec 12 2009 15:20:35
Writing library                  : libebml v0.7.9 + libmatroska v0.8.1

Video
ID                               : 1
Format                           : AVC
Format/Info                      : Advanced Video Codec
Format profile                   : [email protected]
Format settings, CABAC           : Yes
Format settings, ReFrames        : 4 frames
Codec ID                         : V_MPEG4/ISO/AVC
Duration                         : 1mn 56s
Bit rate                         : 5 843 Kbps
Width                            : 1 280 pixels
Height                           : 544 pixels
Display aspect ratio             : 2.40:1
Frame rate                       : 23.976 fps
Color space                      : YUV
Chroma subsampling               : 4:2:0
Bit depth                        : 8 bits
Scan type                        : Progressive
Bits/(Pixel*Frame)               : 0.350
Stream size                      : 81.5 MiB (65%)
Language                         : English

Audio #1
ID                               : 2
Format                           : DTS
Format/Info                      : Digital Theater Systems
Codec ID                         : A_DTS
Duration                         : 1mn 56s
Bit rate mode                    : Constant
Bit rate                         : 1 510 Kbps
Channel(s)                       : 6 channels
Channel positions                : Front: L C R, Side: L R, LFE
Sampling rate                    : 48.0 KHz
Bit depth                        : 24 bits
Compression mode                 : Lossy
Delay relative to video          : 67ms
Stream size                      : 21.1 MiB (17%)
Language                         : Russian

Audio #2
ID                               : 3
Format                           : DTS
Format/Info                      : Digital Theater Systems
Codec ID                         : A_DTS
Duration                         : 1mn 56s
Bit rate mode                    : Constant
Bit rate                         : 1 510 Kbps
Channel(s)                       : 6 channels
Channel positions                : Front: L C R, Side: L R, LFE
Sampling rate                    : 48.0 KHz
Bit depth                        : 24 bits
Compression mode                 : Lossy
Delay relative to video          : 67ms
Stream size                      : 21.1 MiB (17%)
Language                         : English
我很OK 2025-01-04 11:51:12

ffprobe,从版本 1.0.7 开始,通过 -print_format json 命令开关提供了格式良好的 JSON 输出。

你可以这样使用它:

ffprobe -v 安静 -print_format json -show_format Ramp\ -\ Apathy.mp3

产生以下输出:

{
    "format": {
        "filename": "Ramp - Apathy.mp3",
        "nb_streams": 2,
        "format_name": "mp3",
        "format_long_name": "MP2/3 (MPEG audio layer 2/3)",
        "start_time": "0.000000",
        "duration": "203.638856",
        "size": "4072777",
        "bit_rate": "159999",
        "tags": {
            "title": "Apathy",
            "artist": "Ramp",
            "album": "Evolution Devolution Revolution",
            "date": "1999",
            "genre": "Metal"
        }
    }
}

ffprobe, as of version 1.0.7 provides a nicely formated JSON output with the -print_format json command switch.

You can use it like this:

ffprobe -v quiet -print_format json -show_format Ramp\ -\ Apathy.mp3

Which produces the follwing output:

{
    "format": {
        "filename": "Ramp - Apathy.mp3",
        "nb_streams": 2,
        "format_name": "mp3",
        "format_long_name": "MP2/3 (MPEG audio layer 2/3)",
        "start_time": "0.000000",
        "duration": "203.638856",
        "size": "4072777",
        "bit_rate": "159999",
        "tags": {
            "title": "Apathy",
            "artist": "Ramp",
            "album": "Evolution Devolution Revolution",
            "date": "1999",
            "genre": "Metal"
        }
    }
}
始于初秋 2025-01-04 11:51:12

使用G-Spot 来检测信息。

此处获取

Use G-Spot to detect the information.

Get it here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文