https://foro.gambas-es.org/viewtopic.php?f=17&t=7851&p=47378#p47378
-----------------------------------
tincho
Sabado, 04 Enero 2020, 17:44

Re: Librerias Para Leer Metadatos De Fotos Y Videos.
-----------------------------------
Ahora adapte otra clase, también de Vuott, que utiliza libquicktime. y logro extraer una fecha pero no logro convertirla a algo legible por humanos.
La pagina de consulta sobre la libreria que estoy usando es:
http://libquicktime.sourceforge.net/doc/apiref/group__metadata.html

A la clase hay que pasarle la ruta del archivo de video y luego devuelve una coleccion con los datos.
El resultado es  un signo "[b]-[/b]" seguido de 9 números

¿Alguna idea de que estoy haciendo mal? o tal vez esta bien pero debo convertir ese formato a fecha pero... ¿Como hacerlo? Probe con dete de la terminal de linux y da cualquier cosa.

[i]El fragmento en cuestión es:[/i]
[code linenumbers=false syntax=gambas]
      fecha = lqt_get_creation_time(qt, i)
      cn.Add(fecha, "VideoCreationDate[" & CStr(i) & "]")
[/code]

[i]El código completo es:[/i]
[code linenumbers=false syntax=gambas]
' Gambas class file

Export

'Library "libmediainfo:0.0.0"
'Library "libvlc:5.6.0"

Library "libquicktime:2.0.0"

' quicktime_t * quicktime_open (const char *filename, int rd, int wr)
' Open a file.
Private Extern quicktime_open(filename As String, rd As Integer, wr As Integer) As Pointer

' int quicktime_has_audio (quicktime_t * file)
' Check if a file has at least one audio track.
Private Extern quicktime_has_audio(quicktime As Pointer) As Integer

' int quicktime_audio_tracks (quicktime_t * file)
' Get the number of audio tracks.
Private Extern quicktime_audio_tracks(quicktime As Pointer) As Integer

' long quicktime_sample_rate (quicktime_t *file, int track)
' Get the samplerate of an audio track.
Private Extern quicktime_sample_rate(quicktime As Pointer, track As Integer) As Long

' int quicktime_audio_bits (quicktime_t *file, int track)
' Get the bits per sample of an audio track.
Private Extern quicktime_audio_bits(quicktime As Pointer, track As Integer) As Integer

' int quicktime_track_channels (quicktime_t *file, int track)
' Get the number of channels of an audio track.
Private Extern quicktime_track_channels(quicktime As Pointer, track As Integer) As Integer

' long quicktime_audio_length (quicktime_t *file, int track)
' Get the audio length.
Private Extern quicktime_audio_length(quicktime As Pointer, track As Integer) As Long

' int lqt_get_audio_language (quicktime_t *file, int track, char * language)
' Get the audio language.
Private Extern lqt_get_audio_language(quicktime As Pointer, track As Integer, language As Pointer) As Integer

' int quicktime_has_video (quicktime_t *file)
' Check if a file has at least one video track.
Private Extern quicktime_has_video(quicktime As Pointer) As Integer

' int quicktime_video_tracks (quicktime_t *file)
' Get the number of video tracks.
Private Extern quicktime_video_tracks(quicktime As Pointer) As Integer

' int quicktime_video_width (quicktime_t *file, int track)
' Get the width of a video track.
Private Extern quicktime_video_width(quicktime As Pointer, track As Integer) As Integer

' int quicktime_video_height (quicktime_t *file, int track)
' Get the height of a video track.
Private Extern quicktime_video_height(quicktime As Pointer, track As Integer) As Integer

' double quicktime_frame_rate (quicktime_t *file, int track)
' Get the framerate of a video track.
Private Extern quicktime_frame_rate(quicktime As Pointer, track As Integer) As Float

' long quicktime_video_length (quicktime_t *file, int track)
' Get the video length.
Private Extern quicktime_video_length(quicktime As Pointer, track As Integer) As Long

' char * quicktime_video_compressor (quicktime_t *file, int track)
' Get the four character code of a video track.
Private Extern quicktime_video_compressor(quicktime As Pointer, track As Integer) As String

' int quicktime_close (quicktime_t * file)
' Close a quicktime handle and free all associated memory.
Private Extern quicktime_close(quicktime As Pointer) As Integer

