ffmpeg is setting start_time to a negative value o

2019-09-02 04:19发布

We've been using an old version of ffmpeg for a while and now we need to upgrade to a more recent version (e.g. 2.6) and we have issues with it while converting .mov to .mp4.

For instance I have a .mov video file that has two streams, video and audio, both with start_time=0 and when I convert it using:

ffmpeg -i my_file.mov my_file.mp4

the output mp4 has an audio stream with start_time=-0.021333.

The FORMAT section, as shown by ffprobe -show_format -show_streams my_file.mp4 also has start_time=-0.021333

The previous version of ffmpeg we were using didn't have this issue...

When we play the output mp4 file in a web browser using < video > it's all good while playing but if we pause the video and seek here and there we notice that all the frames are off by 1. The first frame is duplicated and the last frame is missing!

In other words:

dom.currentTime = 0 shows the first frame
dom.currentTime = 1/24 (fps is 24) shows the first frame again
dom.currentTime = 2/24 shows the second frame instead of the third frame
dom.currentTime = 3/24 shows the third frame instead of the fourth frame
...

We believe this is caused by the field start_time=-0.021333

This is a major issue for us...

It's repro on chrome and firefox but somehow safari is not having issues with this...

After googling this we found that we're not the only one with this issue but it's not clear what the solution is.

Someone suggested to use the "-c:a copy" arguments and it worked on some files but gave an error on some others:

Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument

So this doesn't seem to be a robust solution...

Any help would be appreciated.

1条回答
劳资没心,怎么记你
2楼-- · 2019-09-02 04:48

You can try to avoid negative TS altogether

ffmpeg -i my_file.mov -avoid_negative_ts make_zero my_file.mp4

With your input file, I ran this command,

ffmpeg -i AnimalTrancoding_v001_Shot0020.mov out.mp4

Rrunning ffprobe on the output,

 ffprobe -show_entries format=start_time:stream=start_time -of compact out.mp4

I see

stream|start_time=0.000000
stream|start_time=0.000000
stream|start_time=0.000000
format|start_time=0.000000

A comparison the first few frames didn't show any duplication or drops with respect to the source.

I'm running a recent nightly build (May 2016).

查看更多
登录 后发表回答