Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mono/Linux doesn't return sane values when using Get method, just "" #2

Open
Mouaijin opened this issue Jan 12, 2016 · 4 comments
Open

Comments

@Mouaijin
Copy link

When running my code on 64-bit Windows against a folder of videos, the fields are appropriately parsed and returned using the mi.Get(StreamKind.Video, 0, "Width") type calls. When running on 64-bit Linux with the correct libMediaInfo.so.0 file, the project compiles and runs fine, until trying to access the data inside of MediaInfo objects (same files as Windows tests). Debugging shows that every value is returned as an empty string.
I have a feeling this involves the ANSI conditional in the MediaInfo library source code.
I'll do some poking around to figure out if this can be resolved within the MediaInfoDotNet solution, unless there is a known fix.

@nicholi
Copy link
Owner

nicholi commented Jan 12, 2016

This was one of the REALLY weird parts of the parent git I forked. Deciding whether to use ANSI or Unicode version of the library (plus 64bit or 32bit). I made my fixes primarily for Windows (plus an ASP.NET specific fix to find the DomainPath), and left the non-Windows portions as they were.

As it stands in MediaInfoDotNet/MediaInfoDLL.cs it looks like for ALL non-Windows platforms the library is forced to use ANSI only binaries. Really I don't know why they did this at all, and we should probably just hardcode it to always use unicode binaries for mediainfo. So instead of the whole Environment.OSVersion check, we could just set MustUseAnsi to always be false. If that works for you I'll make the change on my end as well.

@Mouaijin
Copy link
Author

Okay, I'm out of time to look at this tonight, but from what I've found the MustUseAnsi check isn't actually the (main) culprit. It's definitely smelly though.

I've managed to create a pretty extensive list of stack traces that seem to point to the problem being the kernel32 DLL imports- I have a feeling that it's not actually loading in the method pointers from the MediaInfo.dll, but just generating stubs.
Mostly, the traces point at this line:
moduleHandle = UnsafeNativeMethods.LoadLibraryEx(mediaInfoDllPath, IntPtr.Zero, 0);

I'm not sure how UTF plays into that process yet, but I'll see if I can get anything to return proper values and send you a pull request if I get it figured out.

@hilts-vaughan
Copy link

Was there ever any movement on this? Does this work on Linux?

@Mouaijin
Copy link
Author

I had some luck using the branch by x265, since it doesn't depend on kernel32 in Arch Linux. It does take some uncomfortable incantations (i.e. copying the libmediainfo.so.* file to MediaInfo.dll within the executable root). I'm interested in seeing if there's any interop oppurtunities using .Net Core, but that won't be in the short-term.

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

No branches or pull requests

3 participants