'// Agregado para intentar extraer la fecha de creción
' unsigned long lqt_get_creation_time (quicktime_t * file)
' Get the creation Time From the file.
Private Extern lqt_get_creation_time(quicktime As Pointer, track As Integer) As Long

Public Sub QtimeDat(f As String) As Collection

  Dim qt, lingua As Pointer
  Dim i, tracce, bit, canali, wi, hi As Integer
  Dim frequenza, dimensione As Long

  Dim frame As Float
  Dim compr As String

  Dim fecha As Long '/// Agregado parar fecha
  Dim cn As New Collection '/// Agregado parar fecha

  cn.Clear
  If Exist(f) Then
    qt = quicktime_open(f, 1, 0)
    If IsNull(qt) Then Error.Raise("Impossibile aprire il file !")

    'Print "== ANALISI DELL'AUDIO =="

    If CBool(quicktime_has_audio(qt)) = False Then
      Print "Il file video non ha tracce audio !"
      Quit
    Endif

    tracce = quicktime_audio_tracks(qt)
    'Print "Numero tracce audio: "; Null, tracce
    cn.Add(tracce, "AudioTracks")

    For i = 0 To tracce - 1

      frequenza = quicktime_sample_rate(qt, i)
      'Print "Frequenza camp.to: "; Null, "Hz "; frequenza
      cn.Add(frequenza, "AudioSampleRate[" & CStr(i) & "]")

      bit = quicktime_audio_bits(qt, i)
      If bit > 0 Then ' Print "Risoluzione audio: "; Null, bit; " bit"
        cn.Add(bit, "AudioBits[" & CStr(i) & "]")
      Endif

      canali = quicktime_track_channels(qt, i)
      'Print "Numero canali audio: "; Null, canali
      cn.Add(canali, "AudioChannels[" & CStr(i) & "]")

      dimensione = quicktime_audio_length(qt, i)
      'Print "Dimensione audio: "; Null, dimensione; " byte"
      cn.Add(dimensione, "AudioLength[" & CStr(i) & "]")

      lingua = Alloc(SizeOf(gb.String))
      lqt_get_audio_language(qt, i, lingua)
      'Print "Lingua dell'audio: "; Null, String@(lingua)
      cn.Add(lingua, "AudioLanguage[" & CStr(i) & "]")
    Next

    'Print "\n== ANALISI DEL VIDEO =="

    If CBool(quicktime_has_video(qt)) = False Then Error.Raise("Il file non possiede video !")
    tracce = quicktime_video_tracks(qt)
    Print "Numero tracce video: "; Null, tracce
    cn.Add(tracce, "VideoTracks[" & CStr(i) & "]")

    For i = 0 To tracce - 1
      wi = quicktime_video_width(qt, i)
      'Print "Larghezza video: "; Null, wi; " pixel"
      cn.Add(wi, "Width[" & CStr(i) & "]")

      hi = quicktime_video_height(qt, i)
      'Print "Altezza video: ", Null, hi; " pixel"
      cn.Add(hi, "Height[" & CStr(i) & "]")

      frame = quicktime_frame_rate(qt, i)
      'Print "Frequenza frame: "; Null, frame
      cn.Add(frame, "VideoFrameRate[" & CStr(i) & "]")

      dimensione = quicktime_video_length(qt, i)
      'Print "Dimensione video: "; Null, dimensione; " frame"
      cn.Add(dimensione, "VideoLength[" & CStr(i) & "]")

      compr = quicktime_video_compressor(qt, i)
      Print "Tipo compressione: "; Null, compr
      cn.Add(compr, "VideoCodec[" & CStr(i) & "]")

      '/// Extracción de la fecha de creación
      fecha = lqt_get_creation_time(qt, i)
      'Print "Fecha video: "; Null, fecha; " frame"
      'cn.Add(Format(fecha, "yyyymmdd"), "VideoCreationDate")
      cn.Add(fecha, "VideoCreationDate[" & CStr(i) & "]")

    Next

    ' '/// Extracción de la fecha de creación
    ' fecha = lqt_get_creation_time(qt)
    ' 'Print "Fecha video: "; Null, fecha; " frame"
    ' 'cn.Add(Format(fecha, "yyyymmdd"), "VideoCreationDate")
    ' cn.Add(fecha, "VideoCreationDate")

    ' Va in chiusura:
    Free(lingua)
    quicktime_close(qt)
  Endif

  Return cn

End
[/code]

Saludos.


