Add estimated track duration for RTSP streams. - #1
Open
jkeller-miovision wants to merge 1 commit into
Open
Conversation
RTSP packets don't have the pkt->duration field populated. This causes the video track duration to be incorrect in the mp4 file (it is short by one frame duration). Estimate the packet duration when needed in order to set a believable track duration. This allows concatenation of two RTSP mp4 files have correct packet durations at the seams.
| "this case.\n", | ||
| pkt->stream_index, pkt->dts); | ||
| } | ||
|
|
Author
There was a problem hiding this comment.
wow. This is quite the function!
| MOVMuxContext *mov = s->priv_data; | ||
| MOVTrack *trk = &mov->tracks[pkt->stream_index]; | ||
| int64_t ref; | ||
| uint64_t duration; |
| uint64_t duration; | ||
|
|
||
| if (trk->entry) { | ||
| ref = trk->cluster[trk->entry - 1].dts; |
Author
There was a problem hiding this comment.
any chance [trk->entry - 1] will not be valid? first frame?
Author
There was a problem hiding this comment.
that's probably what the if(trk->entry) is about, isn't it?
| && !trk->frag_discont) { | ||
| ref = trk->start_dts + trk->track_duration; | ||
| } else | ||
| ref = pkt->pts; // Skip tests for the first packet |
Author
There was a problem hiding this comment.
bracketless else clause, or is the github UI messing with me?
| ref = trk->cluster[trk->entry - 1].dts; | ||
| } else if ( trk->start_dts != AV_NOPTS_VALUE | ||
| && !trk->frag_discont) { | ||
| ref = trk->start_dts + trk->track_duration; |
Author
There was a problem hiding this comment.
IDK what's going on here 🤷♂️
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RTSP packets don't have the pkt->duration field populated. This causes the video track duration to be incorrect in the mp4 file (it is short by one frame duration). Estimate the packet duration when needed in order to set a believable track duration. This allows concatenation of two RTSP mp4 files have correct packet durations at the seams.