Record at least video packets on stop
If the recorder is stopped while it has not received any audio packet yet, make sure the video stream is correctly recorded. PR #3757 <https://github.com/Genymobile/scrcpy/pull/3757>
This commit is contained in:
parent
80c0780b77
commit
17d5301c0f
1 changed files with 18 additions and 5 deletions
|
@ -249,8 +249,10 @@ sc_recorder_process_header(struct sc_recorder *recorder) {
|
||||||
sc_cond_wait(&recorder->queue_cond, &recorder->mutex);
|
sc_cond_wait(&recorder->queue_cond, &recorder->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sc_recorder_has_empty_queues(recorder)) {
|
if (sc_queue_is_empty(&recorder->video_queue)) {
|
||||||
assert(recorder->stopped);
|
assert(recorder->stopped);
|
||||||
|
// Don't process anything if there are not at least video packets (when
|
||||||
|
// the recorder is stopped)
|
||||||
sc_mutex_unlock(&recorder->mutex);
|
sc_mutex_unlock(&recorder->mutex);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -258,8 +260,9 @@ sc_recorder_process_header(struct sc_recorder *recorder) {
|
||||||
struct sc_record_packet *video_pkt;
|
struct sc_record_packet *video_pkt;
|
||||||
sc_queue_take(&recorder->video_queue, next, &video_pkt);
|
sc_queue_take(&recorder->video_queue, next, &video_pkt);
|
||||||
|
|
||||||
struct sc_record_packet *audio_pkt;
|
struct sc_record_packet *audio_pkt = NULL;
|
||||||
if (recorder->audio) {
|
if (!sc_queue_is_empty(&recorder->audio_queue)) {
|
||||||
|
assert(recorder->audio);
|
||||||
sc_queue_take(&recorder->audio_queue, next, &audio_pkt);
|
sc_queue_take(&recorder->audio_queue, next, &audio_pkt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,7 +283,7 @@ sc_recorder_process_header(struct sc_recorder *recorder) {
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (recorder->audio) {
|
if (audio_pkt) {
|
||||||
if (audio_pkt->packet->pts != AV_NOPTS_VALUE) {
|
if (audio_pkt->packet->pts != AV_NOPTS_VALUE) {
|
||||||
LOGE("The first audio packet is not a config packet");
|
LOGE("The first audio packet is not a config packet");
|
||||||
goto end;
|
goto end;
|
||||||
|
@ -305,7 +308,7 @@ sc_recorder_process_header(struct sc_recorder *recorder) {
|
||||||
|
|
||||||
end:
|
end:
|
||||||
sc_record_packet_delete(video_pkt);
|
sc_record_packet_delete(video_pkt);
|
||||||
if (recorder->audio) {
|
if (audio_pkt) {
|
||||||
sc_record_packet_delete(audio_pkt);
|
sc_record_packet_delete(audio_pkt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,6 +396,16 @@ sc_recorder_process_packets(struct sc_recorder *recorder) {
|
||||||
} else if (video_pkt && audio_pkt) {
|
} else if (video_pkt && audio_pkt) {
|
||||||
pts_origin =
|
pts_origin =
|
||||||
MIN(video_pkt->packet->pts, audio_pkt->packet->pts);
|
MIN(video_pkt->packet->pts, audio_pkt->packet->pts);
|
||||||
|
} else if (recorder->stopped) {
|
||||||
|
if (video_pkt) {
|
||||||
|
// The recorder is stopped without audio, record the video
|
||||||
|
// packets
|
||||||
|
pts_origin = video_pkt->packet->pts;
|
||||||
|
} else {
|
||||||
|
// Fail if there is no video
|
||||||
|
error = true;
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// We need both video and audio packets to initialize pts_origin
|
// We need both video and audio packets to initialize pts_origin
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in a new issue