-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
fix mp4 stts box bug. #4190
fix mp4 stts box bug. #4190
Conversation
|
||
|
||
// skip any SEI type nalus | ||
if (format->vcodec->id == SrsVideoCodecIdAVC) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need process HEVC?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HEVC added.
trunk/src/kernel/srs_kernel_mp4.cpp
Outdated
if (stts && previous) { | ||
if (sample->dts >= previous->dts && previous->nb_subsamples > 0) { | ||
uint32_t delta = (uint32_t)(sample->dts - previous->dts) / previous->nb_subsamples; | ||
stts_entry.sample_count = previous->nb_subsamples; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sample in samples is an audio/video frame, nb_subsamples is the nalu count of this frame.
In most cases, it is always one nalu in one frame, but in multi-slice frames, there is more than one nalu in one video frame.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nb_subsamples
is a mistake. revert this code.
1. fix stts box calculation; 2. filter nalu SEI for h.265 codec.
|
||
if (avc_nalu_type == SrsAvcNaluTypeSEI) { | ||
return err; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the video frame is [SEI P], will it drop? SEI always appears in Harward encoders like video toolbox, Nvidia enc, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed on #4201
How to reproduce?
./objs/srs -c conf/dvr.mp4.conf
ffmpeg -re -i output.flv -c copy -f flv rtmp://localhost/live/livestream
the
output.flv
is recorded from a DJI drone, download from this google drive link: https://drive.google.com/file/d/1IVoDXI-WYoIlKiyzs65fCsDRRt0z-EuU/view?usp=sharinglivestream.*.mp4
located intrunk/objs/nginx/html/live
.Cause
The Mp4 frame rate is determined by mp4 box:
mdhd
andstts
. But thestts
encoding in srs has bugs. The aboveoutput.flv
video file has a lot ofSEI
type of nalu, which is not video samples, SRS can't calculate thestts
correctly.How to calculate
stts
?check doc ISO/IEC 14496-12:2012(E) 8.6.1.2 Decoding Time to Sample Box.
https://ossrs.net/lts/zh-cn/assets/files/ISO_IEC_14496-12-base-format-2012-b70dd5f101daecd072700609842c9649.pdf
video source generated by OBS with ultrafast + zerolatency
https://drive.google.com/file/d/1rXipV93EWmtZ-rPShwE66f5aO85ugiIc/view?usp=sharing
Use this source, with video frames split to multi slices, to verify the dvr recorded mp4.