【问题标题】:Why won't some MP4 videos start streaming until the entire file is downloaded? [duplicate]为什么某些 MP4 视频在整个文件下载完成后才开始流式传输? [复制]
【发布时间】:2012-01-05 14:25:06
【问题描述】:

我正在开发一个应用程序,用户上传视频并使用 jwplayer、jplayer、flowplayer 等在浏览器中播放。有些视频会立即播放,而有些则等到整个视频文件下载完毕。

我正在使用 ffmpeg 将视频转换为 mp4 格式。

以下是我尝试的其中一个视频文件的一些详细信息。

General
Complete name                    : 429183132058337290450_AutoFF.mp4
Format                           : MPEG-4
Format profile                   : Base Media
Codec ID                         : isom
File size                        : 10.2 MiB
Duration                         : 24s 333ms
Overall bit rate                 : 3 501 Kbps

Video
ID                               : 1
Format                           : AVC
Format/Info                      : Advanced Video Codec
Format profile                   : High@L4.1
Format settings, CABAC           : Yes
Format settings, ReFrames        : 3 frames
Codec ID                         : avc1
Codec ID/Info                    : Advanced Video Coding
Duration                         : 24s 333ms
Bit rate mode                    : Variable
Bit rate                         : 3 351 Kbps
Width                            : 1 024 pixels
Height                           : 560 pixels
Display aspect ratio             : 16:9
Frame rate mode                  : Constant
Frame rate                       : 30.000 fps
Color space                      : YUV
Chroma subsampling               : 4:2:0
Bit depth                        : 8 bits
Scan type                        : Progressive
Bits/(Pixel*Frame)               : 0.195
Stream size                      : 9.72 MiB (96%)
Language                         : Japanese

【问题讨论】:

    标签: php video ffmpeg encode


    【解决方案1】:

    我也遇到了一些 MP4 视频的问题。我正在将上传的视频转换为 mp4 (h.264 + aac),它们不会缓冲。原因是这种格式包含文件末尾播放所需的一些重要元数据,因此必须在播放开始之前加载整个文件。解决方案是在转换结果上使用一个名为qt-faststart (https://github.com/danielgtaylor/qtfaststart) 的小程序。该程序将此元数据重新定位到文件的开头,从而可以进行渐进式下载播放。

    【讨论】:

      【解决方案2】:

      在使用 ffmpeg 创建 MP4 视频时,我遇到过同样的问题很长时间 - 最终奏效的只是将 preload="metadata" 添加到 html5 标签:

      <video preload="metadata"><source src="..." /></video>
      

      【讨论】:

        【解决方案3】:

        ffmpeg-movflags +faststart 选项一起使用。这会将moov 原子重新定位到文件的开头,从而允许客户端开始播放,而无需先完全下载文件。

        您可以在编码命令中使用它,也可以将其与现有文件一起使用并简单地重新复用:

        ffmpeg -i input.mp4 -c copy -movflags +faststart output.mp4
        

        【讨论】:

          猜你喜欢
          • 2015-06-29
          • 1970-01-01
          • 1970-01-01
          • 2018-03-01
          • 2016-01-28
          • 1970-01-01
          • 1970-01-01
          • 2016-01-17
          • 2023-03-31
          相关资源
          最近更新 更多