-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Android MP4文件写入 #360
Comments
构造部分:
写入部分: void MP4Muxer::write_video_data(uint8_t *buffer, AMediaCodecBufferInfo *info) {
int flags = 0;
if (unlikely((info->flags & 1) != 0)) {
flags = MOV_AV_FLAG_KEYFREAME;
}
shared_lock<shared_mutex> lock{_m};
if (unlikely(track_id_invalid())) {
_cv.wait(lock, [=]() -> bool {
return !track_id_invalid();
});
}
hxxx_iterator_ctx_t ctx;
hxxx_iterator_init(&ctx, buffer + info->offset, info->size, 0);
const uint8_t *p_nal;
size_t i_nal;
int64_t pts = info->presentationTimeUs;
while (hxxx_annexb_iterate_next(&ctx, &p_nal, &i_nal)) {
mov_writer_write(mov_write.get(), video_track_id, p_nal, i_nal, pts, pts, flags);
}
} |
mov_flags值是什么,有没有包含FastStart? FastStart Flag会在mp4文件结束时,把moov移动到文件头部,会导致整个mp4文件重写一遍。 可以尝试去掉FastStart标记后再试试。 |
在去掉MOV_FLAG_FASTSTART后,确实是可以快速关闭了
但是出现了moov atom not found的情况 |
附上生成的视频文件 2024-11-08_16_49_29.mp4 |
MOV_FLAG_SEGMENT 这个是生成fmp4的,普通文件没必要用这些参数。 如果不太明确每个参数的作用,可以参考libmov/test目录下的例子,或者把flags设置成0。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
我在Android上使用了该库,但是目前出现了一个问题我不知道是否正常。
关闭mp4写入时会调用mov_writer_destroy,但是几乎需要很长时间都没有执行完该函数。我想知道如何优化或者是什么原因导致的呢?
火焰图如下
The text was updated successfully, but these errors were encountered: