Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

首个moof的default_sample_duration为0,导致浏览器播放fmp4首个GOP失败 #285

Open
v354412101 opened this issue Jun 6, 2023 · 6 comments

Comments

@v354412101
Copy link

v354412101 commented Jun 6, 2023

我在chrome浏览器播放流式fmp4数据时,会出现首个gop数据播放失败,原因是首个moof的default_sample_duration为0导致的。

https://github.com/ireader/media-server/blob/671c6618772a31e3201d6628b4cf50fb7bf8de3d/libmov/source/fmp4-writer.c#LL415C39-L415C39

int fmp4_writer_write(struct fmp4_writer_t* writer, int idx, const void* data, size_t bytes, int64_t pts, int64_t dts, int flags) {
    ......
    duration = dts > track->last_dts && INT64_MIN != track->last_dts ? dts - track->last_dts : 0;
}

如果首帧的dts为0,track->last_dts也为0,所以duration也为0

因为moof表示一个视频段,所以default_sample_duration不应该为0,即便moof里只有一帧数据,对于25fps的视频流default_sample_duration最小也是40,不应该为0

@v354412101
Copy link
Author

我的修改思路是:

int fmp4_writer_write(struct fmp4_writer_t* writer, int idx, const void* data, size_t bytes, int64_t pts, int64_t dts, int flags) {
    ......
    duration = dts > track->last_dts && INT64_MIN != track->last_dts ? dts - track->last_dts : 0;
    if(duration <= 0) {
        duration = 40;
    }
}

@gcy111
Copy link

gcy111 commented Mar 18, 2024

怎么排查出来fmp4播放是因为这个default_sample_duration为0的?

@v354412101
Copy link
Author

怎么排查出来fmp4播放是因为这个default_sample_duration为0的?

用ffmpeg生成一段可以秒开的fmp4文件,
用libmov生成一段不能秒开的fmp4文件,
然后用mp4box对比,就会发现libmov生成的fmp4文件default_sample_duration有问题。

@gcy111
Copy link

gcy111 commented Mar 28, 2024

我按这个修改了,没有好

@ireader
Copy link
Owner

ireader commented Mar 28, 2024

我按这个修改了,没有好

把mp4文件上传下?

@gcy111
Copy link

gcy111 commented Apr 21, 2024

Uploading 017721038891_1_1713681945suffix.mp4…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants