Medya dosya özelliklerini alma (MediaInfo.dll yöntemi)

Zeki Gürsoy

Uzman
Uzman
Katılım
31 Aralık 2005
Mesajlar
4,284
Excel Vers. ve Dili
Office 2019 (64 bit) - Türkçe
Medya dosyalarını oynatabilmek için K-Lite Codec kurduysanız sistem menüsü üzerine eklenen "MediaInfo" menüsü aşağıdaki görselden de anlaşılacağı üzere tanıdık gelecektir.

Normalde Shell sınıfı pek çok bilgiyi verebiliyor; bu proje ona bir alternatiftir. Yakın bir zamanda Shell sınıfının index yoluyla alınan çözünürlük bilgisinin dosya türüne göre index numarasının kayabildiği yönünde bir mesaj gönderildi. Böyle bir durumda ekli kütüphaneyi kullanabilirsiniz.

Download (rar archive): MediaInfo_VBA (4.08MB)


251409

MediaInfo.cls:

C#:
Option Explicit
'************************************************************************'
'************************************************************************'
'************************************************************************'
'***                                                                  ***'
'***   Project: Media Info Class Object For VBA                       ***'
'***   Author : Zeki Gürsoy                                           ***'
'***   Web    : https://zekigursoy.blogspot.com                       ***'
'***   Mail   : gursoyzeki@gmail.com                                  ***'
'***   Date   : 17.04.2024  / https://www.excel.web.tr                ***'
'***   C Api  : https://mediaarea.net/en/MediaInfo/Download/Windows   ***'
'***                                                                  ***'
'************************************************************************'
'************************************************************************'
'************************************************************************'
#If Win64 Then
    Private Declare PtrSafe Function strlen Lib "ntdll.dll" (ByVal pString As LongLong) As Long 'For ANSI
    Private Declare PtrSafe Function strcpy Lib "ntdll.dll" (ByVal destStr As String, ByVal pSrcStr As LongLong) As LongLong 'For ANSI
   
    Private Declare PtrSafe Function MediaInfoA_New Lib "MediaInfo.dll" () As LongLong
    Private Declare PtrSafe Function MediaInfoA_Open Lib "MediaInfo.dll" (ByVal hMedia As LongLong, ByVal fileName As String) As Long
    Private Declare PtrSafe Sub MediaInfoA_Close Lib "MediaInfo.dll" (ByVal hMedia As LongLong)
    Private Declare PtrSafe Sub MediaInfoA_Delete Lib "MediaInfo.dll" (ByVal hMedia As LongLong)
    Private Declare PtrSafe Function MediaInfoA_Option Lib "MediaInfo.dll" (ByVal hMedia As LongLong, ByVal strOption As String, ByVal strValue As String) As LongLong
    Private Declare PtrSafe Function MediaInfoA_Inform Lib "MediaInfo.dll" (ByVal hMedia As LongLong, ByVal reserved As Long) As LongLong
    Private Declare PtrSafe Function MediaInfoA_GetI Lib "MediaInfo.dll" (ByVal hMedia As LongLong, ByVal StreamKind As StreamKind, _
                                        ByVal streamNumber As Long, ByVal Parameter As Long, Optional ByVal kindOfInfo As InfoKind = 3, _
                                        Optional ByVal kindOfSearch As InfoKind = 0) As LongLong
                                                                        
    Private Declare PtrSafe Function MediaInfoA_Get Lib "MediaInfo.dll" (ByVal hMedia As LongLong, ByVal stream_Kind As StreamKind, _
                                    ByVal streamNumber As Long, ByVal Parameter As String, Optional ByVal kindOfInfo As InfoKind = 3, _
                                    Optional ByVal kindOfSearch As InfoKind = 0) As LongLong
   
    Private Declare PtrSafe Function MediaInfoA_Count_Get Lib "MediaInfo.dll" (ByVal hMedia As LongLong, ByVal stream_Kind As StreamKind, ByVal streamNumber As Long) As Long
   
    Private m_hMedia As LongLong
