Nevcairiel / LAVFilters

LAV Filters - Open-Source DirectShow Media Splitter and Decoders
GNU General Public License v2.0
7.44k stars 787 forks source link

Do not prefer an unsupported audio stream (iPhone 16) #620

Open clsid2 opened 5 days ago

clsid2 commented 5 days ago

Sample file: https://www.sendspace.com/file/5p09hb

Video recorded by iPhone 16. It contains two audio streams: AAC and apac (not yet supported by FFmpeg?).

The splitter selects the second track by default causing audio playback to fail. Turning off option to prefer best quality track solves that. But a better fix perhaps would be to ignore unknown/unsupported audio formats in the best track selection choice. Or just ignore this specific format if that is easier.

clsid2 commented 5 days ago

Quick fix

--- a/demuxer/Demuxers/LAVFDemuxer.cpp
+++ b/demuxer/Demuxers/LAVFDemuxer.cpp
@@ -3012,6 +3012,10 @@ const CBaseDemuxer::stream *CLAVFDemuxer::SelectAudioStream(std::list<std::strin
                 AVStream *old_stream = m_avFormat->streams[best->pid];
                 AVStream *new_stream = m_avFormat->streams[(*sit)->pid];

+                if (new_stream->codecpar->codec_id == 0) {
+                    continue;
+                }
+
                 int check_nb_f = av_lav_stream_codec_info_nb_frames(new_stream);
                 int best_nb_f = av_lav_stream_codec_info_nb_frames(old_stream);
                 if (m_bRM && (check_nb_f > 0 && best_nb_f <= 0))