Skip to content

Add estimated track duration for RTSP streams. - #1

Open
jkeller-miovision wants to merge 1 commit into
segment-fixfrom
concat-fix
Open

Add estimated track duration for RTSP streams.#1
jkeller-miovision wants to merge 1 commit into
segment-fixfrom
concat-fix

Conversation

@jkeller-miovision

Copy link
Copy Markdown

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.

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.
Comment thread libavformat/movenc.c
"this case.\n",
pkt->stream_index, pkt->dts);
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow. This is quite the function!

Comment thread libavformat/movenc.c
MOVMuxContext *mov = s->priv_data;
MOVTrack *trk = &mov->tracks[pkt->stream_index];
int64_t ref;
uint64_t duration;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused var?

Comment thread libavformat/movenc.c
uint64_t duration;

if (trk->entry) {
ref = trk->cluster[trk->entry - 1].dts;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any chance [trk->entry - 1] will not be valid? first frame?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's probably what the if(trk->entry) is about, isn't it?

Comment thread libavformat/movenc.c
&& !trk->frag_discont) {
ref = trk->start_dts + trk->track_duration;
} else
ref = pkt->pts; // Skip tests for the first packet

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bracketless else clause, or is the github UI messing with me?

Comment thread libavformat/movenc.c
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;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IDK what's going on here 🤷‍♂️

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

Successfully merging this pull request may close these issues.

2 participants