ffmpeg - MP4 容器中的 H.264 编码流在 WMP12 Windows 7 中无法正常播放

标签 ffmpeg windows-7 mp4 h.264 wmp

我想弄清楚为什么我在 MP4 容器中的 H.264 编码流无法在 Windows 7 的 Window Media Player 12 中正确播放。该文件在 VLC 和其他播放器(包括 Windows 10 的 WMP)中播放良好,但我只是想知道为什么 Win 7 中的 WMP12 不播放它。

似乎只显示了 I 型帧,并显示了空白的黑色帧,而不是介于两者之间的所有 P 型帧。如果我强制我的设备编码器仅生成 I 型帧,则文件在 WMP12(Win 7)中可以正常播放,但文件大小增加太多。 Windows 7 中 H.264 解码器的限制是什么?

我在下面添加 ffprobe -show_frames video.mp4 (只有几帧,但 ffprobe 没有报告错误):

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.83.100
  Duration: 00:00:05.51, start: 0.024000, bitrate: 513 kb/s
    Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 720x480, 510 kb/s, 30.11 fps, 59.94 tbr, 90k tbn, 180k tbc (default)
    Metadata:
      handler_name    : VideoHandler
[FRAME]
media_type=video
stream_index=0
key_frame=1
pkt_pts=2160
pkt_pts_time=0.024000
pkt_dts=2160
pkt_dts_time=0.024000
best_effort_timestamp=2160
best_effort_timestamp_time=0.024000
pkt_duration=2340
pkt_duration_time=0.026000
pkt_pos=48
pkt_size=2979
width=720
height=480
pix_fmt=yuv420p
sample_aspect_ratio=N/A
pict_type=I
coded_picture_number=0
display_picture_number=0
interlaced_frame=0
top_field_first=0
repeat_pict=0
[/FRAME]
[FRAME]
media_type=video
stream_index=0
key_frame=0
pkt_pts=4500
pkt_pts_time=0.050000
pkt_dts=4500
pkt_dts_time=0.050000
best_effort_timestamp=4500
best_effort_timestamp_time=0.050000
pkt_duration=4320
pkt_duration_time=0.048000
pkt_pos=3027
pkt_size=1662
width=720
height=480
pix_fmt=yuv420p
sample_aspect_ratio=N/A
pict_type=P
coded_picture_number=1
display_picture_number=0
interlaced_frame=0
top_field_first=0
repeat_pict=0
[/FRAME]
[FRAME]
media_type=video
stream_index=0
key_frame=0
pkt_pts=8820
pkt_pts_time=0.098000
pkt_dts=8820
pkt_dts_time=0.098000
best_effort_timestamp=8820
best_effort_timestamp_time=0.098000
pkt_duration=3060
pkt_duration_time=0.034000
pkt_pos=4689
pkt_size=1073
width=720
height=480
pix_fmt=yuv420p
sample_aspect_ratio=N/A
pict_type=P
coded_picture_number=2
display_picture_number=0
interlaced_frame=0
top_field_first=0
repeat_pict=0
[/FRAME]
[FRAME]
media_type=video
stream_index=0
key_frame=0
pkt_pts=11880
pkt_pts_time=0.132000
pkt_dts=11880
pkt_dts_time=0.132000
best_effort_timestamp=11880
best_effort_timestamp_time=0.132000
pkt_duration=2970
pkt_duration_time=0.033000
pkt_pos=5762
pkt_size=829
width=720
height=480
pix_fmt=yuv420p
sample_aspect_ratio=N/A
pict_type=P
coded_picture_number=3
display_picture_number=0
interlaced_frame=0
top_field_first=0
repeat_pict=0
[/FRAME]
[FRAME]
media_type=video
stream_index=0
key_frame=0
pkt_pts=14850
pkt_pts_time=0.165000
pkt_dts=14850
pkt_dts_time=0.165000
best_effort_timestamp=14850
best_effort_timestamp_time=0.165000
pkt_duration=3060
pkt_duration_time=0.034000
pkt_pos=6591
pkt_size=987
width=720
height=480
pix_fmt=yuv420p
sample_aspect_ratio=N/A
pict_type=P
coded_picture_number=4
display_picture_number=0
interlaced_frame=0
top_field_first=0
repeat_pict=0
[/FRAME]
[FRAME]
media_type=video
stream_index=0
key_frame=0
pkt_pts=17910
pkt_pts_time=0.199000
pkt_dts=17910
pkt_dts_time=0.199000
best_effort_timestamp=17910
best_effort_timestamp_time=0.199000
pkt_duration=2970
pkt_duration_time=0.033000
pkt_pos=7578
pkt_size=1344
width=720
height=480
pix_fmt=yuv420p
sample_aspect_ratio=N/A
pict_type=P
coded_picture_number=5
display_picture_number=0
interlaced_frame=0
top_field_first=0
repeat_pict=0
[/FRAME]
[FRAME]
media_type=video
stream_index=0
key_frame=0
pkt_pts=20880
pkt_pts_time=0.232000
pkt_dts=20880
pkt_dts_time=0.232000
best_effort_timestamp=20880
best_effort_timestamp_time=0.232000
pkt_duration=2970
pkt_duration_time=0.033000
pkt_pos=8922
pkt_size=1850
width=720
height=480
pix_fmt=yuv420p
sample_aspect_ratio=N/A
pict_type=P
coded_picture_number=6
display_picture_number=0
interlaced_frame=0
top_field_first=0
repeat_pict=0
[/FRAME]
[FRAME]
media_type=video
stream_index=0
key_frame=0
pkt_pts=23850
pkt_pts_time=0.265000
pkt_dts=23850
pkt_dts_time=0.265000
best_effort_timestamp=23850
best_effort_timestamp_time=0.265000
pkt_duration=3060
pkt_duration_time=0.034000
pkt_pos=10772
pkt_size=1972
width=720
height=480
pix_fmt=yuv420p
sample_aspect_ratio=N/A
pict_type=P
coded_picture_number=7
display_picture_number=0
interlaced_frame=0
top_field_first=0
repeat_pict=0
[/FRAME]