#Else
    Private Declare Function strlen Lib "kernel32.dll" Alias "lstrlenA" (ByVal pString As Long) As Long 'For ANSI
    Private Declare Function strcpy Lib "kernel32.dll" Alias "lstrcpyA" (ByVal destStr As String, ByVal pSrcStr As Long) As Long 'For ANSI
   
    Private Declare Function MediaInfoA_New Lib "MediaInfo.dll" () As Long
    Private Declare Function MediaInfoA_Open Lib "MediaInfo.dll" (ByVal hMedia As Long, ByVal fileName As String) As Long
    Private Declare Sub MediaInfoA_Close Lib "MediaInfo.dll" (ByVal hMedia As Long)
    Private Declare Sub MediaInfoA_Delete Lib "MediaInfo.dll" (ByVal hMedia As Long)
    Private Declare Function MediaInfoA_Option Lib "MediaInfo.dll" (ByVal hMedia As Long, ByVal strOption As String, ByVal strValue As String) As Long
    Private Declare Function MediaInfoA_Inform Lib "MediaInfo.dll" (ByVal hMedia As Long, ByVal reserved As Long) As Long
    Private Declare Function MediaInfoA_GetI Lib "MediaInfo.dll" (ByVal hMedia As Long, ByVal StreamKind As StreamKind, _
                                        ByVal streamNumber As Long, ByVal Parameter As Long, Optional ByVal kindOfInfo As InfoKind = 3, _
                                        Optional ByVal kindOfSearch As InfoKind = 0) As Long
                                                                        
    Private Declare Function MediaInfoA_Get Lib "MediaInfo.dll" (ByVal hMedia As Long, ByVal stream_Kind As StreamKind, _
                                    ByVal streamNumber As Long, ByVal Parameter As String, Optional ByVal kindOfInfo As InfoKind = 3, _
                                    Optional ByVal kindOfSearch As InfoKind = 0) As Long
   
    Private Declare Function MediaInfoA_Count_Get Lib "MediaInfo.dll" (ByVal hMedia As Long, ByVal stream_Kind As StreamKind, ByVal streamNumber As Long) As Long

    Private m_hMedia As Long
#End If

Public Enum StreamKind
    General = 0
    Video = 1
    Audio = 2
    Text = 3
    Other = 4
    Image = 5
    Menu = 6
End Enum

Public Enum InfoKind
    Name = 0
    Text = 1
    Measure = 2
    Options = 3
    NameText = 4
    MeasureText = 5
    Info = 6
    HowTo = 7
End Enum

Public Function OpenMedia(ByVal fileName As String) As Long
'Open a file and collect information about it (technical information and tags)
'
'Parameters
'    File_Name:  Full name of file to open
'
'Return values
'    0  File not opened
'    1  File opened
    OpenMedia = MediaInfoA_Open(m_hMedia, fileName)
End Function

Public Sub CloseMedia()
    If m_hMedia = 0 Then Exit Sub
    MediaInfoA_Close m_hMedia
End Sub

Public Sub Dispose()
    If m_hMedia = 0 Then Exit Sub
    MediaInfoA_Delete m_hMedia
    m_hMedia = 0
End Sub

Public Function OptionMedia(ByVal strOption As String, Optional ByVal strValue As String = "") As String
#If Win64 Then
    Dim hInfo As LongLong
#Else
    Dim hInfo As Long
#End If
'"0": Immediatly
'"1": After geting local information
'"2": When user interaction is needed, or whan Internet information is get
'"Complete": For debug, configure if MediaInfoLib::Inform() show all information (doesn't care of InfoOption_NoShow tag): shows all information if true,
'            shows only useful for user information if false (No by default)
'"Complete_Get": return the state of "Complete"
'"Info_Parameters": Information about what are known unique names for parameters
'"Info_Parameters_CSV": Information about what are known unique names for parameters, in CSV format
'"Info_Codecs": Information about which codec is known
'"Info_Version": Information about the version of MediaInfoLib
'"Info_Url": Information about where to find the last version
'
    Dim tmpStr As String
   
    hInfo = MediaInfoA_Option(m_hMedia, strOption, strValue)
    tmpStr = String$(strlen(hInfo), 0)
    strcpy tmpStr, hInfo
   
    OptionMedia = tmpStr
End Function

Public Function InForm() As String
'Get all details about a file in one string
'
'Parameters
'    Reserved   Reserved, do not use
'
'Precondition
'    You can change default presentation with Inform_Set()
'
'Returns
'    Text with information about the file
'
#If Win64 Then
    Dim hInForm As LongLong
#Else
    Dim hInForm As Long
#End If
   
    Dim tmpStr As String
   
    hInForm = MediaInfoA_Inform(m_hMedia, 0)
    tmpStr = String$(strlen(hInForm), 0)
    strcpy tmpStr, hInForm
   
    InForm = tmpStr
End Function

Public Function GetByIndex(ByVal stream_Kind As StreamKind, ByVal streamNumber As Long, ByVal Parameter As Long, _
                        Optional ByVal kindOfInfo As InfoKind = InfoKind.Text, Optional ByVal kindOfSearch As InfoKind = InfoKind.Name) As String

'Get a piece of information about a file (parameter is a string)
'
'Parameters
'    StreamKind: Kind of stream (general, video, audio...)
'    StreamNumber:   Stream number in Kind of stream (first, second...)
'    Parameter: Parameter you are looking for in the stream (Codec, width, bitrate...), in integer format (first parameter, second parameter...)
'              This integer is arbitarily assigned by the library, so its consistency should not be relied on, but is useful when looping through
'              all the parameters
'    InfoKind:   Kind of information you want about the parameter (the text, the measure, the help...)
'    SearchKind: Where to look for the parameter
'
'Returns
'    a string about information you search
'    an empty string if there is a problem
'
#If Win64 Then
    Dim hInfo As LongLong
#Else
    Dim hInfo As Long
#End If
   
    Dim tmpStr As String
   
    hInfo = MediaInfoA_GetI(m_hMedia, stream_Kind, streamNumber, Parameter, kindOfInfo, kindOfSearch)
    tmpStr = String$(strlen(hInfo), 0)
    strcpy tmpStr, hInfo
   
    GetByIndex = tmpStr
End Function

Public Function GetByName(ByVal stream_Kind As StreamKind, ByVal streamNumber As Long, ByVal Parameter As String, _
                        Optional ByVal kindOfInfo As InfoKind = InfoKind.Text, Optional ByVal kindOfSearch As InfoKind = InfoKind.Name) As String

'Get a piece of information about a file (parameter is a string)
'
'Parameters
'    StreamKind: Kind of stream (general, video, audio...)
'    StreamNumber:   Stream number in Kind of stream (first, second...)
'    Parameter:  Parameter you are looking for in the stream (Codec, width, bitrate...), in string format ("Codec", "Width"...)
'    See MediaInfo: Option("Info_Parameters") to have the full list
'    InfoKind:   Kind of information you want about the parameter (the text, the measure, the help...)
'    SearchKind: Where to look for the parameter
'
'Returns
'    a string about information you search
'    an empty string if there is a problem
#If Win64 Then
    Dim hInfo As LongLong
#Else
    Dim hInfo As Long
#End If
   
    Dim tmpStr As String
   
    hInfo = MediaInfoA_Get(m_hMedia, stream_Kind, streamNumber, Parameter, kindOfInfo, kindOfSearch)
    tmpStr = String$(strlen(hInfo), 0)
    strcpy tmpStr, hInfo
   
    GetByName = tmpStr
End Function

Public Function Count_Get(ByVal stream_Kind As StreamKind, Optional ByVal streamNumber As Long = -1) As Long
'Count of streams of a stream kind (StreamNumber not filled), or count of piece of information in this stream.
'
'Parameters
'    StreamKind: Kind of stream (general, video, audio...)
'    StreamNumber:   Stream number in this kind of stream (first, second...)
'
'Returns
'    The count of fields for this stream kind / stream number if stream number is provided, else the count of streams for this stream kind
'
    If m_hMedia = 0 Then Exit Function
    Count_Get = MediaInfoA_Count_Get(m_hMedia, stream_Kind, streamNumber)
End Function

Private Sub Class_Initialize()
    m_hMedia = MediaInfoA_New
End Sub

Private Sub Class_Terminate()
    Me.Dispose
End Sub


ExamplesModule.bas:

