View Full Version : MediaInfo(Lib) 0.7 - Reading information about media files
BiO-HaZaRd
22nd June 2008, 22:58
Why is it that for any video encoded in xvid 1.1.3 the program shows me that are xvid 1.1.2???
I have only 1.1.3 installed on my computer, i've encoded something just for testing... and it shows 1.1.2...
Placio74
22nd June 2008, 23:33
Why is it that for any video encoded in xvid 1.1.3 the program shows me that are xvid 1.1.2???
...
I'm guess... because Xvid 1.1.3 and 1.1.2 have same bitstream 'tag' - XviD0046.
Zenitram
23rd June 2008, 12:54
Why is it that for any video encoded in xvid 1.1.3 the program shows me that are xvid 1.1.2???
As Placio74 said, both version have the same version tag. There is no way to detect XviD 1.1.3 because the version detection is based on this tag (this is an error from XviD, not mine)
Trusting http://xmm.sourceforge.net/DivX5-6_Xvid_Bitstream_version.php , v.1.1.3 is the only version with this problem.
vlada
1st July 2008, 01:07
Hi,
I have a FLV file (downloaded from YouTube) which is VFR. In this file MediaInfo doesn't detect number of frames and duration of video stream. Is it possible to get these information from a VFR file?
The file can be obtained from YouTube (http://www.youtube.com/watch?v=vwALSGmTNkA) or I can upload it anywhere else.
Zenitram
1st July 2008, 12:05
I have a FLV file (downloaded from YouTube) which is VFR. In this file MediaInfo doesn't detect number of frames and duration of video stream. Is it possible to get these information from a VFR file?
MediaInfo currently does NOT parse the whole file, so when there is no index in the container it can't know how frames there are in the file.
And FLV has no index. Duration is given when the FLV duration metadata is filled.
Parsing the whole file is planned for later.
kurt
24th July 2008, 18:26
feature request:
show framerate of audiofiles, especially for ac3 & dts
this would be great, in particular if one is converting stuff from different sources ...
btw: your program is great - i use it every day :)
Zenitram
24th July 2008, 18:31
feature request:
show framerate of audiofiles, especially for ac3 & dts
this would be great, in particular if one is converting stuff from different sources ...
If you explain me what is a frame (so... an image, or this word has multiple significations for you?) for an Audio stream...
What I can imagine is the "frame size" (how many byte per audio chunk), so the count of audio "chunks" per second, but I don't understand the use of it. And what is the interest of it for multiple sources.
StickHorsie
24th July 2008, 18:42
Downloaded, and will probably be using it a lot! :D
kurt
24th July 2008, 18:49
If you explain me what is a frame (so... an image, or this word has multiple significations for you?) for an Audio stream...
What I can imagine is the "frame size" (how many byte per audio chunk), so the count of audio "chunks" per second, but I don't understand the use of it. And what is the interest of it for multiple sources.
ok
I mean if I take the audio part from a pal source (25 fps) and want to mux it with a ntsc video (i.e. 23,976), I have to adjust either the audio file or the video to get things in sync. So it would be much easier to know the audio-"framerate" (I know, the term is wrong) before muxing and if one should run it through eac3to...
Technically I have no idea how this could work :p (but madshi maybe - he is the audio guru)
Zenitram
24th July 2008, 18:59
I mean if I take the audio part from a pal source (25 fps) and want to mux it with a ntsc video (i.e. 23,976), I have to adjust either the audio file or the video to get things in sync. So it would be much easier to know the audio-"framerate" (I know, the term is wrong) before muxing.
There is no "framerate" as you imagine.
A audio stream is multiple chunks following each others, with no framerate, a chunk is x ms, x depends of the bitrate, no more.
Audio from a PAL source is the same of Audio of NTSC source if this is well made.
The only thing I can imagine is that technician has accelerated the audio and video streams for synchronizing to 25 fps without modifying the video stream (so the audio stream is accelarated by 1/24) for a PAL source, but the audio stream is alterated BEFORE the encoding. It is not possible to know what the technician has done before an encoding!
If a PAL source is well done (3:2:2:2:2:2:2:2:2:2:2 pulldown) and NTSC source is well done (3:2 pulldown, with framedrop for converting 30 fps to 29.970 fps, NTSCis not 23.976...), the film duration is exactly same between NTSC and PAL), and audio part is compatible with both, because there is no framerate information in an audio stream, only a duration....
You speak of alteration of the original sequence, before encoding. Nobody can know what is done before the encoding. PAL and NTSC encoding must be done from the same source if you want to have a good synchro with audio, but this is rarely the case...
vlada
5th August 2008, 20:22
A little OT: I think that speeding up video for PAL is done on almost all PAL DVDs. And I think it is the correct solution. Playing the movie a little faster is better then duplicating a frame (which isn't fluent). Of course this is not a good solution for musical movies because of the audio speed-up.
hvda
13th August 2008, 14:14
(1) I used the GUI version of MediaInfo for about a year to catalogue my video collection, and I thought I understood the information I got. Example: I thought that "General" information (such as "Complete Name", "File size" "Overall bitrate") are attributes attributes at the top level, related to the container, and that by consequence their could not be multiple occurences of General attributes for one single container (as opposed to eg Audio or Menu attributes, which can have multiple occurences).
This seemed at that time to be confirmed by the layout of csv exports: the Heading line in the .csv file goes like this (simplified) : "General ... Video 0...Audio 0 ....Audio 1 ....Audio 3 ...." (ie : NO occurence number for General).
(2) Now I started exploring/testing the DLL version (0.7.7.4) of this wonderful tool with VBE 2005.
-> Here comes my problem : I found that for StreamKind 0 = "General" one of the "General" parameters is "GeneralCount" (comment: number of General Streams).
If my interpretation is correct, this would mean that their can be multiple "General" streams in a container ? And each General stream having its own occurence with different values for the General parameters ?
Could someone please explain this, because I really do not understand the concept of multiple General streams in a container: I tought (cfr para 1) there is only one.
(what is even more confusing : if I do MediaInfo_Get's with the parameter "GeneralCount", the result is always [empty] (ie 0); I expected at least the result to be 1).
Thanks for giving some explanations (and perhaps an example based on say a matroska container).
Zenitram
13th August 2008, 14:50
Could someone please explain this, because I really do not understand the concept of multiple General streams in a container: I tought (cfr para 1) there is only one.
Currently, there is no files with more than one "General" stream.
But:
- The interface is for all kinds of streams, General and Video and Audio and so on. All of this streams ("General" included) are in an unique internal database, with a number for each stream of each kind of stream. This number is unuseful for the "General" stream, but it is easier to have only one programming interface for all streams, so the "General" stream need a number too. Removing this number for General stream would create a more complex interface for requesting info (even more in C than in C++, because I can overload methods in C!)
- Maybe later, I will add a support for more than one "General" stream, but I don't know currently what ;-)
- For Matroska with multiple videos in it, it would be maybe better to add a "menu" stream, as I do for MPEG-TS with multiple programs. But I don't like this possiblility in MKV, this is strange to have multiple independant and not in synchro videos in one file... So a copy of what I do in MPEG-Ts is maybe not a good solution. I am thinking about a way to implement this in MediaInfo, this and the problem of multiple .mp3 in a ZIP file too... If someone has an idea of how to show this kind of files, I am interested ;-)
(what is even more confusing : if I do MediaInfo_Get's with the parameter "GeneralCount", the result is always [empty] (ie 0); I expected at least the result to be 1).
This is a bug, I don't currently fill this field.
I will try to think to add it.
A workaround is to use MediaInfo::Get(Stream_General, 0, "StreamCount")
hvda
13th August 2008, 15:18
Thank you so much for your immediate and extensive reply.
Currently, there is no files with more than one "General" stream
I hope to live long enough to see one; I suppose that will also create the need for another/new streamkind, say "Root" or something like that...
..., but it is easier to have only one programming interface for all streams, so the "General" stream need a number too.
That I can understand perfectly well.
This is a bug....A workaround is to use MediaInfo::Get(Stream_General, 0, "StreamCount")
Thank you, this will put me on track again.
STaRGaZeR
16th August 2008, 14:43
Zenitram, I have a question, sorry if this has been answared before. Using Vista x64 and MediaInfo GUI for Win32. If the files are associated with WMP or BSplayer for example, MediaInfo is shown directly when you right-click the file. But if the files are associated with MPC-HC then it doesn't, you have to do 'Open with...' and then select MediaInfo. Is this a bug or something else?
Also, can we have a x64 GUI?
Thanks for this great tool, a must have :)
Zenitram
16th August 2008, 14:45
Zenitram, Ihave a question, sorry if this has been answared before. Using Vista x64 and MediaInfo GUI for Win32. If the files are associated with WMP or BSplayer for example, MediaInfo is show directly when you right-click the file. But if the files are associated with MPC-HC then it doesn't, you have to do 'Open with...' and then select MediaInfo. Is this a bug or something else?
Extension association on Windows is quite difficult to manage
I didn't understand well yet all the "functionnalities" of the registry for this.
I will install mpc-hc to see what it erase about what I did in the registry.
STaRGaZeR
16th August 2008, 17:35
Extension association on Windows is quite difficult to manage
I didn't understand well yet all the "functionnalities" of the registry for this.
I will install mpc-hc to see what it erase about what I did in the registry.
Thanks, installed and standalone versions are the same for me.
vlada
16th August 2008, 22:11
Hi Zenitram,
I have a (hopefully) small feature request. I'm now using MediaInfo library to read tags from audio files. It works perfectly for me, except one thing - I can't get some tag fields. It is ReplayGain. I think it is because foobar2000 (and other players probably too) store 2 values - track gain and album gain. The other information I can't read is playback statistics, foobar2000 uses these fields: %first_played%, %last_played%, %played_per_day%, %play_count%, %added%. The last information I'm missing is rating.
Could you please implement reading of these tag values at least for MP3 and Ogg Vorbis? Thank you very much.
Zenitram
17th August 2008, 11:07
I can't get some tag fields.
Please provide me examples files with theses tags (at least one of each format), and I will integrate this quickly.
I can provide a FTP access for uploading if requested.
clsid
17th August 2008, 11:52
Found a typo: "warpoints" should be "warppoints"
Zenitram
17th August 2008, 11:57
Found a typo: "warpoints" should be "warppoints"
Should be already corrected in official version 0.7.7.4 (at least).
If not, warn me.
vlada
17th August 2008, 13:09
Please provide me examples files with theses tags (at least one of each format), and I will integrate this quickly.
Here are the samples: http://www.sendspace.com/file/1ow76f (only 120 kB). There are 3 files - MP3, Ogg Vorbis and flac.
I'm not sure if there is a standard on how to tag Matroska files. There should be apparently one album gain tag for the whole file, but one track gain for every chapter (track). Also the play counter should be independent for every track. I will probably discuss this with Matroska developers later.
Zenitram
17th August 2008, 18:08
The other information I can't read is playback statistics, foobar2000 uses these fields: %first_played%, %last_played%, %played_per_day%, %play_count%, %added%. The last information I'm missing is rating.
This info was already available in MediaInfo ;-)
See with the GUI, example for the .mp3:
(...)
last_played_timestamp : 128634480972656250
play_count : 3
first_played_timestamp : 128634480552187500
added_timestamp : 128634479293750000
replaygain_album_gain : -1.79 dB
replaygain_album_peak : 0.953469
replaygain_track_gain : -1.79 dB
replaygain_track_peak : 0.953469
(...)
You just have to use theses "words" to retrieve info (they are the raw names from the custom Id3v2 tags) when MediaInfo soes not support specific tags.
Anyway, I added support for theses items in the last development snapshot, at least version 20080817:
http://downloads.sourceforge.net/mediainfo/MediaInfo_20080817_GUI_Win32_WithoutInstaller.7z
Example for the .mp3:
General
Complete name : F:\Programmation\MediaInfoLib_CrashTest\Nominal\Tags\Id3v2\ReplayGain\sample.mp3
Format : MPEG Audio
File size : 49.9 KiB
Duration : 3s 49ms
Overall bit rate : 128 Kbps
Album replay gain : -1.79 dB
Album replay gain peak : 0.953469
Album : Samples
Track name : mp3
Performer : Me
Writing library : LAME3.94 (alpha)
Added date : UTC 2002-07-05 17:05:01.750
First playing : UTC 2002-07-05 17:26:00.187
Last playing : UTC 2002-07-05 17:33:00.656
Count of playings : 3
Audio
Format : MPEG Audio
Format version : Version 1
Format profile : Layer 3
Duration : 3s 49ms
Bit rate mode : Constant
Bit rate : 128 Kbps
Channel(s) : 1 channel
Sampling rate : 44.1 KHz
Resolution : 16 bits
Replay gain : -1.79 dB
Replay gain peak : 0.953469
Writing library : LAME3.94 (alpha)
Some notes:
- I am not sure of the "english words" to use, if you have a better proposition, don't hesitate.
- I didn't succeed to use Foobar2000+Playback Statistics for writting stats in a file, so I can't verify if the date is good, please confirm. I am not sure about the signification of the raw value for the date, I think this is the count of nanoseconds since 1st January, 1601 (this kind of value is already used elsewehre...), if not I need a better proposition.
- %played_per_day% is not in your files. (maybe it is the play_count/(last_played_timestamp-first_played_timestamp) )
Schrade
17th August 2008, 19:01
English suggestions:
First playing -> First played
Last playing -> Last played
Count of playings -> Times played
vlada
17th August 2008, 19:05
Thanks a lot for your incredibly fast reply and implementation.
1) My English is quite poor, so I can't help. :-(
2) The timestamp was a mystery to me. So I searched through the Internet and your information is correct except of the fact that those are 100 nanoseconds (divide by 10 000 000 to get seconds). The date 01/01/1601 is correct too, but your result is six years off. It should point to today around noon. I have no idea what could be the problem, I tried to calculate it myself and it came out correctly: 128634472997656250/(365.24*24*3600*10000000) = 407. 1601+407 = 2008.
3) Yes, I noticed that his tag is not in the files. It's listed at http://foobar2000.org/components/, maybe it's not implemented yet, I really don't know. Personally I have no use for this tag.
pjo
18th August 2008, 01:48
Hi! I am having a difficulty to read an .m2ts file. It has AAC5.1 audio.
In the dialogue to specify the file, .m2ts is not displayed.
Does MediaInfo support m2ts file ?
pjo
Zenitram
18th August 2008, 04:03
About ReplayGain:
Oh, yes, I forgot tha this is the count of 100-nanoseconds!
So, thanks to Schrade, the output in the next development snapshot will be:
General
Complete name : F:\Programmation\MediaInfoLib_CrashTest\Nominal\Tags\Id3v2\ReplayGain\sample.mp3
Format : MPEG Audio
File size : 49.9 KiB
Duration : 3s 49ms
Overall bit rate : 128 Kbps
Album replay gain : -1.79 dB
Album replay gain peak : 0.953469
Album : Samples
Track name : mp3
Performer : Me
Writing library : LAME3.94 (alpha)
Added date : UTC 2008-08-17 11:58:49.375
First played : UTC 2008-08-17 12:00:55.218
Last played : UTC 2008-08-17 12:01:37.265
Times played : 3
Audio
Format : MPEG Audio
Format version : Version 1
Format profile : Layer 3
Duration : 3s 49ms
Bit rate mode : Constant
Bit rate : 128 Kbps
Channel(s) : 1 channel
Sampling rate : 44.1 KHz
Resolution : 16 bits
Replay gain : -1.79 dB
Replay gain peak : 0.953469
Writing library : LAME3.94 (alpha)
Zenitram
18th August 2008, 04:56
Does MediaInfo support m2ts file ?
BDAV (Blu-ray) or normal TS files are both supported.
If one stream is not detected, please provide an example (some megabytes).
I can provide a FTP access if requested.
pjo
18th August 2008, 05:17
BDAV (Blu-ray) or normal TS files are both supported.
If one stream is not detected, please provide an example (some megabytes).
I can provide a FTP access if requested.
Merci, Please provide the ftp info.
With what tool shall I cut the first several megabytes ?
pjo
pjo
18th August 2008, 07:02
BDAV (Blu-ray) or normal TS files are both supported.
If one stream is not detected, please provide an example (some megabytes).
I can provide a FTP access if requested.
Yes. Here is the link to the first 16877KB of the .m2ts.
http://rapidshare.de/files/40262409/00001cutted.m2ts.html
The first few seconds portion is an ending of a news show with mono AAC (probably), then the main show starts with AAC5.1.
After cutting the news portion with tsMuxeR, the main show is really AAC5.1 when played with MPC without using ffdshow.
Zenitram
18th August 2008, 07:28
After cutting the news portion with tsMuxeR, the main show is really AAC5.1 when played with MPC without using ffdshow.
MediaInfo analyzes only the beginning of a file, and shows info about what it finds at the beginning. MediaInfo can't analyze quickly the complete file (imagine reading the whole 20 GB file from the HDD before showing something ;-) ), and it is not intented for detecting changes in a real time stream (when you provide a real time IP stream to MediaInfo, it shows what it detect at the date and time you provide, not later).
When MediaInfo analyzes your file, it shows what it had found at the beginning (it shows "1 channel").
When MediaInfo analyzes an extraction of your file at the end (cut by myself), it shows the right value for the current stream (it shows "6 channels", there is no info in AAC for saying if a channel is LFE or not)
MediaInfo is not designed for showing different formats in the timeline.
It could with some programming, but I don't have enough time for this, I will not do it.
pjo
18th August 2008, 07:56
Thanks, Zenitram.
I fully understand that the changing stream is not supported in MediaInfo.
Please advise how to load the .m2ts into MediaInfo. I still cannot specify the file in the file selecting dialogue. Running Vista.
pjo
Zenitram
18th August 2008, 12:15
Please advise how to load the .m2ts into MediaInfo. I still cannot specify the file in the file selecting dialogue. Running Vista.
I don't understand well this part.
Since some versions (I don't remeber well, this is more a bug rather than a feature), there is no more filters in the file selecting dialog box.
Anyway, you can:
- Select "All files (*.*)" in the file selection box
- Drag and drop the file to MediaInfo
- Open with... "MediaInfo".
I will add m2ts to the list of the extensions with a context menu, I forgot it.
pjo
18th August 2008, 12:52
I don't understand well this part.
Since some versions (I don't remeber well, this is more a bug rather than a feature), there is no more filters in the file selecting dialog box.
Anyway, you can:
- Select "All files (*.*)" in the file selection box
- Drag and drop the file to MediaInfo
- Open with... "MediaInfo".
I will add m2ts to the list of the extensions with a context menu, I forgot it.
Thanks Zenitram, Drag and drop worked this time. I just restarted MediaInfo.
Will the version with the new context menu be available in the MediaInfo web site ?
Zenitram
18th August 2008, 12:54
Will the version with the new context menu be available in the MediaInfo web site ?
No. Next official version (next Friday).
Zenitram
18th August 2008, 17:21
Will the version with the new context menu be available in the MediaInfo web site ?
A development snapshot (so... Not officialy supported version) is aavailable here:
http://downloads.sourceforge.net/mediainfo/MediaInfo_20080818_GUI_Win32_WithoutInstaller.7z
pjo
19th August 2008, 05:25
A development snapshot (so... Not officialy supported version) is aavailable here:
http://downloads.sourceforge.net/mediainfo/MediaInfo_20080818_GUI_Win32_WithoutInstaller.7z
Thanks !
DanielCardenas
17th September 2008, 00:46
Is your python script available? I'm thinking of writing one and could use the sample code. I'm thinking of creating a script that will enter media info into a database.
Thanks for clearing this up. It really makes sense.
Maybe you could get the information about the number of consecutive B-frames also by scanning the first 10 seconds. It should be enough to judge for 99,9% of files.
I have a serious problem with the latest version and reading Duration (PlayTime) of a video. In my application I use MI.Get("Stream_Video", 0, "Duration", "Info_Text", "Info_Name"). At this line my program exits without any errors. I have no problems with older versions and "PlayTime". If you couldn't find what causes the problem, I could create a sample Python script which demonstrates it.
vlada
5th October 2008, 15:28
DanielCardenas> I'm sorry for my very late reply. After some moth I finally got back to develop my application. Within a month I should be able to make a first release. It will be available under GPL license. I'm afraid it wouldn't be much helpful to you in the current state.
Anyway if you plan to use MediaInfo from Python, there is a wrapper and an example program included with the DLL version of MediaInfo. If you have any problems using it, I should be able to help you, just PM me.
Atak_Snajpera
25th November 2008, 17:18
Zenitram
MediaInfo does not see chapters in .IFO file
http://www.mediafire.com/?zwfigmmqtnz
Zenitram
25th November 2008, 19:38
MediaInfo does not see chapters in .IFO file
IFO support is currently basic, IFO chapters are unfortunatly not well supported (this is planned, but no ETA)
hiper56
30th November 2008, 23:39
Why does the installer tries to connect to internet?
Why does MediaInfo associate itself with *.dat files without asking and why doesn't it have any option in the program settings to change that?
Atak_Snajpera
30th November 2008, 23:48
Why does the installer try to connect to internet?
Why does MediaInfo associate itself with *.dat files without asking and why doesn't it have any option in the program settings to change that?
If you are not happy with official gui try my extremally simple alternative GUI. Link in signature.
Zenitram
1st December 2008, 08:14
Why does the installer tries to connect to internet?
Why does MediaInfo associate itself with *.dat files without asking and why doesn't it have any option in the program settings to change that?
It does.
Uncheck options "check for newest versions" and "Shell extensions" if you don't want this.
vlada
2nd January 2009, 23:20
Hi Zenitram,
I'm getting close to release first version of my transcodig application. There are some things in MediaInfo which I need to workaround or wait for you to implement them.
1) Some files (usually VOBs and VFR FLVs) don't show duration and/or number of frames. I can't correctly transcode such files, because I can't set correct size if I don't know their length.
2) When opening VOBs I would like to see audio/subtitles language and chapters, as Atak_Snajpera already suggested. I know I can read the language from associated .IFO file. What about reading it automatically in MediaInfo?
Do you plan to implement these features in near future or should I find a workaround for them? Honestly I don't know how to get round the first issue. I know you might need to scan the whole file in some cases, but I wouldn't mind. You could make it as an option.
Kurtnoise
2nd January 2009, 23:26
2) When opening VOBs I would like to see audio/subtitles language and chapters, as Atak_Snajpera already suggested.
there are no such infos in vob files afaik...
Zenitram
3rd January 2009, 13:28
1) Some files (usually VOBs and VFR FLVs) don't show duration and/or number of frames. I can't correctly transcode such files, because I can't set correct size if I don't know their length.
This is bug, please contact me at zen@mediaarea.net for providing me the (complete, unfortunatly) files.
I can provide a FTP server if requested.
2) When opening VOBs I would like to see audio/subtitles language and chapters, as Atak_Snajpera already suggested. I know I can read the language from associated .IFO file. What about reading it automatically in MediaInfo?
Do you plan to implement these features in near future or should I find a workaround for them?
For 1) as soon as you send me the file
For 2) When I have time (unfortunatly for you, associating .VOB and .IFO is not currently my priority)
Honestly I don't know how to get round the first issue. I know you might need to scan the whole file in some cases, but I wouldn't mind. You could make it as an option.
In theory, I would not need to scan the complete file.
But if I must, I must adapt a little MediaInfo, but this is time (my time) consuming. Not sure I will do it soon if it is needed. Depends of a lot of things, I can't promise an ETA for this.
there are no such infos in vob files afaik...
No, but in IFO associated with the .VOBs ;-)
.VOBs concatanation and IFO link option is unfortunatly not planed in a near release.
If I am motivated, I try to impement something quickly next week, because this is requested by some users (your feedback as users is a part of the priority I give to feature requests ;-) )
vlada
3rd January 2009, 19:10
Thanks a lot for your answers. I sent you an e-mail regarding the sample files.
I have one more question if anyone could help. I tried to port the python bindings to Python but it doesn't work and I can't find out why.
This is a shorted version of what I did:
# -*- coding: utf-8 -*-
import os
from ctypes import *
if os.name == "posix":
MI = CDLL("libmediainfo.so.0")
else:
MI = windll.MediaInfo
NULL = c_void_p(0)
MediaInfo_New = MI.MediaInfo_New
MediaInfo_New.argtypes = []
MediaInfo_New.restype = c_void_p
MediaInfo_Delete = MI.MediaInfo_Delete
MediaInfo_Delete.argtypes = [c_void_p]
MediaInfo_Open = MI.MediaInfo_Open
MediaInfo_Open.argtype = [c_void_p, c_wchar_p]
MediaInfo_Open.restype = c_uint
MediaInfo_Get = MI.MediaInfo_Get
MediaInfo_Get.argtype = [c_void_p, c_int, c_uint, c_wchar_p, c_int, c_int]
MediaInfo_Get.restype = c_wchar_p
class Stream:
General, Video, Audio, Text, Chapters, Image, Menu, Max = range(8)
class Info:
Name, Text, Measure, Options, Name_Text, Measure_Text, Info, HowTo, Max = range(9)
class InfoOption:
ShowInInform, Reserved, ShowInSupported, TypeOfValue, Max = range(5)
class FileOptions:
Nothing, Recursive, CloseAll, xxNULLxx_3, Max = range(5)
class MediaInfo:
Handle = c_void_p(0)
def __init__(self):
self.Handle=MediaInfo_New()
def __del__(self):
MediaInfo_Delete(self.Handle)
def Open(self, File):
return MediaInfo_Open(self.Handle, File);
def Open_Buffer(self, Begin, Begin_Size, End=NULL, End_Size=0):
return MediaInfo_Open_Buffer(self.Handle, Begin, Begin_Size, End, End_Size)
def Save(self):
return MediaInfo_Save(self.Handle)
def Close(self):
return MediaInfo_Close(self.Handle)
def Inform(self):
return MediaInfo_Inform(self.Handle, 0)
def Get(self, StreamKind, StreamNumber, Parameter, InfoKind=Info.Text, SearchKind=Info.Name):
return MediaInfo_Get(self.Handle, StreamKind, StreamNumber, Parameter, InfoKind, SearchKind)
def GetI(self, StreamKind, StreamNumber, Parameter, InfoKind=Info.Text):
return MediaInfo_GetI(self.Handle, StreamKind, StreamNumber, Parameter, InfoKind)
def Set(self, ToSet, StreamKind, StreamNumber, Parameter, OldParameter=u""):
return MediaInfo_Set(self.Handle, ToSet, StreamKind, StreamNumber, Parameter, OldParameter)
def SetI(self, ToSet, StreamKind, StreamNumber, Parameter, OldValue):
return MediaInfo_SetI(self.Handle, ToSet, StreamKind, StreamNumber, Parameter, OldValue)
def Option(self, Option, Value=u""):
return MediaInfo_Option(self.Handle, Option, Value)
def Option_Static(self, Option, Value=u""):
return MediaInfo_Option(NULL, Option, Value)
def State_Get(self):
return MediaInfo_State_Get(self, Handle)
def Count_Get(self, StreamKind, StreamNumber=-1):
return MediaInfo_Count_Get(self.Handle, StreamKind, StreamNumber)
info = MediaInfo()
info.Open(u"video.avi")
print info.Get(Stream.General, 0, u"Format", Info.Text, Info.Name)
On Windows this works (except of an error when calling the delete constructor). On Linux I get a "Segmentation Fault" when running the "Open" function. Do you have any idea what did I wrong?
Zenitram
16th January 2009, 14:37
I have one more question if anyone could help. I tried to port the python bindings to Python but it doesn't work and I can't find out why.
(...)
On Windows this works (except of an error when calling the delete constructor).
I changed the Python binding in order to avoid this problem (Python is a bit stupid, it deletes the C function pointer before the MediaInfo python class, so when the Python class is destroyed, the call to the C function fails... No comment)
You can have the new binding here:
http://mediainfo.svn.sourceforge.net/viewvc/mediainfo/MediaInfoLib/trunk/Source/MediaInfoDLL/MediaInfoDLL.py?view=markup
The example is updated too:
http://mediainfo.svn.sourceforge.net/viewvc/mediainfo/MediaInfoLib/trunk/Source/Example/HowToUse_Dll.py?view=markup
(if you know how to import the MediaInfoDLL.py instead of pasting and copying it, I am interested in, when I do "import MediaInfoDLL" in the example, I have some error message I don't understand)
On Linux I get a "Segmentation Fault" when running the "Open" function. Do you have any idea what did I wrong?
I imagine you speak about a 64-bit version of Linux, because I succeed to have it working on 32-bit Linux, but not on 64-bit Linux.
I wrote to the Python ctypes guy about this, here is a link to the mailinglist with the details about my tests:
http://thread.gmane.org/gmane.comp.python.ctypes.user/4191
Zenitram
22nd January 2009, 20:29
I have one more question if anyone could help. I tried to port the python bindings to Python but it doesn't work and I can't find out why.
I have adapted my code to avoid the bug in Python/ctypes, so you can find a working copy here:
http://mediainfo.svn.sourceforge.net/viewvc/mediainfo/MediaInfoLib/trunk/Source/Example/HowToUse_Dll.py?view=markup
Note: I use now the "Ansi" version of the binding, and I didn't succeed yet to have this method working with files with non-american caracters (é, ü, chinesich characters), so it works with "classic" files, but not with all the filenames. libmediainfo has strange reactions when it is called by Python, I will try to find the problem later.
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.