Count_Get not working for me in JNA wrapper on Mac OS X and Linux

Help
Tobias
2013-05-21
2013-05-28
  • Tobias
    Tobias
    2013-05-21

    Hi,

    I am testing the following piece of code:

        MediaInfo mi = new MediaInfo();
    
        System.out.println(mi.Option("Info_Version"));
    
        if (mi.Open(fileName) > 0) {
    
            int audioStreams = mi.Count_Get(StreamKind.Audio);
            for (int i = 0; i < audioStreams; i++) {
                System.out.println(mi.Get(StreamKind.Audio, i, "ID"));
                System.out.println(mi.Get(StreamKind.Audio, i, "CodecID"));
                System.out.println(mi.Get(StreamKind.Audio, i, "Format"));
                System.out.println(mi.Get(StreamKind.Audio, i, "Channels"));
                System.out.println(mi.Get(StreamKind.Audio, i, "SamplingRate"));
                System.out.println(mi.Get(StreamKind.Audio, i, "BitRate"));
                System.out.println(mi.Get(StreamKind.Audio, i, "BitRate_Mode"));
            }
    
            mi.Close();
        }
    

    But this gives me 0 Audio on Mac OS X 10.7.5 (Mediainfo Lib 0.7.61 - the 0.7.62 library download link is broken by the way) and openSUSE 11.4 64Bit (Mediainfo Lib 0.7.62). The library seems to be loaded as it gives me the version information. The sample works on Windows though. Am I missing something?

    Thanks!

    -Tobias

     
  • Boris Naguet
    Boris Naguet
    2013-05-22

    Hi,

    I'm having exactly the same issue, and can't find the solution: This works on windows but not on Linux (no Mac around).
    I'm using a modified version of the JNA class, but nothing has changed around that.
    I've updated to 0.6.63 for both (although calling version() prints 0.6.62 on Linux, but this is another issue), and it's the same thing.

    mi.Count_Get(StreamKind)
    always returns 0 for all kinds (tested on very different files: images, video, sound...), even GENERAL

    Everything else works on Linux: I can "get" a value from stream n°0 of a StreamKind even if it says there's no stream of this kind.

    Regards
    Boris

     
  • Chris Leonello
    Chris Leonello
    2013-05-23

    I am having a similar issue with the python interface on Mac. The Get() calls return a simple "OK" string or no string at all. On Windows, works fine.

     
    Last edit: Chris Leonello 2013-05-23
  • Argh.... It is due to the issue with How do I map a native long type (3rd question)
    -1 value is not well mapped, and I need it for Java binding.

    I tried with NativeLong, but I can not succeed too.
    So I use a slower method now.

    Please use this patch (for JNA) and confirm it is OK everywhere.
    For Python, I imagine it is the same kind of issue, I'll modify the binding the same way soon.

     
  • Boris Naguet
    Boris Naguet
    2013-05-24

    Hello,

    It's working for me (on win64 and linux64).
    Thank you for this fast answer!

    Though, I would suggest a little change to keep the same behavior when there's no stream of that kind,

    MediaInfoDLL_Internal.INSTANCE.Count_Get(Handle, StreamKind.ordinal(), -1)
    

    used to simply return 0

    Get(StreamKind, 0, "StreamCount")
    

    returns an empty String, and parseInt launches a NumberFormatException.
    So I did:

    String streamCount = get(streamKind, 0, "StreamCount");
    if(streamCount == null || streamCount.length() == 0){
    return 0;
    }
    return Integer.parseInt(streamCount);
    

    Regards

     
    • Ho... I don't use to deal with an exception in that case (C function returns 0).
      Slightly modified patch, thank you.
      I hope all is OK now.

       
      Last edit: Jerome Martinez 2013-05-27
  • Tobias
    Tobias
    2013-05-27

    Works for me too, Thanks a lot!

     
  • Chris Leonello
    Chris Leonello
    2013-05-28

    Hi Jerome,

    I wasn't clear on the python issue. The issue is the "Get" and "Inform" methods are not returning anything. The problem I am having is on OS X specifically. It appears to work O.K. on Windows.

    Using the libmediainfo.dylib from the 0.7.62 build and running the HowToUseDLL.py script, output looks like this (this is with your patched MediaInfoDLL.py from above):

    $ python HowToUse_Dll.py
    Info_Parameters
    File_Created_Date_Local   : The time that the file was created on the file system (Warning: this field depends of local     configuration, do not use it in an internationaFile_Modified_Date_Local  : The time that the file was modified on the file system ( Warning: this field depends of local configuration, do not use it in an internationWritten_Location          : Location that the     item was originaly designed/written. Information should be stored in the following format: country code, state/province,    LabelCode                 : A 4-digit or 5-digit number to identify the record label, typically printed as (LC) xxxx or (LC) 0xxxx     on CDs medias or covers, with only tRating                    : A numeric value defining how much a person likes the song/movie.    The number is between 0 and 5 with decimal values possible (e.g. 2.7), 5(.Language                  : Language (2-letter ISO 639-1     if exists, else 3-letter ISO 639-2, and with optional ISO 3166-1 country separated by a dash if available, e.   gLanguage/String4          : Language (2-letter ISO 639-1 if exists with optional ISO 3166-1 country separated by a dash if    available, e.g. en, en-us, zh-cn, else emptyLanguage                  : Language (2-letter ISO 639-1 if exists, else 3-letter ISO  639-2, and with optional ISO 3166-1 country separated by a dash if available, e.gLanguage/String4          : Language (2-letter  ISO 639-1 if exists with optional ISO 3166-1 country separated by a dash if available, e.g. en, en-us, zh-cn, else   emptyLanguage                  : Language (2-letter ISO 639-1 if exists, else 3-letter ISO 639-2, and with optional ISO 3166-1    country separated by a dash if available, e.gLanguage/String4          : Language (2-letter ISO 639-1 if exists with optional ISO  3166-1 country separated by a dash if available, e.g. en, en-us, zh-cn, else emptyLanguage                  : Language (2-letter     ISO 639-1 if exists, else 3-letter ISO 639-2, and with optional ISO 3166-1 country separated by a dash if available, e. gLanguage/String4          : Language (2-letter ISO 639-1 if exists with optional ISO 3166-1 country separated by a dash if  available, e.g. en, en-us, zh-cn, else emptyLanguage                  : Language (2-letter ISO 639-1 if exists, else 3-letter ISO    639-2, and with optional ISO 3166-1 country separated by a dash if available, e.gLanguage/String4          : Language (2-letter    ISO 639-1 if exists with optional ISO 3166-1 country separated by a dash if available, e.g. en, en-us, zh-cn, else     emptyLanguage                  : Language (2-letter ISO 639-1 if exists, else 3-letter ISO 639-2, and with optional ISO 3166-1  country separated by a dash if available, e.gLanguage/String4          : Language (2-letter ISO 639-1 if exists with optional ISO    3166-1 country separated by a dash if available, e.g. en, en-us, zh-cn, else emptyChapters_Pos_Begin        : Used by third-party  developers to know about the beginning of the chapters list, to be used by Get(Stream_Menu, x, Pos), where Pos is an     InChapters_Pos_End          : Used by third-party developers to know about the end of the chapters list (this position excluded)
    
    Info_Capacities
    Option disactivated for this version, will come back soon!
    
    Info_Codecs
     RGB;RGB;4CC;V;RGB;;Uncompressed. Basic Windows bitmap format. 1, 4 and 8 bpp versions are palettised. 16, 24 and 32bpp contain     Uncompressed RGB samples.;http://www.foAAS4;Autodesk;4CC;V;RGB;;Autodesk Animator Studio RLE (warning: this is a discoutinued   product);http://mirror01.iptelecom.net.ua/~video/codecs/Autodesk.Animator.v1.11.AASC;Autodesk;4CC;V;RGB;;Autodesk Animator Studio     RLE (warning: this is a discoutinued product);http://mirror01.iptelecom.net.ua/~video/codecs/Autodesk.Animator.v1.11.AFLC   ;Autodesk;4CC;V;;;Autodesk Animator Studio FLI (256 color) (warning: this is a discoutinued product);http://mirror01.iptelecom.net .ua/~video/codecs/Autodesk.AnimatAFLI;Autodesk;4CC;V;;;Autodesk Animator Studio FLI (256 color) (warning: this is a discoutinued     product);http://mirror01.iptelecom.net.ua/~video/codecs/Autodesk.AnimatRGBA;RGB;4CC;V;RGB;;Uncompressed w/ Alpha. Uncompressed  RGB with alpha. Sample precision and packing is arbitrary and determined using bit masks for each component,     asUYNV;YUV;4CC;V;YUV;;Nvidia 16bpp. A direct copy of UYVY registered by Nvidia to work around problems in some olds which did not   like hardware which offered more than 2UYVY;YUV;4CC;V;YUV;;Uncompressed 16bpp. YUV 4:2:2 (Y sample at every pixel, U and V    sampled at every second pixel horizontally on each line). A macropixel contains 2 px264;AVC;4CC;V;AVC;;XiWave GNU GPL x264 MPEG-   4hannel;http://www.real.comone.htmlndalone.htmlltmlmldalone.htmlne.htmllone.htmlcc.org/indexyuv.htme than 2 YUY2 surfaces
    
    Open
    
    Inform with Complete=false
    
    Inform with Complete=true
    
    Custom Inform
    
    Get with Stream=General and Parameter='FileSize'
    
    GetI with Stream=General and Parameter=46
    
    Count_Get with StreamKind=Stream_Audio
    Traceback (most recent call last):
      File "HowToUse_Dll.py", line 91, in <module>
        print MI.Count_Get(Stream.Audio)
      File "/Users/chris/proj/pyscraper/MediaInfoDLL.py", line 256, in Count_Get
        return int(self.Get(StreamKind, 0, "StreamCount"))
    ValueError: invalid literal for int() with base 10: 'Your software uses an outdated interface, you must use MediaInfo.DLL 0.6   instead'
    

    Note, the final error was only with the patched version of MediaInfoDLL.py. With the unpatched version (from the 0.7.62 build), final output looks like:

    <snip>
    
    Count_Get with StreamKind=Stream_Audio
    0
    
    Get with Stream=General and Parameter='AudioCount'
    
    Get with Stream=Audio and Parameter='StreamCount'
    
    Close
    

    These results are on OS X 10.8.3 with Python 2.7.5 compiled via Homebrew.

    Also note, on OS X, I have to make the following modification to MediaInfoDLL.py for it to run:

    else:
        MediaInfoDLL_Handler = CDLL("libmediainfo.dylib")
        MustUseAnsi = 0
    
     
    • ok, I see.
      I did not test this precise combination (Library / 64 bit / Python / Mac), I'll try it and see if I can find the specific issue. But no ETA.

       
  • Chris Leonello
    Chris Leonello
    2013-05-28

    Thanks. If there is any other info I can provide, let me know.