C#:
Option Explicit
'
Private Function FilePickerSingle() As String
    ' Zeki Gürsoy - 24.04.2024
    ' Ref: https://learn.microsoft.com/en-us/office/vba/api/excel.application.getopenfilename
    '
    Dim fd As Variant, sFilter As String, sTitle As String, bMultiSelect As Boolean, defautFilterIndex As Integer, vFile
  
    bMultiSelect = False
    sTitle = "::.. MediaInfo - Select a file ..::"
    sFilter = "Audio files (*.wav;*.mp3), *.wav;*.mp3"
    sFilter = sFilter & "," & "Video files (*.avi;*.mpg;*.mpeg;*.ts;*.mkv;*.mp4), *.avi;*.mpg;*.ts;*.mkv;*.mp4"
    sFilter = sFilter & "," & "All files (*.*), *.*"
    defautFilterIndex = 2
  
    fd = Application.GetOpenFilename(sFilter, defautFilterIndex, sTitle, "This param for Mac", bMultiSelect)
  
    'Returns Boolean/False if user press cancel button. If user select one or more files and when the bMultiSelect
    'variable is True, returns file fullpaths as an array. Otherwise returns single file fullpath.
    If VarType(fd) = vbBoolean Then Exit Function
  
    FilePickerSingle = fd
End Function

Sub All_Of_Info_To_One_String()
    Dim c As New MediaInfo, dlg As Variant
  
    dlg = FilePickerSingle
  
    If dlg = "" Then Exit Sub
  
    c.OpenMedia dlg
  
    'Syntax: First parameter must 'InForm';
    'As you see returned string is fixed length per line. You can get/read all properties with line by line.
    c.OptionMedia "Inform"
    Debug.Print c.InForm
  
    c.CloseMedia
    c.Dispose
End Sub

Sub With_Parameter_Formatted_String()
    Dim c As New MediaInfo, dlg As Variant

    dlg = FilePickerSingle
  
    If dlg = "" Then Exit Sub
  
    c.OpenMedia dlg
  
    'Note: The name of parameters (Width and Height) are CASE SENSITIVE !!!
    '      This is like 'C' notation or system variable.
    'Syntax: First parameter must be 'InForm';
    '        Second parameter starts with StreamKind enumaration name and semicolon, then contionue parameter name(s).
    '
    'Getting video width and height single line...
    c.OptionMedia "Inform", "Video; Video sizes: %Width% x %Height% pixels"
    Debug.Print c.InForm
  
    'Getting file size...
    c.OptionMedia "Inform", "General; File size is: %FileSize/String4%"
    Debug.Print c.InForm
  
    'Getting duration...
    c.OptionMedia "Inform", "General; Duration is: %Duration/String3%"
    Debug.Print c.InForm
  
    c.CloseMedia
    c.Dispose
End Sub

Sub With_Parameter_Get_Piece_Specific_String_ByName()
    Dim c As New MediaInfo, dlg As Variant
  
    dlg = FilePickerSingle
  
    If dlg = "" Then Exit Sub
  
    c.OpenMedia dlg
  
    'Syntax: First parameter is StreamKind enumaration;
    '        Second parameter is usually '0';
    '        Thirth parameter is string info parameter name (CASE SENSITIVE !!!)
  
    Debug.Print "Width: "; c.GetByName(Video, 0, "Width"); " px"
    Debug.Print "Height: "; c.GetByName(Video, 0, "Height"); " px"
    Debug.Print "File size: "; c.GetByName(General, 0, "FileSize/String4")
    Debug.Print "Duration: "; c.GetByName(General, 0, "Duration/String3")
  
    c.CloseMedia
    c.Dispose
End Sub
.
 
Son düzenleme:
Katılım
24 Nisan 2005
Mesajlar
3,657
Excel Vers. ve Dili
Office 2016 EN 64 Bit
Altın Üyelik Bitiş Tarihi
25/05/2022
64 bit Office 2016 da çalıştı.

Emeğinize sağlık. Güzel bir çalışma.

Kod:
General
Complete name                            : D:\Aidat Takip.avi
Format                                   : AVI
Format/Info                              : Audio Video Interleave
Format settings                          : BitmapInfoHeader
File size                                : 8.38 MiB
Duration                                 : 2 min 59 s
Overall bit rate                         : 391 kb/s
Frame rate                               : 20.000 FPS
IsTruncated                              : Yes

