Skip to content

Commit

Permalink
Do not write invalid packet duration
Browse files Browse the repository at this point in the history
Configuration packets have no PTS. Do not compute a packet duration from
their PTS.

Fixes recording in mp4 on device rotation.
  • Loading branch information
rom1v committed Nov 13, 2019
1 parent af3027a commit 198d478
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/src/recorder.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,12 @@ run_recorder(void *data) {
continue;
}

// we now know the duration of the previous packet
previous->packet.duration = rec->packet.pts - previous->packet.pts;
// config packets have no PTS, we must ignore them
if (rec->packet.pts != AV_NOPTS_VALUE
&& previous->packet.pts != AV_NOPTS_VALUE) {
// we now know the duration of the previous packet
previous->packet.duration = rec->packet.pts - previous->packet.pts;
}

bool ok = recorder_write(recorder, &previous->packet);
record_packet_delete(previous);
Expand Down

0 comments on commit 198d478

Please sign in to comment.