Accepting stdin as file input

Help
Young Kim
2014-02-18
2014-02-26
  • Young Kim
    Young Kim
    2014-02-18

    Hello,

    Is there a way for MediaInfo to use stdin as a file input? Or is it necessary to have a local file?

    Thanks,
    Young Kim

     
  • MediaInfo can not currently use stdin, I never think to implement such feature (but it is not impossible).

    Which kind of use case are you thinking about?

     
  • Young Kim
    Young Kim
    2014-02-19

    Thanks for the clarification Jerome.

    In regards to this particular use case, we want a stdin mainly to pass in TS files (in memory) through an external process manager in Python/Ruby/etc. Currently, I'm bypassing this by committing the TS file to a file on disk, but to reduce latency, I clearly want to just pass the content via stdin.

     
  • MediaInfo can be used with a memory buffer, some people use it for analyzing "real time" TS streams (with 7*188=1366 byte packets fiting in an Ethernet frame) , but implementation depends of the language binding. stdin may be a good langage-neutral future solution.

    The Python binding and example do not contain the "By buffer" interface, but it could be expanded for supporting MediaInfo::Open_Buffer_* functions.
    I (the main developer) don't plan to develop it now (only on my free support ToDo-list, which is already long) but maybe you can use the example from C++ and C# (let me know if you develop something! Either a stdin interface or update of the bindings)

     
  • Young Kim
    Young Kim
    2014-02-21

    That makes sense. Do you know where I can find the Python bindings? I could look into adapting it to our needs or something.

    In addition, is it possible to use a pipe as an input for Mediainfo? Or is that a terrible idea?

     
  • Do you know where I can find the Python bindings?

    Bindings
    Examples

    In addition, is it possible to use a pipe as an input for Mediainfo? Or is that a terrible idea?

    Not a terrible idea. Only not developed (and currently not the idea of my sponsors so not a priority for me, the main developer, for the moment). Any patch would be appreciated ;-).

     
  • Young Kim
    Young Kim
    2014-02-21

    Thanks for the links Jerome. I can look into doing something, but is there some sort of documentation specifically for the DLL bindings? If there is, then I probably can go about doing something for Python.

     
  • Documentation is definitely something which is missing :(.
    There is a small documentation in the C++ native interface and the examples shows a bit how to use, but that's all for the moment. The idea is more first to have the same thing in your preferred programming language as the current examples.

     
  • Young Kim
    Young Kim
    2014-02-24

    Post awaiting moderation.
  • Young Kim
    Young Kim
    2014-02-24

    Actually, scratch that. I just screwed up in parts of my code that loaded the file incorrectly :X

    I'm still more than happy in sending you a file that shows the update to the Python wrapper to accommodate this feature :)

     
  • Young Kim
    Young Kim
    2014-02-25

    There's a little snafoo I hit. In particular, what does Open_Buffer_Continue_GoTo_Get exactly do? I adapted the example you gave me, but my load file is now hitting an infinite loop due to the fact that Open_Buffer_Continue_GoTo_Get returns 0 no matter what I do.

     
  • what does Open_Buffer_Continue_GoTo_Get exactly do?

    when not -1 (unsigned 64-bit integer form), value is the byte offset needed by MediaInfo (it is a request to seek in the data stream)

    Open_Buffer_Continue_GoTo_Get returns 0 no matter what I do.

    Not normal, it is -1 most of the time, and sometimes it is the requested byte offset (which is never 0 with MPEG-TS stream)

    If you provide the same kind of standalone example as with other bindings (so data is read from a local file, by blocks of 64K bytes, and seek requests are handled), I may try to help to debug.

    FYI, I just added the "By Buffer" interface, with examples from a local file or from an URL, for the Java binding, patch.

     
  • Young Kim
    Young Kim
    2014-02-25

    I actually got it working correctly. However, it took a while to debug what was going on. The basic summary is that when I load the library in a threaded application, Python does not seem to be able to correctly handle the DLL interaction. My guess is that either MediaInfo's library is not thread safe, or Python is screwing up in these regards. I worked around it by making an external program that takes stdin for MediaInfo.

     
  • MediaInfo is supposed to be thread-safe, but there are no extensive tests about it currently.

    It is always good to start with simple cases (ie without threads), step by step ;-).

    Would you mind to post an example about how you implemented it?

     
  • Young Kim
    Young Kim
    2014-02-26

    Here's the MediaInfoDLL modification in Python: http://pastebin.com/P4Jh7s8e

    As for the actual example, is it possible for me to e-mail it to you directly? I'd be uncomfortable releasing it on a public forum.

     
  • is it possible for me to e-mail it to you directly?

    Sure.
    info@mediaarea.net