Video
ID                                       : 0
Format                                   : MPEG-4 Visual
Format profile                           : Advanced Simple@L5
Format settings                          : BVOP2
Format settings, BVOP                    : 2
Format settings, QPel                    : No
Format settings, GMC                     : No warppoints
Format settings, Matrix                  : Default (H.263)
Muxing mode                              : Packed bitstream
Codec ID                                 : XVID
Codec ID/Hint                            : XviD
Duration                                 : 2 min 59 s
Bit rate                                 : 387 kb/s
Width                                    : 1 600 pixels
Height                                   : 860 pixels
Display aspect ratio                     : 1.85:1
Frame rate                               : 20.000 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Compression mode                         : Lossy
Bits/(Pixel*Frame)                       : 0.014
Stream size                              : 8.30 MiB (99%)
Writing library                          : XviD 64
 
Katılım
17 Haziran 2008
Mesajlar
1,859
Excel Vers. ve Dili
Microsoft Ofis Profesyonel 2019 x64 TR
Altın Üyelik Bitiş Tarihi
26-03-2020
Merhaba


örnek : B2 hücresinde; C:\deneme.mp4

Command buton ile bu videonun özeliklerini nasıl alabilirim?, Hatta videonun bulunğu yere, özellikleri txt olarak nasıl kayıt edebilirim ?

Teşekkürler.
 

Zeki Gürsoy

Uzman
Uzman
Katılım
31 Aralık 2005
Mesajlar
4,284
Excel Vers. ve Dili
Office 2019 (64 bit) - Türkçe
Merhaba;

Öncelikle "C:" kök dizininde çalışmamayı prensip edinmenizi tavsiye ederim. Aşağıdaki kodu kök dizinde test ederseniz "Path/Access" hatası alırsınız.

C#:
Sub Test_B2()
    Dim c As New MediaInfo, strProps As String, strTxt As String, strFile As String
   
    strFile = Worksheets("Sayfa1").[b2].Text
   
    c.OpenMedia strFile
   
    c.OptionMedia "Inform"
   
    strProps = c.InForm
   
    c.CloseMedia
    c.Dispose
   
    strTxt = Left$(strFile, InStrRev(strFile, ".")) & "txt"
   
    Open strTxt For Output As #1
        Print #1, strProps
    Close
End Sub
.
 
Katılım
17 Haziran 2008
Mesajlar
1,859
Excel Vers. ve Dili
Microsoft Ofis Profesyonel 2019 x64 TR
Altın Üyelik Bitiş Tarihi
26-03-2020
@Zeki Gürsoy

Evet haklısınız. Onu sadece bir örnek olarak vermiştim. Esasında VB6 da hazırlamış olduğum bir programıma bunu entegre etmek istiyorum. olur gibi duruyor... Dosya adını da combobox dan alacak...
-----------------------------------------------------------
Bu şekilde bir hata alıyorum. Command butondan öncede bu hatayı alıyordum... ( ofis pro 2019 x32 kurulu durumda...)

Laptop da denyeyim...







-------------------------------------------------------------

Laptop da sorunsuz çalıştı. txt olarak kayıt yaptı. Çok teşekkür ediyorum. Tamamdır. ( ofis 2016 x64 )
 
Son düzenleme:

Zeki Gürsoy

Uzman
Uzman
Katılım
31 Aralık 2005
Mesajlar
4,284
Excel Vers. ve Dili
Office 2019 (64 bit) - Türkçe
Mavi boyalı satırda platforma yönelik veri tipini değiştirmeyi unuttum sanırım. LongLong olan tipi sadece Long olarak değiştirin. Böylelikle 32 bit ortamında da çalışacak.
.
 
Katılım
17 Haziran 2008
Mesajlar
1,859
Excel Vers. ve Dili
Microsoft Ofis Profesyonel 2019 x64 TR
Altın Üyelik Bitiş Tarihi
26-03-2020
Değiştirdim. Bu şekilde bir hata verdi.

 

Zeki Gürsoy

