Skip to content

Commit

Permalink
LWLibavAudioSource: stream_index=-1 (#39)
Browse files Browse the repository at this point in the history
Use the default audio track instead the first one in order.
  • Loading branch information
Asd-g committed Jan 12, 2024
1 parent d90c186 commit 16e215f
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions common/lwindex.c
Original file line number Diff line number Diff line change
Expand Up @@ -2181,6 +2181,7 @@ static int create_index
fprintf( index, "<ActiveVideoStreamIndex>%+011d</ActiveVideoStreamIndex>\n", -1 );
audio_index_pos = ftell( index );
fprintf( index, "<ActiveAudioStreamIndex>%+011d</ActiveAudioStreamIndex>\n", adhp->stream_index );
fprintf(index, "<DefaultAudioStreamIndex>%+011d</DefaultAudioStreamIndex>\n", -1);
}
AVPacket pkt = { 0 };
int pix_fmt_investigated = 0;
Expand Down Expand Up @@ -2466,6 +2467,7 @@ static int create_index
int32_t current_pos = ftell( index );
fseek( index, audio_index_pos, SEEK_SET );
fprintf( index, "<ActiveAudioStreamIndex>%+011d</ActiveAudioStreamIndex>\n", pkt.stream_index );
fprintf(index, "<DefaultAudioStreamIndex>%+011d</DefaultAudioStreamIndex>\n", pkt.stream_index);
fseek( index, current_pos, SEEK_SET );
}
adhp->ctx = pkt_ctx;
Expand Down Expand Up @@ -2889,8 +2891,9 @@ static int parse_index
uint64_t file_hash = 0;
unsigned file_hash_32 = 0;
char format_name[256];
int active_video_index;
int active_audio_index;
const int active_video_index;
const int active_audio_index;
const int default_audio;
#ifdef _WIN32
wchar_t *wname = NULL;
struct _stat64 file_stat;
Expand Down Expand Up @@ -2938,7 +2941,8 @@ static int parse_index
return -1;
int32_t active_index_pos = ftell( index );
if( fscanf( index, "<ActiveVideoStreamIndex>%d</ActiveVideoStreamIndex>\n", &active_video_index ) != 1
|| fscanf( index, "<ActiveAudioStreamIndex>%d</ActiveAudioStreamIndex>\n", &active_audio_index ) != 1 )
|| fscanf( index, "<ActiveAudioStreamIndex>%d</ActiveAudioStreamIndex>\n", &active_audio_index ) != 1
|| fscanf( index, "<DefaultAudioStreamIndex>%d</DefaultAudioStreamIndex>\n", &default_audio ) != 1 )
return -1;
lwhp->format_name = format_name;
adhp->dv_in_avi = !strcmp( lwhp->format_name, "avi" ) ? -1 : 0;
Expand All @@ -2949,16 +2953,12 @@ static int parse_index
adhp->stream_index = opt->force_audio_index;
else
{
if (audio_present)
if (audio_present && default_audio != active_audio_index)
{
const int first_audio = ++active_video_index;
if (first_audio != active_audio_index)
{
#ifdef _WIN32
lw_free(wname);
lw_free(wname);
#endif // _WIN32
return -1;
}
return -1;
}
adhp->stream_index = active_audio_index;
}
Expand Down

0 comments on commit 16e215f

Please sign in to comment.