You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The mediainfo binary is able to parse piped input so I assume the library supports non-seekable streams.
@JeromeMartinez, how would I go about implementing this? Do I naively ignore MediaInfo_Open_Buffer_Continue_GoTo_Get and pass an arbitrary size to MediaInfo_Open_Buffer_Continue like this? It works with a test stream but I'm not sure it's the right way :D
diff --git a/pymediainfo/__init__.py b/pymediainfo/__init__.py
index 5cce5fa..852c2b3 100644
--- a/pymediainfo/__init__.py+++ b/pymediainfo/__init__.py@@ -457,13 +457,8 @@ class MediaInfo:
)
for option_name, option_value in mediainfo_options.items():
lib.MediaInfo_Option(handle, option_name, option_value)
- try:- filename.seek(0, 2)- file_size = filename.tell()- filename.seek(0)- except AttributeError: # filename is not a file-like object- file_size = None+ file_size = 2**64 - 1
if file_size is not None: # We have a file-like object, use the buffer protocol:
# Some file-like objects do not have a mode
if "b" not in getattr(filename, "mode", "b"):
@@ -476,13 +471,6 @@ class MediaInfo:
# 4th bit = finished
if lib.MediaInfo_Open_Buffer_Continue(handle, buffer, len(buffer)) & 0x08:
break
- # Ask MediaInfo if we need to seek- seek = lib.MediaInfo_Open_Buffer_Continue_GoTo_Get(handle)- # https://github.com/MediaArea/MediaInfoLib/blob/v20.09/Source/MediaInfoDLL/MediaInfoJNI.cpp#L127- if seek != ctypes.c_uint64(-1).value:- filename.seek(seek)- # Inform MediaInfo we have sought- lib.MediaInfo_Open_Buffer_Init(handle, file_size, filename.tell())
else:
break
lib.MediaInfo_Open_Buffer_Finalize(handle)
The text was updated successfully, but these errors were encountered:
Do I naively ignore MediaInfo_Open_Buffer_Continue_GoTo_Get and pass an arbitrary size to MediaInfo_Open_Buffer_Continue like this?
Our usage is to stop the parsing (so exiting the loop then MediaInfo_Open_Buffer_Finalize). Behavior is not so bad there, usually you miss only the duration from MPEG-TS files, or info only from stream content with MP4 with header at the end.
Ignoring MediaInfo_Open_Buffer_Continue_GoTo_Get will work in lot of cases e.g. Matroska, MPEG-TS, MP4 with header at the begining of the file, it will work partially with MP4 with header at the end (it will skip all the data part then read the header i.e. you have to feed with the whole file before there is something interesting, then will try to go back to the beginning for stream content but will fail so no info from the stream content itself, only from the header), it does not hurt, it may just be super slow because you provide the full stream in several cases e.g. MPEG-TS, so like full parsing.
I would recommend to stop the parsing after a seek request if parse_speed is < 1 or if seek request is < current offset, else ignoring the seek request.
Currently, the
parse()
method supports file-like objects but they have to be seekable:pymediainfo/pymediainfo/__init__.py
Lines 480 to 483 in 5ccb770
The
mediainfo
binary is able to parse piped input so I assume the library supports non-seekable streams.@JeromeMartinez, how would I go about implementing this? Do I naively ignore
MediaInfo_Open_Buffer_Continue_GoTo_Get
and pass an arbitrary size toMediaInfo_Open_Buffer_Continue
like this? It works with a test stream but I'm not sure it's the right way :DThe text was updated successfully, but these errors were encountered: