summaryrefslogtreecommitdiff
path: root/src/lib/ffmpeg_stream.h
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-10-14 17:02:15 +0200
committerCarl Hetherington <cth@carlh.net>2025-10-15 22:33:26 +0200
commit2d8d05c2e7ad67ebac2ff250670a219a891d09ca (patch)
treed26660275365ab7e3576723a0ef7fd2d3f69406b /src/lib/ffmpeg_stream.h
parent4be14646eeb80bf51a6a86bf708446179a0416e9 (diff)
Disable use of stream IDs if there are duplicates, rather than rewriting.
It turns out that FFmpeg decoders (e.g. flv, see FFmpeg 25faaa311a74efdfdc4fed56996d7338ed807488) check stream IDs and sometimes create new streams if they see one that they didn't see before. If we change stream IDs we break this. Here we try to use stream indices in cases where the IDs are duplicated. We also account for the case where a new stream appears during examination. This wasn't covered by tests until the FFmpeg commit mentioned above, were the flv decoder creates a new stream during examination of boon_telly.mkv.
Diffstat (limited to 'src/lib/ffmpeg_stream.h')
-rw-r--r--src/lib/ffmpeg_stream.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/lib/ffmpeg_stream.h b/src/lib/ffmpeg_stream.h
index 0ed0b3be2..1583e5221 100644
--- a/src/lib/ffmpeg_stream.h
+++ b/src/lib/ffmpeg_stream.h
@@ -30,9 +30,10 @@ struct AVStream;
class FFmpegStream
{
public:
- FFmpegStream(std::string n, int i)
+ FFmpegStream(std::string n, int id, int index)
: name(n)
- , _id(i)
+ , _id(id)
+ , _index(index)
{}
explicit FFmpegStream(cxml::ConstNodePtr);
@@ -49,10 +50,14 @@ public:
std::string technical_summary() const;
std::string identifier() const;
- int id() const {
+ boost::optional<int> id() const {
return _id;
}
+ void unset_id() {
+ _id = boost::none;
+ }
+
int index(AVFormatContext const * c) const;
std::string name;
@@ -61,7 +66,8 @@ public:
friend bool operator!=(FFmpegStream const & a, FFmpegStream const & b);
private:
- int _id;
+ boost::optional<int> _id;
+ boost::optional<int> _index;
};
#endif