Uzman
Uzman
Katılım
31 Aralık 2005
Mesajlar
4,284
Excel Vers. ve Dili
Office 2019 (64 bit) - Türkçe
Görseldeki hata penceresine bakılırsa, eğer kod 32 bit çalıştırılıyorsa, x86 dll in __stdcall yerine __cdecl çağrı biçimini desteklediği anlamına geliyor. Çözüm için aklımda iki senaryo var...

Bu arada Thisworbook modülündeki kodları gördünüz mü? Onları da kullanmanız gerekiyor.

.
 
Katılım
17 Haziran 2008
Mesajlar
1,859
Excel Vers. ve Dili
Microsoft Ofis Profesyonel 2019 x64 TR
Altın Üyelik Bitiş Tarihi
26-03-2020
Bu arada Thisworbook modülündeki kodları gördünüz mü? Onları da kullanmanız gerekiyor.

.
Evet gördüm.,

" x86 dll in __stdcall yerine __cdecl çağrı biçimini desteklediği anlamına geliyor. "

bunu nasıl değiştirebiliriz peki ? . vb6 da derlediğim program 32 bit. (VB6 da 32 bit zaten)

Bunu çözebilirsek bu dll, exe dosyası ile birlikte çalışacak. Eminim.
 

Zeki Gürsoy

Uzman
Uzman
Katılım
31 Aralık 2005
Mesajlar
4,284
Excel Vers. ve Dili
Office 2019 (64 bit) - Türkçe
32 bit testi yaptığımda sorunun MediaInfo.dll' de olmadığı, yüksek performans için kullandığım strlen ve strcpy fonksisyonlarının işletim sisteminin ana direği olan ntdll.dll' in 32 bit platformda CDECL çağrı biçimini kullanmasından dolayı uyumsuzluk gösterdiğini farkettim.

Buna göre, çalışırlığını test ettiğim API deklarasyonlarını aşağıdakiler ile değiştirin. (Hatalı değişim ihtimaline karşı tamamını ekliyorum)

C#:
#If Win64 Then
    Private Declare PtrSafe Function strlen Lib "ntdll.dll" (ByVal pString As LongLong) As Long 'For ANSI
    Private Declare PtrSafe Function strcpy Lib "ntdll.dll" (ByVal destStr As String, ByVal pSrcStr As LongLong) As LongLong 'For ANSI
   
    Private Declare PtrSafe Function MediaInfoA_New Lib "MediaInfo.dll" () As LongLong
    Private Declare PtrSafe Function MediaInfoA_Open Lib "MediaInfo.dll" (ByVal hMedia As LongLong, ByVal fileName As String) As Long
    Private Declare PtrSafe Sub MediaInfoA_Close Lib "MediaInfo.dll" (ByVal hMedia As LongLong)
    Private Declare PtrSafe Sub MediaInfoA_Delete Lib "MediaInfo.dll" (ByVal hMedia As LongLong)
    Private Declare PtrSafe Function MediaInfoA_Option Lib "MediaInfo.dll" (ByVal hMedia As LongLong, ByVal strOption As String, ByVal strValue As String) As LongLong
    Private Declare PtrSafe Function MediaInfoA_Inform Lib "MediaInfo.dll" (ByVal hMedia As LongLong, ByVal reserved As Long) As LongLong
    Private Declare PtrSafe Function MediaInfoA_GetI Lib "MediaInfo.dll" (ByVal hMedia As LongLong, ByVal StreamKind As StreamKind, _
                                        ByVal streamNumber As Long, ByVal Parameter As Long, Optional ByVal kindOfInfo As InfoKind = 3, _
                                        Optional ByVal kindOfSearch As InfoKind = 0) As LongLong
                                                                       
    Private Declare PtrSafe Function MediaInfoA_Get Lib "MediaInfo.dll" (ByVal hMedia As LongLong, ByVal stream_Kind As StreamKind, _
                                    ByVal streamNumber As Long, ByVal Parameter As String, Optional ByVal kindOfInfo As InfoKind = 3, _
                                    Optional ByVal kindOfSearch As InfoKind = 0) As LongLong
   
    Private Declare PtrSafe Function MediaInfoA_Count_Get Lib "MediaInfo.dll" (ByVal hMedia As LongLong, ByVal stream_Kind As StreamKind, ByVal streamNumber As Long) As Long
   
    Private m_hMedia As LongLong
