Patch for programs with empty audio/video streams

  Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
joaopp Offline
Junior Member
Posts: 5
Joined: Aug 2017
Reputation: 1
Post: #1
With this patch when the first program has empty audio/video stream, it will search other programs until it find a non empty audio/video stream:

Code:
diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
index f182509296..79c4d8e102 100644
--- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
+++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
@@ -1281,9 +1281,15 @@ void CDVDDemuxFFmpeg::CreateStreams(unsigned int program)
     // look for first non empty stream and discard nonselected programs
     for (unsigned int i = 0; i < m_pFormatContext->nb_programs; i++)
     {
-      if(m_program == UINT_MAX && m_pFormatContext->programs[i]->nb_stream_indexes > 0)
+      for (unsigned int j = 0; m_program == UINT_MAX && j < m_pFormatContext->programs[i]->nb_stream_indexes; j++)
       {
-        m_program = i;
+        int idx = m_pFormatContext->programs[i]->stream_index[j];
+        AVStream *st = m_pFormatContext->streams[idx];
+        if ((st->codec->codec_type == AVMEDIA_TYPE_VIDEO && st->codec_info_nb_frames > 0) ||
+            (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->codec->sample_rate > 0))
+        {
+          m_program = i;
+        }
       }

       if(i != m_program)
(This post was last modified: 2017-08-09 18:59 by joaopp.)
find quote
negge Offline
yo guysv7may bd latr tomorroe
Posts: 3,719
Joined: Dec 2010
Reputation: 53
Location: Finland
Post: #2
Could you submit a PR on GitHub instead?
find quote
joaopp Offline
Junior Member
Posts: 5
Joined: Aug 2017
Reputation: 1
Post: #3
(2017-08-10 15:28)negge Wrote:  Could you submit a PR on GitHub instead?
Done https://github.com/xbmc/xbmc/pull/12655
find quote
negge Offline
yo guysv7may bd latr tomorroe
Posts: 3,719
Joined: Dec 2010
Reputation: 53
Location: Finland
Post: #4
Open source at its finest!
find quote