mp4视频在Quicktime/AVplayer与Chrome/Firefox上的不同时间开始播放 [英] mp4 video starts at different time on Quicktime/AVplayer vs Chrome/Firefox

查看:136
本文介绍了mp4视频在Quicktime/AVplayer与Chrome/Firefox上的不同时间开始播放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个很奇怪的问题.我的OSX应用程序正在基于屏幕投射生成mp4视频.出于某种原因,如果我在Quicktime或任何基于OSX的AVPlayer中打开此视频,它将在第0帧之前开始大约14-15帧.如果我使用Chrome或Firefox打开mp4,则实际上将在第0帧开始播放

I have a very strange issue. My OSX app is generating an mp4 video based on a screen cast. For some reason, if I open this video in Quicktime or any OSX-based AVPlayer, it will start about 14-15 frames in advance of frame 0. If I open the mp4 with Chrome or Firefox, it will actually start playing at frame 0.

什么可能导致忽略开始帧?这是计时器倒计时的屏幕截图,其中比较了零时的Quicktime与Firefox.请注意,Firefox播放器如何从9:55开始,而Quicktime播放器则跳至9:54.

What could cause this ignoring of beginning frames? Here's a screenshot of a timer countdown comparing Quicktime vs Firefox at time zero. Notice how the Firefox player starts at 9:55, while the Quicktime player skips ahead to 9:54.

这是我的示例mp4文件自己看看.

谢谢

推荐答案

这是一个有趣的问题,您的示例很好地说明了这种效果.

This is an interesting question and your example is a great illustration of the effect.

使用ffprobe查看上面链接到的文件会给出:

Using ffprobe to look at the file you linked to above gives:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'c44116b.mp4':
  Metadata:
    major_brand     : qt  
    minor_version   : 0
    compatible_brands: qt  
    creation_time   : 2015-04-25 15:54:30
  Duration: 00:00:03.70, start: 0.957000, bitrate: 1164 kb/s
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 480x360 [SAR 1:1 DAR 4:3], 899 kb/s, 22.99 fps, 22.99 tbr, 6k tbn, 12k tbc (default)
    Metadata:
      creation_time   : 2015-04-25 15:54:30
      handler_name    : Core Media Data Handler
      encoder         : H.264

您可以在这里看到ffprobe报告的开始"值为0.957000,这与您的1秒偏移量相对应.

You can see here that ffprobe is reporting a 'start' of 0.957000, which would correspond to your 1 second offset.

这不能解释为什么某些播放器遵守此规则,而其他播放器则忽略它(Windows Media Player似乎也从开头开始,而不是从偏移开始).更新:Roman在下面指出这是一种已知行为,并且已在ffmpeg列表中进行了讨论(请参阅Roman的答案).这可能归因于mp4容器格式的历史,该历史是从Apple QuickTime规范发展而来的.

This does not explain why certain players abide by this and others ignore it (Windows Media player also appears to start form the beginning, rather than the offset). UPDATE: Roman points out below that this is a known behaviour and it has been discussed on the ffmpeg list (see Roman's answer). This may be due to the history of the mp4 container format, which grew from the Apple QuickTime spec.

开始参数的目的似乎是为了同步而允许轨道偏移.为什么只有一个音轨会出现在视频中呢?

The purpose of the start parameter appears to be to allow a track be offset for synchronisation purposes. Why this would exist in your video with just one track is not clear.

更新:这可能是任何人想要的更多信息,但对于那些感兴趣的人...

UPDATE: This is probably more info that anyone wants, but for those interested...

在听完Roman的回答后,我使用MP4浏览器更详细地了解了mp4文件.由此我们可以首先看到电影的时标":

Following up on Roman's answer I took a look at the mp4 file in more detail using MP4 Browser. From this we can see firstly the 'timescale' of the movie:

然后是编辑原子(或在mp4世界中有时也称为原子的编辑框):

And then the edit atom (or edit box as atoms are also sometimes called in the mp4 world):

编辑原子中的时间字段告诉玩家跳过第一个5742个样本"并从此处开始.将此信息与时间刻度结合使用,可以告诉我们每秒有多少个样本,我们可以计算出应该延迟的时间:

The time field in the edit atom tells the player to skip the first 5742 'samples' and start from there. Using this info with the timescale, which tells us how many samples there are per second, we can calculate the time it should delay:

  • 5742/6000 = 0.957

这与ffprobe报告的开始时间"以及OP报告的延迟相对应.

This corresponds with the 'start time' that ffprobe reports and also with the delay that the OP reported.

这篇关于mp4视频在Quicktime/AVplayer与Chrome/Firefox上的不同时间开始播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