Skip to content

Retain the Encoded Library information stored in a tag (fix #1267)#1268

Open
eugenesvk wants to merge 1 commit intoMediaArea:masterfrom
eugenesvk:master
Open

Retain the Encoded Library information stored in a tag (fix #1267)#1268
eugenesvk wants to merge 1 commit intoMediaArea:masterfrom
eugenesvk:master

Conversation

@eugenesvk
Copy link
Contributor

This fixes #1267

@eugenesvk
Copy link
Contributor Author

eugenesvk commented May 25, 2020

I see that this Travis CI job failed with ../.libs/libmediainfo.so: undefined reference to 'MediaInfoLib::Encoded_Library_Tag' error and with these options seemingly different from a successfull build

-DMEDIAINFO_ALL_NO -DMEDIAINFO_MIXML_YES"
$ export RUN_TESTS="mixml"

Not sure what these are and how I can turn them on on my side to test (I was only using the MSVC2019 project), so will wait for your input

@JeromeMartinez
Copy link
Member

@eugenesvk thanks for the PR. I don't want to have more source file for this unique item, I'll adapt your patch proposal.

@eugenesvk
Copy link
Contributor Author

That's totally fine, it was just the simplest way I found to fix it (I was also thinking of disabling the split into name/version as at first glance it only seemed to be useful to remove a "-" in "x265 - ..." :), but then it was more complicated to trying to figure out all of its uses

@eugenesvk
Copy link
Contributor Author

Any chance you can add it as is so that it's usable and then adapt it later when you have time not to wait 5 more years with a bug?

@JeromeMartinez
Copy link
Member

not to wait 5 more years with a bug

We owe you this one, definitely not right that we have let it open (it felt in the too long todo-list), you don't deserve that.
We'll manage that this week.

@cjee21
Copy link
Contributor

cjee21 commented Feb 10, 2026

Better solution?

diff --git a/Source/MediaInfo/File__Analyze_Streams_Finish.cpp b/Source/MediaInfo/File__Analyze_Streams_Finish.cpp
index ccfc8f566..098e333b8 100644
--- a/Source/MediaInfo/File__Analyze_Streams_Finish.cpp
+++ b/Source/MediaInfo/File__Analyze_Streams_Finish.cpp
@@ -2119,6 +2119,10 @@ extern size_t DolbyVision_Compatibility_Pos(const Ztring& Value);
 //---------------------------------------------------------------------------
 Ztring File__Analyze_Encoded_Library_String (const Ztring &CompanyName, const Ztring &Name, const Ztring &Version, const Ztring &Date, const Ztring &Encoded_Library)
 {
+    if (!Encoded_Library.empty()) {
+        if (Encoded_Library.find(MediaInfoLib::Config.TagSeparator_Get()) != std::string::npos) // there are multiple tags, do not mess with it
+            return Encoded_Library;
+    }
     if (!Name.empty())
     {
         Ztring String;
diff --git a/Source/MediaInfo/Multiple/File_Mk.cpp b/Source/MediaInfo/Multiple/File_Mk.cpp
index d89ab22a2..cd49b2088 100644
--- a/Source/MediaInfo/Multiple/File_Mk.cpp
+++ b/Source/MediaInfo/Multiple/File_Mk.cpp
@@ -1305,7 +1305,13 @@ void File_Mk::Streams_Finish()
                 }
             #endif //MEDIAINFO_PCM_YES
             Finish(Temp->second.Parser);
+            auto encoded_library_from_container = Retrieve_Const(Stream_Video, 0, "Encoded_Library");
             Merge(*Temp->second.Parser, StreamKind_Last, 0, StreamPos_Last);
+            auto encoded_library_after_merge = Retrieve_Const(Stream_Video, 0, "Encoded_Library");
+            if (!encoded_library_from_container.empty() && encoded_library_from_container != encoded_library_after_merge) {
+                auto encoded_library = encoded_library_from_container + MediaInfoLib::Config.TagSeparator_Get() + encoded_library_after_merge;
+                Fill(StreamKind_Last, StreamPos_Last, "Encoded_Library", encoded_library, true);
+            }
             //if (!Duration_Temp.empty()) Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Duration), Duration_Temp, true);
             if (Temp->second.StreamKind==Stream_Video && !Codec_Temp.empty())
                 Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Codec), Codec_Temp, true);

Result (for FFmpeg generated file):

Writing library                          : Lavc62.23.102 libx265 / x265 - 4.1+211-9e551a994:[Windows][GCC 15.2.0][64 bit] 8bit+10bit+12bit

@cjee21
Copy link
Contributor

cjee21 commented Feb 10, 2026

Even better one?

diff --git a/Source/MediaInfo/File__Analyze_Streams_Finish.cpp b/Source/MediaInfo/File__Analyze_Streams_Finish.cpp
index ccfc8f566..cf1b4de32 100644
--- a/Source/MediaInfo/File__Analyze_Streams_Finish.cpp
+++ b/Source/MediaInfo/File__Analyze_Streams_Finish.cpp
@@ -5120,7 +5120,11 @@ void File__Analyze::Streams_Finish_HumanReadable_PerStream(stream_t StreamKind,
         Ztring Version=Retrieve(StreamKind, StreamPos, "Encoded_Library_Version");
         Ztring Date=Retrieve(StreamKind, StreamPos, "Encoded_Library_Date");
         Ztring Encoded_Library=Retrieve(StreamKind, StreamPos, "Encoded_Library");
-        Fill(StreamKind, StreamPos, "Encoded_Library/String", File__Analyze_Encoded_Library_String(CompanyName, Name, Version, Date, Encoded_Library), true);
+        Ztring Encoded_Library_FromContainer = Retrieve(StreamKind, StreamPos, "Encoded_Library_FromContainer");
+        Ztring Encoded_Library_ToFill = File__Analyze_Encoded_Library_String(CompanyName, Name, Version, Date, Encoded_Library);
+        if (!Encoded_Library_FromContainer.empty() && Encoded_Library_ToFill != Encoded_Library_FromContainer)
+            Encoded_Library_ToFill = Encoded_Library_FromContainer + MediaInfoLib::Config.TagSeparator_Get() + Encoded_Library_ToFill;
+        Fill(StreamKind, StreamPos, "Encoded_Library/String", Encoded_Library_ToFill, true);
     }
 
     //Format_Settings_Matrix
diff --git a/Source/MediaInfo/Multiple/File_Mk.cpp b/Source/MediaInfo/Multiple/File_Mk.cpp
index d89ab22a2..cf459229c 100644
--- a/Source/MediaInfo/Multiple/File_Mk.cpp
+++ b/Source/MediaInfo/Multiple/File_Mk.cpp
@@ -1305,7 +1305,12 @@ void File_Mk::Streams_Finish()
                 }
             #endif //MEDIAINFO_PCM_YES
             Finish(Temp->second.Parser);
