Move last packet recording

Write the last packet at the end.
pull/3757/head
Romain Vimont 1 year ago
parent 3c407773e9
commit 4b246cd963

@ -220,19 +220,6 @@ sc_recorder_process_packets(struct sc_recorder *recorder) {
if (recorder->stopped && sc_queue_is_empty(&recorder->queue)) {
sc_mutex_unlock(&recorder->mutex);
struct sc_record_packet *last = previous;
if (last) {
// assign an arbitrary duration to the last packet
last->packet->duration = 100000;
bool ok = sc_recorder_write(recorder, last->packet);
if (!ok) {
// failing to write the last frame is not very serious, no
// future frame may depend on it, so the resulting file
// will still be valid
LOGW("Could not record last packet");
}
sc_record_packet_delete(last);
}
break;
}
@ -283,6 +270,21 @@ sc_recorder_process_packets(struct sc_recorder *recorder) {
return false;
}
// Write the last packet
struct sc_record_packet *last = previous;
if (last) {
// assign an arbitrary duration to the last packet
last->packet->duration = 100000;
bool ok = sc_recorder_write(recorder, last->packet);
if (!ok) {
// failing to write the last frame is not very serious, no
// future frame may depend on it, so the resulting file
// will still be valid
LOGW("Could not record last packet");
}
sc_record_packet_delete(last);
}
int ret = av_write_trailer(recorder->ctx);
if (ret < 0) {
LOGE("Failed to write trailer to %s", recorder->filename);

Loading…
Cancel
Save