如果您在这些帧中发现任何可能影响播放的错误,请告诉我。

使用 Freescale libimxvpuapi 创建编码的 H.264 流,使用 ffmpeg 创建 MP4 容器。

有关文件的更多信息:
exiftool video.mp4 
ExifTool Version Number         : 10.10
File Name                       : video.mp4
Directory                       : .
File Size                       : 346 kB
File Modification Date/Time     : 2018:10:02 11:27:20+02:00
File Access Date/Time           : 2018:10:02 11:41:14+02:00
File Inode Change Date/Time     : 2018:10:02 11:27:21+02:00
File Permissions                : rw-r--r--
File Type                       : MP4
File Type Extension             : mp4
MIME Type                       : video/mp4
Major Brand                     : MP4  Base Media v1 [IS0 14496-12:2003]
Minor Version                   : 0.2.0
Compatible Brands               : isom, iso2, avc1, mp41
Movie Data Size                 : 351479
Movie Data Offset               : 48
Movie Header Version            : 0
Create Date                     : 0000:00:00 00:00:00
Modify Date                     : 0000:00:00 00:00:00
Time Scale                      : 1000
Duration                        : 5.51 s
Preferred Rate                  : 1
Preferred Volume                : 100.00%
Preview Time                    : 0 s
Preview Duration                : 0 s
Poster Time                     : 0 s
Selection Time                  : 0 s
Selection Duration              : 0 s
Current Time                    : 0 s
Next Track ID                   : 2
Track Header Version            : 0
Track Create Date               : 0000:00:00 00:00:00
Track Modify Date               : 0000:00:00 00:00:00
Track ID                        : 1
Track Duration                  : 5.51 s
Track Layer                     : 0
Track Volume                    : 0.00%
Matrix Structure                : 1 0 0 0 1 0 0 0 1
Image Width                     : 720
Image Height                    : 480
Media Header Version            : 0
Media Create Date               : 0000:00:00 00:00:00
Media Modify Date               : 0000:00:00 00:00:00
Media Time Scale                : 90000
Media Duration                  : 5.51 s
Media Language Code             : und
Handler Description             : VideoHandler
Graphics Mode                   : srcCopy
Op Color                        : 0 0 0
Compressor ID                   : avc1
Source Image Width              : 720
Source Image Height             : 480
X Resolution                    : 72
Y Resolution                    : 72
Bit Depth                       : 24
Video Frame Rate                : 30.109
Handler Type                    : Metadata
Handler Vendor ID               : Apple
Encoder                         : Lavf57.83.100
Avg Bitrate                     : 510 kbps
Image Size                      : 720x480
Megapixels                      : 0.346
Rotation                        : 0

非常感谢!

请在此处找到视频示例:

https://www.dropbox.com/s/zehqgqhd8ychy0t/video.mp4?dl=0

最佳答案

我发现如果我添加:

if (this->keyFrame) {
    pAVPacket->flags |= AV_PKT_FLAG_KEY;
}

然后该文件在 WMP Win 7 中也能很好地播放。我错过了关键帧的这个标志。

关于ffmpeg - MP4 容器中的 H.264 编码流在 WMP12 Windows 7 中无法正常播放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52606087/

相关文章:

ffmpeg - 在 UWAMP 上安装 ffmpeg 等

c# - 是否可以将 .NET 类转换为 COM 库类?

ffmpeg - .m4a 输出的默认格式是什么?

audio - 仅从源mp4链接下载音频

android - 停止/取消执行 FFmpeg 命令

c++ - FFmpeg 在运行时更改音频过滤器参数

FFMPEG - 剪辑视频导致剪辑时间更长

java - 违反 UNIQUE KEY 约束。无法在对象中插入重复的键

windows-7 - Android模拟器窗口顶栏超出屏幕

ffmpeg 无法转码并将输出提供给 -f mp4 的流