INFORMA?ÃO/TEMPO DE ARQUIVO DE VÍDEO

ANDPAG 20/09/2015 02:01:36
#451600
Bom dia a todos.

Pessoal preciso resolver um detalhe..... Alguém sabe como pegar informação de um arquivo de vídeo? Especificamente de um arquivo AVI.

Eu só preciso pegar o tempo do vídeo. Se ele tem 1 minuto, ou se tem 30 segundos.....

TUNUSAT 21/09/2015 08:12:50
#451610
Resposta escolhida
ANDPAG,

=========================================================================================
Retrieve The Length Of WAV, AVI And MIDI Files
http://cuinl.tripod.com/tips-and-tricks-all.htm
http://cuinl.tripod.com/Tips/media-2.htm
Know how much time run any WAV, AVI and MIDI file.

[ô]Module Code
Declare Function mciSendString Lib [Ô]winmm[Ô] Alias [Ô]mciSendStringA[Ô] (ByVal _
lpstrCommand As String, ByVal lpstrReturnString As String, _
ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long

[ô]Form Code
Function GetMediaLength(FileName As String)

Dim MediaLength As Long
Dim RetString As String * 256
Dim CommandString As String

[ô]open the media file
CommandString = [Ô]Open [Ô] & FileName & [Ô] alias MediaFile[Ô]
mciSendString CommandString, vbNullString, 0, 0&

[ô]get the media file length
CommandString = [Ô]Set MediaFile time format milliseconds[Ô]
mciSendString CommandString, vbNullString, 0, 0&
CommandString = [Ô]Status MediaFile length[Ô]
mciSendString CommandString, RetString, Len(RetString), 0&
GetMediaLength = CLng(RetString)

[ô]close the media file
CommandString = [Ô]Close MediaFile[Ô]
mciSendString CommandString, vbNullString, 0, 0&

End Function

Private Sub Form_Load()
Dim Seconds, Minutes As Integer
Dim MilliSeconds As Long
[ô] replace [Ô]c:\my_media_file.wav[Ô] with the path to your media file
MilliSeconds = GetMediaLength([Ô]c:\my_media_file.wav[Ô])
[ô] the function GetMediaLength return the media length in milliseconds,
[ô] so we will calculate the total minutes and seconds
Seconds = Int(MilliSeconds / 1000) Mod 60
Minutes = Int(MilliSeconds / 60000)
MilliSeconds = MilliSeconds Mod 1000

TotalTime = Minutes & [Ô]:[Ô] & Seconds & [Ô]:[Ô] & MilliSeconds
MsgBox (TotalTime)

End Sub


=========================================================================================

Eu achei esta API... mas, precisa testar:
=========================================================================================
http://www.vbforums.com/showthread.php?135407-How-to-get-AVI-s-info-such-as-framerate-resolution-length-etc

Private Const OF_SHARE_DENY_WRITE As Long = &H20
Private Type AVIFILEINFO
dwMaxBytesPerSec As Long
dwFlags As Long
dwCaps As Long
dwStreams As Long
dwSuggestedBufferSize As Long
dwWidth As Long
dwHeight As Long
dwScale As Long
dwRate As Long
dwLength As Long
dwEditCount As Long
szFileType As String * 64
End Type

Private Declare Function AVIFileOpen Lib [Ô]avifil32[Ô] Alias [Ô]AVIFileOpenA[Ô] (ppfile As Long, ByVal szFile As String, ByVal mode As Long, pclsidHandler As Any) As Long
Private Declare Function AVIFileRelease Lib [Ô]avifil32[Ô] (ByVal pfile As Long) As Long
Private Declare Function AVIFileInfo Lib [Ô]avifil32[Ô] Alias [Ô]AVIFileInfoA[Ô] (ByVal pfile As Long, pfi As AVIFILEINFO, ByVal lSize As Long) As Long
Private Declare Sub AVIFileInit Lib [Ô]avifil32[Ô] ()
Private Declare Sub AVIFileExit Lib [Ô]avifil32[Ô] ()

Private Sub Form_Load()
[ô]KPD-Team 2001
[ô]URL: http://www.allapi.net/
[ô]E-Mail: KPDTeam@Allapi.net
Dim hFile As Long, AviInfo As AVIFILEINFO
[ô]initialize the AVIFile library
AVIFileInit
[ô]create a handle to the AVI file

If AVIFileOpen(hFile, [Ô]C:\SIERRA\Half-Life\valve\media\sierra.avi[Ô], OF_SHARE_DENY_WRITE, ByVal 0&) = 0 Then
[ô]retrieve the AVI information
If AVIFileInfo(hFile, AviInfo, Len(AviInfo)) = 0 Then
MsgBox [Ô]AVI dimensions: [Ô] + CStr(AviInfo.dwWidth) + [Ô]x[Ô] + CStr(AviInfo.dwHeight)
Else
MsgBox [Ô]Error while retrieving AVI information... :([Ô]
End If
[ô]release the file handle
AVIFileRelease hFile
Else
MsgBox [Ô]Error while opening the AVI file... :([Ô]
End If

[ô]exit the AVIFile library and decrement the reference count for the library
AVIFileExit
End Sub

=========================================================================================
ezVidCap Component by Ray Mercer (VB6)
http://www.martin2k.co.uk/vb6/tips/vb_35.php
=========================================================================================

Tem vários exemplos aqui no VBMania, nenhum busca a informação?
Veja também as propriedades dos objetos que armazenam o [Ô].AVI[Ô].

[][ô]s.
Tunusat.
ANDPAG 21/09/2015 14:15:41
#451634
Valeu pelo retorno. Aqui só encontrei exemplos de como rodar o arquivo. Eu só preciso saber o tempo que ele tem.

Vou testar seus exemplos e dou um retorno aqui no fórum.

TUNUSAT 22/09/2015 10:43:42
#451678
ANDPAG,

OKay.
Se der certo, posta um código exemplo no VBMania sobre captura de informações de dados dos [Ô].AVI[Ô].

[][ô]s,
Tunusat.
ANDPAG 12/10/2015 04:42:54
#452439
Citação:

:
ANDPAG,

=========================================================================================
Retrieve The Length Of WAV, AVI And MIDI Files
http://cuinl.tripod.com/tips-and-tricks-all.htm
http://cuinl.tripod.com/Tips/media-2.htm
Know how much time run any WAV, AVI and MIDI file.

[ô]Module Code
Declare Function mciSendString Lib [Ô]winmm[Ô] Alias [Ô]mciSendStringA[Ô] (ByVal _
lpstrCommand As String, ByVal lpstrReturnString As String, _
ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long

[ô]Form Code
Function GetMediaLength(FileName As String)

Dim MediaLength As Long
Dim RetString As String * 256
Dim CommandString As String

[ô]open the media file
CommandString = [Ô]Open [Ô] & FileName & [Ô] alias MediaFile[Ô]
mciSendString CommandString, vbNullString, 0, 0&

[ô]get the media file length
CommandString = [Ô]Set MediaFile time format milliseconds[Ô]
mciSendString CommandString, vbNullString, 0, 0&
CommandString = [Ô]Status MediaFile length[Ô]
mciSendString CommandString, RetString, Len(RetString), 0&
GetMediaLength = CLng(RetString)

[ô]close the media file
CommandString = [Ô]Close MediaFile[Ô]
mciSendString CommandString, vbNullString, 0, 0&

End Function

Private Sub Form_Load()
Dim Seconds, Minutes As Integer
Dim MilliSeconds As Long
[ô] replace [Ô]c:my_media_file.wav[Ô] with the path to your media file
MilliSeconds = GetMediaLength([Ô]c:my_media_file.wav[Ô])
[ô] the function GetMediaLength return the media length in milliseconds,
[ô] so we will calculate the total minutes and seconds
Seconds = Int(MilliSeconds / 1000) Mod 60
Minutes = Int(MilliSeconds / 60000)
MilliSeconds = MilliSeconds Mod 1000

TotalTime = Minutes & [Ô]:[Ô] & Seconds & [Ô]:[Ô] & MilliSeconds
MsgBox (TotalTime)

End Sub


=========================================================================================

Eu achei esta API... mas, precisa testar:
=========================================================================================
http://www.vbforums.com/showthread.php?135407-How-to-get-AVI-s-info-such-as-framerate-resolution-length-etc

Private Const OF_SHARE_DENY_WRITE As Long = &H20
Private Type AVIFILEINFO
dwMaxBytesPerSec As Long
dwFlags As Long
dwCaps As Long
dwStreams As Long
dwSuggestedBufferSize As Long
dwWidth As Long
dwHeight As Long
dwScale As Long
dwRate As Long
dwLength As Long
dwEditCount As Long
szFileType As String * 64
End Type

Private Declare Function AVIFileOpen Lib [Ô]avifil32[Ô] Alias [Ô]AVIFileOpenA[Ô] (ppfile As Long, ByVal szFile As String, ByVal mode As Long, pclsidHandler As Any) As Long
Private Declare Function AVIFileRelease Lib [Ô]avifil32[Ô] (ByVal pfile As Long) As Long
Private Declare Function AVIFileInfo Lib [Ô]avifil32[Ô] Alias [Ô]AVIFileInfoA[Ô] (ByVal pfile As Long, pfi As AVIFILEINFO, ByVal lSize As Long) As Long
Private Declare Sub AVIFileInit Lib [Ô]avifil32[Ô] ()
Private Declare Sub AVIFileExit Lib [Ô]avifil32[Ô] ()

Private Sub Form_Load()
[ô]KPD-Team 2001
[ô]URL: http://www.allapi.net/
[ô]E-Mail: KPDTeam@Allapi.net
Dim hFile As Long, AviInfo As AVIFILEINFO
[ô]initialize the AVIFile library
AVIFileInit
[ô]create a handle to the AVI file

If AVIFileOpen(hFile, [Ô]C:SIERRAHalf-Life
alvemediasierra.avi[Ô], OF_SHARE_DENY_WRITE, ByVal 0&) = 0 Then
[ô]retrieve the AVI information
If AVIFileInfo(hFile, AviInfo, Len(AviInfo)) = 0 Then
MsgBox [Ô]AVI dimensions: [Ô] + CStr(AviInfo.dwWidth) + [Ô]x[Ô] + CStr(AviInfo.dwHeight)
Else
MsgBox [Ô]Error while retrieving AVI information... :([Ô]
End If
[ô]release the file handle
AVIFileRelease hFile
Else
MsgBox [Ô]Error while opening the AVI file... :([Ô]
End If

[ô]exit the AVIFile library and decrement the reference count for the library
AVIFileExit
End Sub

=========================================================================================
ezVidCap Component by Ray Mercer (VB6)
http://www.martin2k.co.uk/vb6/tips/vb_35.php
=========================================================================================

Tem vários exemplos aqui no VBMania, nenhum busca a informação?
Veja também as propriedades dos objetos que armazenam o [Ô].AVI[Ô].

[][ô]s.
Tunusat.


Valeu, muito obrigado era isso mesmo.... O primeiro exemplo deu certo aqui para mim... Até mais e abs.
Tópico encerrado , respostas não são mais permitidas