HTML5 视频播放器一些 mp4 文件无法播放 chrome
HTML5 video player some mp4 files not playing chrome
所以我正在尝试构建一个个人流媒体平台,并且我已尽最大努力遵循我在任何地方发现的建议,以便在流媒体时更好地compatibility/quality。
所以我使用以下命令将我的视频系统地编码为带有 mp4 容器和 ffmpeg 的视频编解码器 h264:
ffmpeg -i input -vcodec libx264 -maxrate 8000k -bufsize 1000K -minrate 10k -crf 24 -ab 192k -movflags faststart output.mp4
然而,我偶尔会遇到一些不太情愿的 mp4,这些 mp4 在 Edge 和 Firefox 上可以正常播放,但在 Chrome 上却不行。加载似乎处理得很好,因为我可以在控件中看到总持续时间,但它永远不会播放,也不会在控制台中留下任何错误。
这是这种不情愿的文件的 Mediainfo 导出:
Format : MPEG-4
Format profile : Base Media
Codec ID : isom (isom/iso2/avc1/mp41)
File size : 1.04 GiB
Duration : 1 h 21 min
Overall bit rate : 1 832 kb/s
Writing application : Lavf57.56.101
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L4
Format settings : CABAC / 4 Ref Frames
Format settings, CABAC : Yes
Format settings, Reference frames : 4 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 1 h 21 min
Bit rate : 1 634 kb/s
Width : 1 912 pixels
Height : 1 032 pixels
Display aspect ratio : 1.85:1
Frame rate mode : Constant
Frame rate : 24.000 FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.035
Stream size : 953 MiB (89%)
Writing library : x264 core 148 r2748 97eaef2
Encoding settings : cabac=1 / ref=3 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=9 / lookahead_threads=1 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=24 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=crf / mbtree=1 / crf=24.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / vbv_maxrate=8000 / vbv_bufsize=1000 / crf_max=0.0 / nal_hrd=none / filler=0 / ip_ratio=1.40 / aq=1:1.00
Language : French
Menus : 3
Codec configuration box : avcC
Audio
ID : 2
Format : AAC LC
Format/Info : Advanced Audio Codec Low Complexity
Codec ID : mp4a-40-2
Duration : 1 h 21 min
Bit rate mode : Constant
Bit rate : 192 kb/s
Channel(s) : 6 channels
Channel layout : C L R Ls Rs LFE
Sampling rate : 48.0 kHz
Frame rate : 46.875 FPS (1024 SPF)
Compression mode : Lossy
Stream size : 112 MiB (11%)
Language : French
Default : Yes
Alternate group : 1
Menus : 3
Menu #1
ID : 3
Codec ID : text
Duration : 1 h 21 min
Language : English
Bit rate mode : CBR
Menu For : 1,2
00:00:00.000 : Chapitre 01
00:08:39.000 : Chapitre 02
00:15:10.000 : Chapitre 03
00:24:47.000 : Chapitre 04
00:33:39.000 : Chapitre 05
00:43:38.000 : Chapitre 06
00:50:51.000 : Chapitre 07
00:59:13.000 : Chapitre 08
01:08:01.000 : Chapitre 09
01:14:06.000 : Chapitre 10
Bit rate mode : Constant
Menu #2
00:00:00.000 : Chapitre 01
00:08:39.000 : Chapitre 02
00:15:10.000 : Chapitre 03
00:24:47.000 : Chapitre 04
00:33:39.000 : Chapitre 05
00:43:38.000 : Chapitre 06
00:50:51.000 : Chapitre 07
00:59:13.000 : Chapitre 08
01:08:01.000 : Chapitre 09
01:14:06.000 : Chapitre 10
提前感谢您提供的任何宝贵提示
很奇怪,我设法解决了这个问题,尽管我仍然不明白为什么。
我注意到我的服务器的另一个问题是我无法在视频中寻找特定点。
运行 debian stretch arm64 下的 apache2 服务器我发现开箱即用的字节范围不被接受。
我启用了 apache2 mod header 并添加了:
Header set Accept-Ranges bytes
到我的 apache2.conf 文件。
我解决了搜索问题,但也解决了无法播放 mp4 文件的问题!
出于好奇,如果有人可以解释这两件事之间的关系(假设其他 mp4 文件播放得很好),我将不胜感激。
还不能发表评论,否则我会把它放在评论中。
在您的命令行中使用 -v verbose 来查看是否有任何与 faststart 设置相关的问题导致您出现问题。比如..一个不正确的选项。
-movflags +faststart
ffmpeg 是如何描述命令用法的。
https://trac.ffmpeg.org/wiki/Encode/H.264
所以我正在尝试构建一个个人流媒体平台,并且我已尽最大努力遵循我在任何地方发现的建议,以便在流媒体时更好地compatibility/quality。
所以我使用以下命令将我的视频系统地编码为带有 mp4 容器和 ffmpeg 的视频编解码器 h264:
ffmpeg -i input -vcodec libx264 -maxrate 8000k -bufsize 1000K -minrate 10k -crf 24 -ab 192k -movflags faststart output.mp4
然而,我偶尔会遇到一些不太情愿的 mp4,这些 mp4 在 Edge 和 Firefox 上可以正常播放,但在 Chrome 上却不行。加载似乎处理得很好,因为我可以在控件中看到总持续时间,但它永远不会播放,也不会在控制台中留下任何错误。
这是这种不情愿的文件的 Mediainfo 导出:
Format : MPEG-4
Format profile : Base Media
Codec ID : isom (isom/iso2/avc1/mp41)
File size : 1.04 GiB
Duration : 1 h 21 min
Overall bit rate : 1 832 kb/s
Writing application : Lavf57.56.101
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L4
Format settings : CABAC / 4 Ref Frames
Format settings, CABAC : Yes
Format settings, Reference frames : 4 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 1 h 21 min
Bit rate : 1 634 kb/s
Width : 1 912 pixels
Height : 1 032 pixels
Display aspect ratio : 1.85:1
Frame rate mode : Constant
Frame rate : 24.000 FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.035
Stream size : 953 MiB (89%)
Writing library : x264 core 148 r2748 97eaef2
Encoding settings : cabac=1 / ref=3 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=9 / lookahead_threads=1 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=24 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=crf / mbtree=1 / crf=24.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / vbv_maxrate=8000 / vbv_bufsize=1000 / crf_max=0.0 / nal_hrd=none / filler=0 / ip_ratio=1.40 / aq=1:1.00
Language : French
Menus : 3
Codec configuration box : avcC
Audio
ID : 2
Format : AAC LC
Format/Info : Advanced Audio Codec Low Complexity
Codec ID : mp4a-40-2
Duration : 1 h 21 min
Bit rate mode : Constant
Bit rate : 192 kb/s
Channel(s) : 6 channels
Channel layout : C L R Ls Rs LFE
Sampling rate : 48.0 kHz
Frame rate : 46.875 FPS (1024 SPF)
Compression mode : Lossy
Stream size : 112 MiB (11%)
Language : French
Default : Yes
Alternate group : 1
Menus : 3
Menu #1
ID : 3
Codec ID : text
Duration : 1 h 21 min
Language : English
Bit rate mode : CBR
Menu For : 1,2
00:00:00.000 : Chapitre 01
00:08:39.000 : Chapitre 02
00:15:10.000 : Chapitre 03
00:24:47.000 : Chapitre 04
00:33:39.000 : Chapitre 05
00:43:38.000 : Chapitre 06
00:50:51.000 : Chapitre 07
00:59:13.000 : Chapitre 08
01:08:01.000 : Chapitre 09
01:14:06.000 : Chapitre 10
Bit rate mode : Constant
Menu #2
00:00:00.000 : Chapitre 01
00:08:39.000 : Chapitre 02
00:15:10.000 : Chapitre 03
00:24:47.000 : Chapitre 04
00:33:39.000 : Chapitre 05
00:43:38.000 : Chapitre 06
00:50:51.000 : Chapitre 07
00:59:13.000 : Chapitre 08
01:08:01.000 : Chapitre 09
01:14:06.000 : Chapitre 10
提前感谢您提供的任何宝贵提示
很奇怪,我设法解决了这个问题,尽管我仍然不明白为什么。
我注意到我的服务器的另一个问题是我无法在视频中寻找特定点。
运行 debian stretch arm64 下的 apache2 服务器我发现开箱即用的字节范围不被接受。
我启用了 apache2 mod header 并添加了:
Header set Accept-Ranges bytes
到我的 apache2.conf 文件。
我解决了搜索问题,但也解决了无法播放 mp4 文件的问题! 出于好奇,如果有人可以解释这两件事之间的关系(假设其他 mp4 文件播放得很好),我将不胜感激。
还不能发表评论,否则我会把它放在评论中。
在您的命令行中使用 -v verbose 来查看是否有任何与 faststart 设置相关的问题导致您出现问题。比如..一个不正确的选项。
-movflags +faststart
ffmpeg 是如何描述命令用法的。
https://trac.ffmpeg.org/wiki/Encode/H.264