#Else
    Private Declare Function strlen Lib "kernel32.dll" Alias "lstrlenA" (ByVal pString As Long) As Long 'For ANSI
    Private Declare Function strcpy Lib "kernel32.dll" Alias "lstrcpyA" (ByVal destStr As String, ByVal pSrcStr As Long) As Long 'For ANSI
   
    Private Declare Function MediaInfoA_New Lib "MediaInfo.dll" () As Long
    Private Declare Function MediaInfoA_Open Lib "MediaInfo.dll" (ByVal hMedia As Long, ByVal fileName As String) As Long
    Private Declare Sub MediaInfoA_Close Lib "MediaInfo.dll" (ByVal hMedia As Long)
    Private Declare Sub MediaInfoA_Delete Lib "MediaInfo.dll" (ByVal hMedia As Long)
    Private Declare Function MediaInfoA_Option Lib "MediaInfo.dll" (ByVal hMedia As Long, ByVal strOption As String, ByVal strValue As String) As Long
    Private Declare Function MediaInfoA_Inform Lib "MediaInfo.dll" (ByVal hMedia As Long, ByVal reserved As Long) As Long
    Private Declare Function MediaInfoA_GetI Lib "MediaInfo.dll" (ByVal hMedia As Long, ByVal StreamKind As StreamKind, _
                                        ByVal streamNumber As Long, ByVal Parameter As Long, Optional ByVal kindOfInfo As InfoKind = 3, _
                                        Optional ByVal kindOfSearch As InfoKind = 0) As Long
                                                                       
    Private Declare Function MediaInfoA_Get Lib "MediaInfo.dll" (ByVal hMedia As Long, ByVal stream_Kind As StreamKind, _
                                    ByVal streamNumber As Long, ByVal Parameter As String, Optional ByVal kindOfInfo As InfoKind = 3, _
                                    Optional ByVal kindOfSearch As InfoKind = 0) As Long
   
    Private Declare Function MediaInfoA_Count_Get Lib "MediaInfo.dll" (ByVal hMedia As Long, ByVal stream_Kind As StreamKind, ByVal streamNumber As Long) As Long

    Private m_hMedia As Long
#End If
.
 
Son düzenleme:

Zeki Gürsoy

Uzman
Uzman
Katılım
31 Aralık 2005
Mesajlar
4,284
Excel Vers. ve Dili
Office 2019 (64 bit) - Türkçe
Sorun giderilmiş olup, #10 nolu mesajdaki API deklarasyonlarını kullanın. İlk mesajdaki ek ve kodlar da güncellenmiştir.

.
 
Son düzenleme:
Katılım
17 Haziran 2008
Mesajlar
1,859
Excel Vers. ve Dili
Microsoft Ofis Profesyonel 2019 x64 TR
Altın Üyelik Bitiş Tarihi
26-03-2020
@Zeki Gürsoy

Evet, ofis 2019 32bit sorunsuz çalıştı. çok teşekkür ediyorum. Gerisi bende... sanırım ekleyebilirim., takıldığım yer olursa buradan yazarım. Çok teşekkür ediyorum.
 
Katılım
17 Haziran 2008
Mesajlar
1,859
Excel Vers. ve Dili
Microsoft Ofis Profesyonel 2019 x64 TR
Altın Üyelik Bitiş Tarihi
26-03-2020
C#:
Formun load kısmına bu şekilde ekledim.
  


Private Declare Function LoadLibraryA Lib "kernel32" (ByVal fileName As String) As Long

Private Sub Form_Load()
    Dim dllPath As String
    dllPath = App.Path
  
    #If Win32 Then
        dllPath = dllPath & "\MediaInfoDLL\x86\MediaInfo.dll"
    #Else
        dllPath = dllPath & "\MediaInfoDLL\x64\MediaInfo.dll"
    #End If
  
    LoadLibraryA dllPath
End Sub

Butona da bu şekilde ;