+            Ztring encoded_library_from_container = Retrieve_Const(Stream_Video, 0, "Encoded_Library");
+            if (!encoded_library_from_container.empty())
+                Fill(StreamKind_Last, StreamPos_Last, "Encoded_Library_FromContainer", encoded_library_from_container);
             Merge(*Temp->second.Parser, StreamKind_Last, 0, StreamPos_Last);
+            if (Retrieve_Const(Stream_Video, 0, "Encoded_Library") == encoded_library_from_container) // no change, Encoded_Library_FromContainer not needed
+                Clear(Stream_Video, 0, "Encoded_Library_FromContainer");
             //if (!Duration_Temp.empty()) Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Duration), Duration_Temp, true);
             if (Temp->second.StreamKind==Stream_Video && !Codec_Temp.empty())
                 Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Codec), Codec_Temp, true);

Result (for FFmpeg generated file):

Writing library                          : Lavc62.23.102 libx265 / x265 4.1+211-9e551a994:[Windows][GCC 15.2.0][64 bit] 8bit+10bit+12bit

@cjee21
Copy link
Contributor

cjee21 commented Feb 11, 2026

Actually I think if this behaviour is desired it should be done in the merging and curation part to ensure consistency between container formats. There should be no need to make changes in MKV parser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Retain the Encoded Library information stored in a tag

3 participants