Skip to content

Commit

Permalink
fix crash changing video stream of video-only file
Browse files Browse the repository at this point in the history
  • Loading branch information
ddennedy committed Sep 1, 2023
1 parent f7adc15 commit 714a7da
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/modules/avformat/producer_avformat.c
Original file line number Diff line number Diff line change
Expand Up @@ -996,15 +996,17 @@ static int setup_filters(producer_avformat self)
static void set_up_discard(producer_avformat self, int audio_index, int video_index)
{
// The open_mutex must be locked when this function is called
for (int x = 0; x < self->audio_format->nb_streams; x++) {
if (audio_index == INT_MAX || x == audio_index
|| (self->audio_format == self->video_format && x == video_index))
self->audio_format->streams[x]->discard = AVDISCARD_DEFAULT;
else
self->audio_format->streams[x]->discard = AVDISCARD_ALL;
if (self->audio_format) {
for (int x = 0; x < self->audio_format->nb_streams; x++) {
if (audio_index == INT_MAX || x == audio_index
|| (self->audio_format == self->video_format && x == video_index))
self->audio_format->streams[x]->discard = AVDISCARD_DEFAULT;
else
self->audio_format->streams[x]->discard = AVDISCARD_ALL;
}
}

if (self->audio_format != self->video_format) {
if (self->video_format && self->video_format != self->audio_format) {
for (int x = 0; x < self->video_format->nb_streams; x++) {
if (x == video_index)
self->video_format->streams[x]->discard = AVDISCARD_DEFAULT;
Expand Down

0 comments on commit 714a7da

Please sign in to comment.