samuelqwe 315 Posted August 14, 2021 Share Posted August 14, 2021 (edited) 11 minutes ago, Happy2Play said: Does not look like it is enabled in Emby ffmpeg (at least in Windows) in ffmpeg 4.3 or 4.4. Emby vs downloaded ffmpeg That would definitely be problematic in this case... @chef you could always build a custom version of FFmpeg (or you can likely find a precompiled one) that does have chromaprint, if you want to keep working on this in the meantime. https://github.com/acoustid/ffmpeg-build/releases or https://www.gyan.dev/ffmpeg/builds/ might work to be able to test. Edited August 14, 2021 by samuelqwe 1 Link to comment Share on other sites More sharing options...
rbjtech 4342 Posted August 14, 2021 Share Posted August 14, 2021 or you can specify a different version of ffmpeg in Advanced Transcoding via the Diagnostics plugin (for testing) ? 1 Link to comment Share on other sites More sharing options...
chef 3750 Posted August 14, 2021 Share Posted August 14, 2021 6 hours ago, rbjtech said: or you can specify a different version of ffmpeg in Advanced Transcoding via the Diagnostics plugin (for testing) ? Thanks man, I've never seen that before Link to comment Share on other sites More sharing options...
chef 3750 Posted August 14, 2021 Share Posted August 14, 2021 (edited) @samuelqwe I was able to acquire a version of ffmpeg which handles chromaprint so I can continue writing this thing. But, when I open the .bin file, there is a lot of encoded data inside, where I thought we would see an Array of finger print data. Is this expected? Is that what you see as well? Edited August 14, 2021 by chef Link to comment Share on other sites More sharing options...
Micael456 43 Posted August 14, 2021 Share Posted August 14, 2021 14 minutes ago, chef said: @samuelqwe I was able to acquire a version of ffmpeg which handles chromaprint so I can continue writing this thing. But, when I open the .bin file, there is a lot of encoded data inside, where I thought we would see an Array of finger print data. Is this expected? Is that what you see as well? Bin compresses it, could be that. Have you tried raw instead? 1 Link to comment Share on other sites More sharing options...
samuelqwe 315 Posted August 14, 2021 Share Posted August 14, 2021 (edited) 22 minutes ago, chef said: @samuelqwe I was able to acquire a version of ffmpeg which handles chromaprint so I can continue writing this thing. But, when I open the .bin file, there is a lot of encoded data inside, where I thought we would see an Array of finger print data. Is this expected? Is that what you see as well? @chef Yes, this is normal. The file contains raw binary data, so just ones and zeros but text editors don’t know that so they try to read it as text. That means that you have to convert each 4 bytes of that binary data to integers yourself. I’m sure there are built-in methods to do this in C#, but I am not super familiar with the language so I can’t tell you exactly how that would work. It shouldn’t be that difficult to accomplish though. It takes about 4 lines of code in Python to accomplish. Edited August 14, 2021 by samuelqwe 1 Link to comment Share on other sites More sharing options...
chef 3750 Posted August 14, 2021 Share Posted August 14, 2021 53 minutes ago, samuelqwe said: @chef Yes, this is normal. The file contains raw binary data, so just ones and zeros but text editors don’t know that so they try to read it as text. That means that you have to convert each 4 bytes of that binary data to integers yourself. I’m sure there are built-in methods to do this in C#, but I am not super familiar with the language so I can’t tell you exactly how that would work. It shouldn’t be that difficult to accomplish though. It takes about 4 lines of code in Python to accomplish. LOL! okay, I'll have to take a look. I think C# has a BinaryReader (hopefull it is used in .netcore... probabaly is). I haven't used it before, so off to Stackoverflow I go! Link to comment Share on other sites More sharing options...
chef 3750 Posted August 14, 2021 Share Posted August 14, 2021 Oh boy, that's advanced! but I understand. Link to comment Share on other sites More sharing options...
samuelqwe 315 Posted August 14, 2021 Share Posted August 14, 2021 (edited) 8 minutes ago, chef said: Oh boy, that's advanced! but I understand. Here it is in Python, in case it might be helpful: fingerprintArray = [] # Create empty fingerprint array with open("FILENAME.bin", "rb") as f: # Open .bin file in binary reading mode while (byte := f.read(4)): # Read 4 bytes at a time, until the end of the file fingerprintArray.append(int.from_bytes(byte, byteorder='little', signed=False)) # Convert from binary to int and add to fingerprint array Edited August 14, 2021 by samuelqwe 1 Link to comment Share on other sites More sharing options...
chef 3750 Posted August 14, 2021 Share Posted August 14, 2021 Perhaps there is ac# dev who wants to chime in here. I can use FileStream to calculate the Byte Array, and get it into chunks, but I think you'll agree that my attempt to add the byte data to the List<uint> feels weird! There must be an AddRange solution to this that I am not seeing right away, without taking four bytes, and moving back through them... Yikes! private List<uint> SplitByteData(string bin) { var fingerprint = new List<uint>(); using(var fileStream = new FileStream(bin, FileMode.Open)) { var fingerprintLength = (uint)fileStream.Length; //The entire size of the filestream var bits = new byte[fingerprintLength]; //Fingerprints added to a new byte Array for (int position = 0; position < fingerprintLength; position += 4) //move through byteArray take every 4 bytes { //This feels strange to do here! fingerprint.Add(bits[position - 4]); fingerprint.Add(bits[position - 3]); fingerprint.Add(bits[position - 2]); fingerprint.Add(bits[position - 1]); } } return fingerprint; } Link to comment Share on other sites More sharing options...
samuelqwe 315 Posted August 14, 2021 Share Posted August 14, 2021 1 hour ago, chef said: Perhaps there is ac# dev who wants to chime in here. I can use FileStream to calculate the Byte Array, and get it into chunks, but I think you'll agree that my attempt to add the byte data to the List<uint> feels weird! There must be an AddRange solution to this that I am not seeing right away, without taking four bytes, and moving back through them... Yikes! private List<uint> SplitByteData(string bin) { var fingerprint = new List<uint>(); using(var fileStream = new FileStream(bin, FileMode.Open)) { var fingerprintLength = (uint)fileStream.Length; //The entire size of the filestream var bits = new byte[fingerprintLength]; //Fingerprints added to a new byte Array for (int position = 0; position < fingerprintLength; position += 4) //move through byteArray take every 4 bytes { //This feels strange to do here! fingerprint.Add(bits[position - 4]); fingerprint.Add(bits[position - 3]); fingerprint.Add(bits[position - 2]); fingerprint.Add(bits[position - 1]); } } return fingerprint; } @chef I figured there had to be a more efficient way to do it and I had a bit of time, so I created a simple C# project in Visual Studio and tried messing around with that. I don't know C# very well, but I can somewhat understand it. So after a bit of googling and trying various solutions, I came up with this: var fingerprint = new List<uint>(); using (BinaryReader b = new BinaryReader(File.Open("FILENAME.bin", FileMode.Open))) { int length = (int)b.BaseStream.Length / sizeof(uint); for (int i = 0; i < length; i++) { fingerprint.Add(b.ReadUInt32()); } } Seems simple enough and gives the expected result. Also, the fingerprint is already in an unsigned int array/list, so no need for an intermediary byte array/list. Just don't know if this solution would work in .NET Core or not. 1 Link to comment Share on other sites More sharing options...
G_P 1 Posted August 14, 2021 Share Posted August 14, 2021 it looks good and think it works for me! But than i play en Episode i don't see any option to skip the Intro! Is that so? Or something missing? greetz Link to comment Share on other sites More sharing options...
samuelqwe 315 Posted August 14, 2021 Share Posted August 14, 2021 1 minute ago, G_P said: it looks good and think it works for me! But than i play en Episode i don't see any option to skip the Intro! Is that so? Or something missing? greetz This is a proof of concept plugin, there is currently no skipping functionality. We are hoping to get there at some point. 1 Link to comment Share on other sites More sharing options...
G_P 1 Posted August 14, 2021 Share Posted August 14, 2021 ahhh @samuelqwe thx for the info! Than will i hope the best 1 Link to comment Share on other sites More sharing options...
chef 3750 Posted August 14, 2021 Share Posted August 14, 2021 1 hour ago, samuelqwe said: @chef I figured there had to be a more efficient way to do it and I had a bit of time, so I created a simple C# project in Visual Studio and tried messing around with that. I don't know C# very well, but I can somewhat understand it. So after a bit of googling and trying various solutions, I came up with this: var fingerprint = new List<uint>(); using (BinaryReader b = new BinaryReader(File.Open("FILENAME.bin", FileMode.Open))) { int length = (int)b.BaseStream.Length / sizeof(uint); for (int i = 0; i < length; i++) { fingerprint.Add(b.ReadUInt32()); } } Seems simple enough and gives the expected result. Also, the fingerprint is already in an unsigned int array/list, so no need for an intermediary byte array/list. Just don't know if this solution would work in .NET Core or not. Yup that's the ticket! I'll get it saving to the database next. Nice! Link to comment Share on other sites More sharing options...
chef 3750 Posted August 14, 2021 Share Posted August 14, 2021 The good news: We can create and manage a data base. Each entry of the db is marked by the internalId of the item for fast lookup. It also contains: 1. The fingerprint data, 2. SeriesId, 3.SeasonId 4. The duration of the fingerprint (because they all have to match) 5. Start and End Times of the title sequence. The Fingerprinting scheduled task will set up the entry, but leave the Start and End times at 0. When the second task (Detect Title Sequences) is run, we'll be able to grab the fingerprints for each entry of the database (based on season), calculate the sequence, and fill in the missing start and end times. The sad news: Emby on windows will not currently support chromaprinting using ffmpeg. But when it does (patiently waiting...) we'll be ready. Link to comment Share on other sites More sharing options...
samuelqwe 315 Posted August 14, 2021 Share Posted August 14, 2021 1 minute ago, chef said: Emby on windows will not currently support chromaprinting using ffmpeg. @Luke @softworkz It appears that some platforms have Chromaprint within their FFmpeg builds and others don’t. Anything that can be done here so that all platforms have Chromaprint? Link to comment Share on other sites More sharing options...
Luke 37272 Posted August 14, 2021 Share Posted August 14, 2021 25 minutes ago, samuelqwe said: @Luke @softworkz It appears that some platforms have Chromaprint within their FFmpeg builds and others don’t. Anything that can be done here so that all platforms have Chromaprint? Yes we need to look at the platforms that are missing it. Thanks. 5 Link to comment Share on other sites More sharing options...
Sammy 739 Posted August 14, 2021 Share Posted August 14, 2021 (edited) Just for reference. As expected, the title sequence for Friends is a bit more than a 30 second skip... Edited August 14, 2021 by Sammy 1 Link to comment Share on other sites More sharing options...
Sammy 739 Posted August 14, 2021 Share Posted August 14, 2021 2 hours ago, chef said: The good news: We can create and manage a data base. Each entry of the db is marked by the internalId of the item for fast lookup. It also contains: 1. The fingerprint data, 2. SeriesId, 3.SeasonId 4. The duration of the fingerprint (because they all have to match) 5. Start and End Times of the title sequence. The Fingerprinting scheduled task will set up the entry, but leave the Start and End times at 0. When the second task (Detect Title Sequences) is run, we'll be able to grab the fingerprints for each entry of the database (based on season), calculate the sequence, and fill in the missing start and end times. The sad news: Emby on windows will not currently support chromaprinting using ffmpeg. But when it does (patiently waiting...) we'll be ready. @chef Is a new plugin ready to test? Link to comment Share on other sites More sharing options...
chef 3750 Posted August 14, 2021 Share Posted August 14, 2021 29 minutes ago, Sammy said: @chef Is a new plugin ready to test? I had better make sure the database is working. Probably get this working very soon. I should forewarn, we'll be swapping ffmpeg on windows machines when we try it out. 1 Link to comment Share on other sites More sharing options...
Sammy 739 Posted August 14, 2021 Share Posted August 14, 2021 Is there a detrimental effect to "normal" use? Link to comment Share on other sites More sharing options...
chef 3750 Posted August 14, 2021 Share Posted August 14, 2021 46 minutes ago, Sammy said: Is there a detrimental effect to "normal" use? Not sure. Most likely not, but I have a second server setup so I'll try it out. Wouldn't want to mess up movie night. 1 Link to comment Share on other sites More sharing options...
chef 3750 Posted August 15, 2021 Share Posted August 15, 2021 Oh! It's alive!! That's exciting! 4 Link to comment Share on other sites More sharing options...
chef 3750 Posted August 15, 2021 Share Posted August 15, 2021 (edited) yeah, database can be hard. But, after many hours auditing the thing, it seems to be okay. Just have to properly edit the table row with title sequence data next. Did you know that a database will sometimes maintain it's file size even if its empty? I know right?!? Also have to check print duration of each episode prior to running the task. If the user changes this, we'll have reprint the entire season. Probably should put that as a warning in the UI somewhere. Also, how big should the database be? Really big? Oh good! Because it will be. Edited August 15, 2021 by chef 2 Link to comment Share on other sites More sharing options...
Recommended Posts