Private Sub mnuMedya_Click()
    Dim c As New MediaInfo, strProps As String, strTxt As String, strFile As String


    strFile = GetDosPath(GetShortFilename(combo_sec.Text))

    c.OpenMedia strFile

    c.OptionMedia "Inform"

    strProps = c.InForm

    c.CloseMedia
    c.Dispose

    strTxt = Left$(strFile, InStrRev(strFile, ".")) & "txt"

    Open strTxt For Output As #1
        Print #1, strProps
    Close
End Sub
Fakat MediaInfo.dll
bulunamadı hatası veriyor... vb6

şu kısımda

Private Sub Class_Initialize()

m_hMedia = MediaInfoA_New
End Sub

m_hMedia=0

 

Zeki Gürsoy

Uzman
Uzman
Katılım
31 Aralık 2005
Mesajlar
4,284
Excel Vers. ve Dili
Office 2019 (64 bit) - Türkçe
DLL bulunamıyorsa, DLL yolunu kontrol edin. Ayrıca, #If Win64 #Else #End If direktif bloklarını bile değiştirmenize gerek yok. Az önce VB6' da çalıştırarak test ettim.

251434

.
 
Son düzenleme:
Katılım
17 Haziran 2008
Mesajlar
1,859
Excel Vers. ve Dili
Microsoft Ofis Profesyonel 2019 x64 TR
Altın Üyelik Bitiş Tarihi
26-03-2020
Zeki bey;

vb6 da düzenlediğiniz dosyayı paylaşırmısınız? mediainfo.dll yolu doğru ancak bulmuyor...

-----------

Tamamdır, çözdüm. Çok teşekkür ediyorum.
 
Son düzenleme:

Haluk

𐱅𐰇𐰼𐰚
Katılım
7 Temmuz 2004
Mesajlar
12,323
Excel Vers. ve Dili
64 Bit 2010 - İngilizce
+
Google Sheets
+
JScript
Altın Üyelik Bitiş Tarihi
Zeki Beyin önerdiği "MediaInfo" kütüphanesinin, alternatif olarak JScript ile kullanımına ilişkin örnek script aşağıdadır;

JavaScript:
<!DOCTYPE html>
<html lang="Tr">
  <head>
    <meta charset="UTF-8">
    <title>mediainfo.js - Haluk 02/05/2024</title>
    <style>
      html, body{
        margin:0;
        padding:0;
      }
      body * {
        box-sizing: border-box;
      }
      #wrapper {
        display: flex;
        flex-direction: column;
        height: 100%;
        padding: 8px;
        position: absolute;
        width: 100%;
      }
      #fileinput {
        padding-bottom: 8px;
      }
      #output {
        height: 100%;
      }
    </style>
</head>

<body>
  <div id="info" style="font-weight:bold;">
    <br>mediainfo.js - Haluk 02/05/2024 <br><br>
  </div>
  <div id="wrapper">
    <input type="file" id="fileinput" name="fileinput">
    <textarea id="output"></textarea>
  </div>
  <script src="https://unpkg.com/mediainfo.js"></script>
      <script id="rendered-js">
        const fileinput = document.getElementById('fileinput');
        const output = document.getElementById('output');

        const onChangeFile = mediainfo => {
          const file = fileinput.files[0];
          if (file) {
            output.value = 'Islem baslatildi, bekleyiniz…';

            const getSize = () => file.size;

            const readChunk = (chunkSize, offset) =>
            new Promise((resolve, reject) => {
              const reader = new FileReader();
              reader.onload = event => {
                if (event.target.error) {
                  reject(event.target.error);
                }
                resolve(new Uint8Array(event.target.result));
              };
              reader.readAsArrayBuffer(file.slice(offset, offset + chunkSize));
            });

            mediainfo.
            analyzeData(getSize, readChunk).
            then(result => {
              output.value = result;
            }).
            catch(error => {
              output.value = `Hata olustu....:\n${error.stack}`;
            });
          }
        };

        MediaInfo({ format: 'text' }, mediainfo => {
          fileinput.removeAttribute('disabled');
          fileinput.addEventListener('change', () => onChangeFile(mediainfo));
        }, err => {
          console.error(err);
        });
      </script>

</body>
</html>

Örnek ekran görüntüsü aşağıda verilmiştir;





Screenshot.png


.
 
Üst