https://foro.gambas-es.org/viewtopic.php?f=17&t=7851
-----------------------------------
tincho
Miercoles, 25 Diciembre 2019, 21:55

Librerias Para Leer Metadatos De Fotos Y Videos.
-----------------------------------
Hola Vuott.
Has implementado alguna función externa de C con alguna librería que permita extraer la fecha de una foto jpeg y algún que otro dato relevante ?
Estoy usando una función con la llamada a shell de exiftool pero es muy lenta.
Necesito ayuda para acelerar el proceso de lectura de imágenes jpeg.
Gracias.
Saludos.


-----------------------------------
vuott
Jueves, 26 Diciembre 2019, 01:08

Re: Alguna Libreria Para Leer Metadatos De Fotos.
-----------------------------------
...no se si puede ayudarte este codigo:

   https://www.gambas-it.org/wiki/index.php?title=Ottenere_alcune_informazioni_sul_file_immagine_con_le_funzioni_del_API_di_GTK%2B3_e_GDK-PixBuf


-----------------------------------
tincho
Jueves, 26 Diciembre 2019, 03:37

Re: Alguna Libreria Para Leer Metadatos De Fotos.
-----------------------------------
[quote user="vuott" post="47306"]...no se si puede ayudarte este codigo:
   https://www.gambas-it.org/wiki/index.php?title=Ottenere_alcune_informazioni_sul_file_immagine_con_le_funzioni_del_API_di_GTK%2B3_e_GDK-PixBuf[/quote]
Gracias, le echare un vistazo, pero por lo que vi, la librería GTK no lee datos Exif de la imagen. Pero lo investigare mas cuidadosamente.
Saludos.


-----------------------------------
cogier
Jueves, 26 Diciembre 2019, 12:58

Re: Alguna Libreria Para Leer Metadatos De Fotos.
-----------------------------------
Hay un programa llamado 'exiftool' que funciona bien. 

Echa un vistazo a mi programa de Gambas [url=https://gambas.one/gambasfarm/?id=666&action=search]aquí. (Lo siento pero está en inglés)

[img]http://www.cogier.com/gambas/PhotoEXIF1.png[/img]


-----------------------------------
vuott
Jueves, 26 Diciembre 2019, 15:08

Re: Alguna Libreria Para Leer Metadatos De Fotos.
-----------------------------------
[quote user="tincho" post="47308"][quote user="vuott" post="47306"]   https://www.gambas-it.org/wiki/index.php?title=Ottenere_alcune_informazioni_sul_file_immagine_con_le_funzioni_del_API_di_GTK%2B3_e_GDK-PixBuf[/quote]
Pero lo investigare mas cuidadosamente.
[/quote]

Prueba aquel codigo.

saludos


-----------------------------------
tincho
Viernes, 27 Diciembre 2019, 16:40

Re: Alguna Libreria Para Leer Metadatos De Fotos.
-----------------------------------
[quote user="cogier" post="47309"]Hay un programa llamado 'exiftool' que funciona bien. 
Echa un vistazo a mi programa de Gambas [url=https://gambas.one/gambasfarm/?id=666&action=search]aquí. (Lo siento pero está en inglés)
[img]http://www.cogier.com/gambas/PhotoEXIF1.png[/img][/quote]
Gracias Cogier, lo estudiare.
Saludos.


-----------------------------------
tincho
Viernes, 27 Diciembre 2019, 18:31

Re: Alguna Libreria Para Leer Metadatos De Fotos.
-----------------------------------
Cogier, estudie el programa, esta interesante para ver de un pantallazo los datos exif.
También uso exiftool en mis programas (de momento).
Pero mi objetivo es usar una librería mas adelante.
Saludos.


-----------------------------------
jguardon
Domingo, 29 Diciembre 2019, 14:32

Re: Alguna Libreria Para Leer Metadatos De Fotos.
-----------------------------------
[quote user="cogier" post="47309"]Hay un programa llamado 'exiftool' que funciona bien. 

Echa un vistazo a mi programa de Gambas [url=https://gambas.one/gambasfarm/?id=666&action=search]aquí. (Lo siento pero está en inglés)

[img]http://www.cogier.com/gambas/PhotoEXIF1.png[/img][/quote]

Enhorabuena por el programa, es extraordinario!!

Saludos


-----------------------------------
portaro
Martes, 31 Diciembre 2019, 21:19

Re: Alguna Libreria Para Leer Metadatos De Fotos.
-----------------------------------
[quote user="cogier" post="47309"]Hay un programa llamado 'exiftool' que funciona bien. 

Echa un vistazo a mi programa de Gambas [url=https://gambas.one/gambasfarm/?id=666&action=search]aquí. (Lo siento pero está en inglés)

[img]http://www.cogier.com/gambas/PhotoEXIF1.png[/img][/quote]

Gracias por compartirlo lo probare.

_______________________________________________________

He probado a hacer el paquete instalador para dejarlo instalado y lo compilo y instalo bien pero me da error de libreria →

 /usr/bin/PhotoEXIF
gb.gui.qt: warning: 'gb.qt5' component not found, using 'gb.qt4' instead

(gbr3:11646): Gtk-WARNING **: Incapaz de localizar motor de temas na module_path: "xfce",

(gbr3:11646): Gtk-WARNING **: Incapaz de localizar motor de temas na module_path: "xfce",

(gbr3:11646): Gtk-WARNING **: Incapaz de localizar motor de temas na module_path: "xfce",

(gbr3:11646): Gtk-WARNING **: Incapaz de localizar motor de temas na module_path: "xfce",

(gbr3:11646): Gtk-WARNING **: Incapaz de localizar motor de temas na module_path: "xfce",

(gbr3:11646): Gtk-WARNING **: Incapaz de localizar motor de temas na module_path: "xfce",
FMain.CheckExif.370: #49: Not a directory: /usr/bin/exiftool/exiftool
FMain.CheckExif.370 FMain.Form_Open.23 


Instale mediante el paquete generado Ubuntu all → photoexif_0.3.0-0ubuntu1_all.deb

Mi sistema es un poco antiguo pero el problema debe de ser el tema gtk libraries yo uso LXDE.

Saludos.


-----------------------------------
cogier
Miercoles, 01 Enero 2020, 15:04

Re: Alguna Libreria Para Leer Metadatos De Fotos.
-----------------------------------
[quote]He probado a hacer el paquete instalador para dejarlo instalado y lo compilo y instalo bien pero me da error de libreria →

/usr/bin/PhotoEXIF
gb.gui.qt: warning: 'gb.qt5' component not found, using 'gb.qt4' instead

(gbr3:11646): Gtk-WARNING **: Incapaz de localizar motor de temas na module_path: "xfce",...[/quote]

Instalé 'Xubuntu 18.03' y Gambas. Luego descargué 'PhotoEXIF' de la 'Granja', y funcionó sin problemas.

Google se quejó de 'FireFox' pero 'Bing' estaba bien.

No he intentado hacer un archivo '.deb'.

[img]http://www.cogier.com/gambas/Screenshot_PhotoEXIF.png[/img]


-----------------------------------
vuott
Miercoles, 01 Enero 2020, 23:07

Re: Alguna Libreria Para Leer Metadatos De Fotos.
-----------------------------------
[quote user="tincho" post="47300"]Hola Vuott.
Has implementado alguna función externa de C con alguna librería que permita extraer la fecha de una foto jpeg y algún que otro dato relevante ?
[/quote]

Hola tincho,
prueba este nuevo codigo ahora:

[code linenumbers=false syntax=gambas]Private content_count As Integer
Private ifd As Integer
Private entry_count As Integer


Library "libexif:12.3.3"

Public Struct ExifData
  ifd[5] As Pointer
  data As Pointer
  size As Integer
  priv As Pointer
End Struct

Public Struct ExifEntry
  tag As Integer
  format_ As Integer
  components As Long
  data As Pointer
  size As Integer
  parent As Pointer
  priv As Pointer
End Struct

' ExifData *exif_data_new_from_file (const char *path)
' Allocate a new #Pointer and load EXIF data from a JPEG file.
Private Extern exif_data_new_from_file(path As String) As ExifData

' ExifByteOrder exif_data_get_byte_order  (ExifData *data)
' Return the byte order in use by this EXIF structure.
Private Extern exif_data_get_byte_order(data As ExifData) As Integer

' const char *exif_byte_order_get_name (ExifByteOrder order)
' Return a short, localized, textual name for the given byte order.
Private Extern exif_byte_order_get_name(order As Integer) As String

' void exif_data_foreach_content (ExifData *data, PointerForeachContentFunc func, void *user_data)
' Execute a function on each IFD in turn.
Private Extern exif_data_foreach_content(data As ExifData, func As Pointer, user_data As Pointer)

' void exif_content_foreach_entry (ExifContent *content, ExifContentForeachEntryFunc func, void *user_data)
' Executes function on each EXIF tag in this IFD in turn.
Private Extern exif_content_foreach_entry(content As Pointer, func As Pointer, user_data As Pointer)

' ExifIfd exif_content_get_ifd (ExifContent *c)
' Return the IFD number in which the given #ExifContent is found.
Private Extern exif_content_get_ifd(c As Pointer) As Integer

' const char *exif_entry_get_value (ExifEntry *entry, char *val, unsigned int maxlen)
' Return a localized textual representation of the value of the EXIF entry.
Private Extern exif_entry_get_value(entry As ExifEntry, _val As Pointer, maxlen As Integer) As String

' const char *exif_tag_get_name_in_ifd(ExifTag tag, ExifIfd ifd)
' Return a textual name of the given tag when found in the given IFD.
Private Extern exif_tag_get_name_in_ifd(tag As Integer, ifd As Integer) As String

' const char *exif_format_get_name (ExifFormat format)
' Return a textual representation of the given EXIF data type.
Private Extern exif_format_get_name(format_ As Integer) As String

' void exif_data_unref (ExifData *data)
Private Extern exif_data_unref(data As ExifData)


Public Sub Main()
 
  Dim ed As ExifData
  Dim jpg As String
  Dim callback_data As Pointer

  jpg = "/ruta/del/archivo.jpg"
  Print "File immagine:   "; jpg
  
  ed = exif_data_new_from_file(jpg)
  If IsNull(ed) Then Error.Raise("Errore !")
  
  Print "Ordine dei byte: "; exif_byte_order_get_name(exif_data_get_byte_order(ed))
  
  exif_data_foreach_content(ed, data_foreach_func, callback_data)
 
  exif_data_unref(ed)
  
End


Private Function data_foreach_func(content As Pointer, callback_data As Pointer)
  
  ifd = exif_content_get_ifd(content)
  Print "  Content :"; content_count, "ifd= "; ifd
  
  exif_content_foreach_entry(content, content_foreach_func, callback_data)
  
  Inc content_count
  
End


Private Function content_foreach_func(entry As Pointer, callback_data As Pointer)

  Dim buf As New Byte[2000]
  Dim ent As ExifEntry
  
  ent = entry
  
  exif_entry_get_value(entry, buf.Data, buf.Count)
  
  Print "   Entry"; entry_count; ": "; exif_tag_get_name_in_ifd(ent.tag, ifd); "("; exif_format_get_name(ent.format_); ")"
  Print "      Size, Comps: "; ent.size; ", "; ent.components
  Print "      Value: "; exif_entry_get_value(ent, buf.Data, buf.Count)
  Inc entry_count
  
End[/code]


-----------------------------------
portaro
Jueves, 02 Enero 2020, 20:34

Re: Alguna Libreria Para Leer Metadatos De Fotos.
-----------------------------------
[quote user="cogier" post="47338"][quote]He probado a hacer el paquete instalador para dejarlo instalado y lo compilo y instalo bien pero me da error de libreria →

/usr/bin/PhotoEXIF
gb.gui.qt: warning: 'gb.qt5' component not found, using 'gb.qt4' instead

(gbr3:11646): Gtk-WARNING **: Incapaz de localizar motor de temas na module_path: "xfce",...[/quote]

Instalé 'Xubuntu 18.03' y Gambas. Luego descargué 'PhotoEXIF' de la 'Granja', y funcionó sin problemas.

Google se quejó de 'FireFox' pero 'Bing' estaba bien.

No he intentado hacer un archivo '.deb'.

[img]http://www.cogier.com/gambas/Screenshot_PhotoEXIF.png[/img][/quote]

Gracias por el dato mirare por la "Granja". 

El programa es genial porque es un interfaz grafico a las opciones que sueles usar por comandos con esa herramienta, creo que tengo alguna aplicacion grafica similar instalada en este PC pero no lo se con total seguridad ni me acuerdo del nombre tendria que buscar en los menus o programas script y como esta aplicacion de front end para Exiftool esta hecha en Gambas pues me interesa porque me gustan estas aplicaciones hechas en este lenguaje y que te ahorra abrir terminal y darle a comandos si lo puedes hacer mediante clicks tiene su uso las dos cosas estan bien a veces mejor comando y a veces mejor por boton.

Gracias.


-----------------------------------
tincho
Jueves, 02 Enero 2020, 23:14

Re: Alguna Libreria Para Leer Metadatos De Fotos.
-----------------------------------
[quote user="vuott" post="47342"]Hola tincho,
prueba este nuevo codigo ahora:

[code linenumbers=false syntax=gambas]Private content_count As Integer
Private ifd As Integer
Private entry_count As Integer

Library "libexif:12.3.3"
'...
End[/code]
[/quote]
Perfecto Vuott, lo probé y funciona muy bien y muy rápido.
Estoy adaptando la clase para poder usarla en varios programas de manejo de fotos.
Siempre haces estos programas que funcionan súper rápido
Muchas gracias por compartirlos.
Saludos.


-----------------------------------
tincho
Viernes, 03 Enero 2020, 00:49

Re: Alguna Libreria Para Leer Metadatos De Fotos.
-----------------------------------
Bueno ya esta, logre adaptar el código paara poder usarlo instanciado en otros programas.
[code linenumbers=false syntax=gambas]
' Gambas class file

Export

Private content_count As Integer
Private ifd As Integer

Public ctn As New Collection
'Private entry_count As Integer

Library "libexif:12.3.3"

Public Struct ExifData
  ifd[5] As Pointer
  data As Pointer
  size As Integer
  priv As Pointer
End Struct

Public Struct ExifEntry
  tag As Integer
  format_ As Integer
  components As Long
  data As Pointer
  size As Integer
  parent As Pointer
  priv As Pointer
End Struct

' ExifData *exif_data_new_from_file (const char *path)
' Allocate a new #Pointer and load EXIF data from a JPEG file.
Private Extern exif_data_new_from_file(path As String) As ExifData

' ExifByteOrder exif_data_get_byte_order  (ExifData *data)
' Return the byte order in use by this EXIF structure.
Private Extern exif_data_get_byte_order(data As ExifData) As Integer

' const char *exif_byte_order_get_name (ExifByteOrder order)
' Return a short, localized, textual name for the given byte order.
Private Extern exif_byte_order_get_name(order As Integer) As String

' void exif_data_foreach_content (ExifData *data, PointerForeachContentFunc func, void *user_data)
' Execute a function on each IFD in turn.
Private Extern exif_data_foreach_content(data As ExifData, func As Pointer, user_data As Pointer)

' void exif_content_foreach_entry (ExifContent *content, ExifContentForeachEntryFunc func, void *user_data)
' Executes function on each EXIF tag in this IFD in turn.
Private Extern exif_content_foreach_entry(content As Pointer, func As Pointer, user_data As Pointer)

' ExifIfd exif_content_get_ifd (ExifContent *c)
' Return the IFD number in which the given #ExifContent is found.
Private Extern exif_content_get_ifd(c As Pointer) As Integer

' const char *exif_entry_get_value (ExifEntry *entry, char *val, unsigned int maxlen)
' Return a localized textual representation of the value of the EXIF entry.
Private Extern exif_entry_get_value(entry As ExifEntry, _val As Pointer, maxlen As Integer) As String

' const char *exif_tag_get_name_in_ifd(ExifTag tag, ExifIfd ifd)
' Return a textual name of the given tag when found in the given IFD.
Private Extern exif_tag_get_name_in_ifd(tag As Integer, ifd As Integer) As String

' const char *exif_format_get_name (ExifFormat format)
' Return a textual representation of the given EXIF data type.
Private Extern exif_format_get_name(format_ As Integer) As String

' void exif_data_unref (ExifData *data)
Private Extern exif_data_unref(data As ExifData)

Public Sub _new()

End

Public Sub exifdat(f As String) As Collection

  Dim ed As ExifData
  'Dim jpg As String
  Dim callback_data As Pointer

  ctn.Clear

  'jpg = "/ruta/del/archivo.jpg"
  'Print "File immagine:   "; jpg
  If Exist(f) Then
    ed = exif_data_new_from_file(f)
    If IsNull(ed) Then Error.Raise("Errore !")
    '    Print "Ordine dei byte: "; exif_byte_order_get_name(exif_data_get_byte_order(ed))
    exif_data_foreach_content(ed, data_foreach_func, callback_data)
    exif_data_unref(ed)
  Endif

  Return Normalize(ctn)

End

Private Function Normalize(cn As Collection) As Collection

  Dim tg As Variant
  Dim co As New Collection

  For Each tg In cn
    Select cn.Key
      Case "Model"
        co.Add(tg, "CameraModel")
      Case "Make"
        co.Add(tg, "CameraMaker")
      Case "DateTimeOriginal", "Date/Time"
        co.Add(tg, "DateTimeOriginal")
      Case Else
        co.Add(tg, cn.Key)
    End Select
  Next

  If co.Exist("Resolution") = False Then
    If co.Exist("PixelXDimension") And co.Exist("PixelYDimension") Then
      co.Add(co["PixelXDimension"] & "X" & co["PixelYDimension"], "Resolution")
    Endif
  Endif

  Return co

End

Private Function data_foreach_func(content As Pointer, callback_data As Pointer)

  ifd = exif_content_get_ifd(content)
  'Print "  Content :"; content_count, "ifd= "; ifd

  exif_content_foreach_entry(content, content_foreach_func, callback_data)

  'Inc content_count

End

Private Function content_foreach_func(entry As Pointer, callback_data As Pointer)

  Dim buf As New Byte[2000]
  Dim ent As ExifEntry

  ent = entry

  exif_entry_get_value(entry, buf.Data, buf.Count)

  'Print "   Entry"; entry_count; ": "; exif_tag_get_name_in_ifd(ent.tag, ifd); "("; exif_format_get_name(ent.format_); ")"
  'Print "      Size, Comps: "; ent.size; ", "; ent.components
  'Print "      Value: "; exif_entry_get_value(ent, buf.Data, buf.Count)

  ctn.Add(exif_entry_get_value(ent, buf.Data, buf.Count), exif_tag_get_name_in_ifd(ent.tag, ifd))

  'Inc entry_count

End
[/code]
Le modifique algunas nombres de tag para que sea compatible con mis programas.
Al intentar leer metadatos de archivos de video no funciono. Supongo que la librería libexif no soportam mas que JPEG.
En este sitio dice que solo es para JPEG
https://libexif.github.io/api/exif-data_8h.html#ac3c2d86223d3b219bad7ab2d28d8b8d2
Así que de momento para otros formatos de archivo seguire usando la herramienta [b]Exiftool[/b] a travez de la terminal.
Uso shell ya que como es una libreria perl no se puede usar como [b]Extern[/b] verdad? o si se puede?

Saludos.


-----------------------------------
tincho
Viernes, 03 Enero 2020, 00:52

Re: Alguna Libreria Para Leer Metadatos De Fotos.
-----------------------------------
[quote user="cogier" post="47309"]Hay un programa llamado 'exiftool' que funciona bien. 
Echa un vistazo a mi programa de Gambas [url=https://gambas.one/gambasfarm/?id=666&action=search]aquí. (Lo siento pero está en inglés)
[img]http://www.cogier.com/gambas/PhotoEXIF1.png[/img][/quote]
Creo que tu programa se vería beneficiado si usas la clase de Vuott que implementa libexif con Extern.
Y por cierto, que antes me olvide de decirlo, muy buen programa.
Saludos.


-----------------------------------
vuott
Viernes, 03 Enero 2020, 09:24

Re: Alguna Libreria Para Leer Metadatos De Fotos.
-----------------------------------
[quote user="tincho" post="47345"]Uso shell ya que como es una libreria perl no se puede usar como [b]Extern[/b] verdad? o si se puede?[/quote]
Con Extern solo C: librerias [color=#CC0000].so[/color] .


-----------------------------------
tincho
Viernes, 03 Enero 2020, 12:22

Re: Alguna Libreria Para Leer Metadatos De Fotos.
-----------------------------------
[quote user="vuott" post="47347"]Con Extern solo C: librerias [color=#CC0000].so[/color] .[/quote]
Ok, me lo imaginaba.
Saludos.


-----------------------------------
vuott
Viernes, 03 Enero 2020, 13:18

Re: Alguna Libreria Para Leer Metadatos De Fotos.
-----------------------------------
[quote user="tincho" post="47345"]Al intentar leer metadatos de archivos de video no funciono[/quote]
Hola tincho,
prueba este codigo con la libreria libvlc:

[code linenumbers=false syntax=gambas]Library "libvlc:5.6.0"

Public Struct video_track_t
  i_height As Integer
  i_width As Integer
  i_sar_num As Integer
  i_sar_den As Integer
  i_frame_rate_num As Integer
  i_frame_rate_den As Integer
  i_orientation As Integer
  i_projection As Integer
  pose1 As Single
  pose2 As Single
  pose3 As Single
  pose4 As Single
  i_multiview As Byte
End Struct

Public Struct audio_track_t
  i_channels As Integer
  i_rate As Integer
End Struct

Private Enum libvlc_media_parse_local = 0,
             libvlc_media_parse_network,
             libvlc_media_fetch_local,
             libvlc_media_fetch_network = 4,
             libvlc_media_do_interact = 8

' libvlc_instance_t * libvlc_new (int argc, const char *const *argv)
' Create And initialize a libvlc instance.
Private Extern libvlc_new(argc As Integer, argv As String[]) As Pointer

' libvlc_media_t * libvlc_media_new_path (libvlc_instance_t *p_instance, const char *path)
' Create a media for a certain file path.
Private Extern libvlc_media_new_path(p_instance As Pointer, path As String) As Pointer

' int libvlc_media_parse_with_options (libvlc_media_t *p_md, libvlc_media_parse_flag_t parse_flag, int timeout)
' Parse the media asynchronously with options.
Private Extern libvlc_media_parse_with_options(p_md As Pointer, parse_flag As Integer, timeout As Integer) As Integer

' libvlc_time_t libvlc_media_get_duration(libvlc_media_t *p_md)
' Get duration (in ms) of media descriptor object item.
Private Extern libvlc_media_get_duration(p_md As Pointer) As Long

' char* libvlc_media_get_meta (libvlc_media_t * p_md, libvlc_meta_t e_meta)
' Read the meta of the media.
Private Extern libvlc_media_get_meta(p_md As Pointer, e_meta As Integer) As String

' unsigned libvlc_media_tracks_get (libvlc_media_t * p_md, libvlc_media_track_t *** tracks)
' Get media descriptor's elementary streams description.
Private Extern libvlc_media_tracks_get(p_md As Pointer, tracks As Pointer) As Integer

' const char * libvlc_media_get_codec_description (libvlc_track_type_t i_type, uint32_t i_codec)
' Get codec description from media elementary stream.
Private Extern libvlc_media_get_codec_description(i_type As Integer, i_codec As Integer) As String

' void libvlc_media_release (libvlc_media_t *p_md)
' Decrement the reference count of a media descriptor object.
Private Extern libvlc_media_release(p_md As Pointer)

' libvlc_release (libvlc_instance_t * p_instance)
' Decrement the reference count of a libvlc instance, and destroy it if it reaches zero.
Private Extern libvlc_release(p_instance As Pointer)


Public Sub Main()
 
  Dim inst, md, p1, p2 As Pointer
  Dim tm As Long
  Dim b As Byte 
  Dim s As String
  Dim tp, i As Integer
  Dim vt As Video_track_t
  Dim at As Audio_track_t
  Dim meta As String[] = ["Title:", "Artist:", "Genre", "Copyright:", "Album", "TrackNumber:",
                          "Description:", "Rating:", "Date:", "Setting:", "URL:",
                          "Language:", "NowPlaying:", "Publisher:", "EncodedBy:", "ArtworkURL:",
                          "TrackID:", "TrackTotal:", "Director:", "Season:", "Episode:",
                          "ShowName:", "Actors:", "AlbumArtist:", "DiscNumber:", "DiscTotal:"]
  Dim orient As String[] = ["Normal", "Flipped horizontally", "Flipped vertically", "Rotated 180 degrees",
                           "Transposed", "Rotated 90 degrees clockwise", "Rotated 90 degrees anti-clockwise", "Anti-transposed"]
 
  s = "/ruta/del/archivo/video"
  Print "Nome file:  "; s
  
  inst = libvlc_new(0, Null)
   
  md = libvlc_media_new_path(inst, s)
  
  libvlc_media_parse_with_options(md, libvlc_media_parse_local, 0)
  
  Sleep 0.1
  
  tm = libvlc_media_get_duration(md)
  Print "Durata:     "; Date(0, 0, 0, 0, 0, 0, tm)
  
  Print "\n- Metadati -"
  For b = 0 To meta.Max
    s = libvlc_media_get_meta(md, b)
    If Not IsNull(s) Then Print meta[b]; String(17 - Len(meta[b]), Chr(32)); s
  Next
  
  Print "\n- Codificatore -"
  p1 = Alloc(SizeOf(gb.Pointer), 3)
  p2 = VarPtr(p1)
  
  i = libvlc_media_tracks_get(md, VarPtr(p2))
For b = 0 To i - 1
  tp = Int@(Pointer@(p2 + (SizeOf(gb.Pointer) * b)) + 12)
  Print "Codifica:        "; libvlc_media_get_codec_description(tp, Int@(Pointer@(p2 + (SizeOf(gb.Pointer) * b))))
  Print "Tipo media:      ";
  Select Case tp
    Case -1
      Print "Unknown"
    Case 0
      Print "Audio"
      at = Pointer@(Pointer@(p2 + (SizeOf(gb.Pointer))) + 24)
      With at
        Print "Canali:          "; at.i_channels
        Print "Frequenza camp.: "; at.i_rate
      End With
    Case 1
      Print "Video"
      vt = Pointer@(Pointer@(p2) + 24)
      With vt
        Print "Risoluzione:     "; .i_width; "x"; .i_height
        Print "Fotogrammi/sec.: "; .i_frame_rate_num
        Print "Orientazione:    "; orient[.i_orientation]
      End With
    Case 2
    Print "Text"
  End Select
  Print
Next


' Libera la memoria:
  Free(p1)
  libvlc_media_release(md)
  libvlc_release(inst)
  
End[/code]


-----------------------------------
portaro
Viernes, 03 Enero 2020, 15:53

Re: Alguna Libreria Para Leer Metadatos De Fotos.
-----------------------------------
Tengo un problema extraño en la granja de Gambas - estoy en otro PC que es de 32 bits y me logeo y bajo o instalo el programa via la granja de gambas y sin darme mensaje de error me dice que lo instala o baja pero no lo tengo por ningun lado y comprobe /usr/bin a ver si no me salia en el menu pero me metia el programa en el camino y no estaba tampoco.

Ya me paso esto algunas veces unos programas se bajan y instalan bien pero otros no. Me acuerdo de algo similar por ejemplo con el juego 1945 que por mucho que instalaba no habia lanzador ni eu menu ni en camino de /usr/bin.
Lo hice funcionar bajando el debian por https://jsbsan.blogspot.com/2014/09/1945-el-juego.html

No se si esto os suele pasar pero podria ser por la maquina ser 32 bits y esos paquetes no estan en esa arquitectura o bien no existen?
No hay mensaje ninguno en la granja y el programa sale como bajado o instalado, aunque reintentes una cosa o otra muchas veces.



[url=https://postimg.cc/zbxY10rH][img]https://i.postimg.cc/zbxY10rH/2020-01-03-145249-1440x900-scrot.png[/img]


-----------------------------------
tincho
Viernes, 03 Enero 2020, 17:25

Re: Alguna Libreria Para Leer Metadatos De Fotos.
-----------------------------------
[quote user="vuott" post="47352"][quote user="tincho" post="47345"]Al intentar leer metadatos de archivos de video no funciono[/quote]
Hola tincho,
prueba este codigo con la libreria libvlc:
[/quote]
Ok, probare y comento luego. gracias Vuott.
Salludos.


-----------------------------------
tincho
Viernes, 03 Enero 2020, 17:28

Re: Alguna Libreria Para Leer Metadatos De Fotos.
-----------------------------------
[quote user="portaro" post="47355"]...lo instala o baja pero no lo tengo por ningun lado...[/quote]
Fijate en el directorio /tmp, es alli donde se descargan los programas y liego se copian a una carpeta en el directorio de tu usuaerio (este ultimo paso me parece que es lo que falla).
Saludos.


-----------------------------------
cogier
Viernes, 03 Enero 2020, 17:30

Re: Alguna Libreria Para Leer Metadatos De Fotos.
-----------------------------------
[quote]Tengo un problema extraño en la granja de gambas[/quote]

Pruebe a descargarlo desde [url=https://gambas.one/gambasfarm/?id=666&action=search]aquí.


-----------------------------------
portaro
Viernes, 03 Enero 2020, 21:54

Re: Alguna Libreria Para Leer Metadatos De Fotos.
-----------------------------------
[quote user="tincho" post="47357"][quote user="portaro" post="47355"]...lo instala o baja pero no lo tengo por ningun lado...[/quote]
Fijate en el directorio /tmp, es alli donde se descargan los programas y liego se copian a una carpeta en el directorio de tu usuaerio (este ultimo paso me parece que es lo que falla).
Saludos.[/quote]

Gracias lo revisare.

[quote user="cogier" post="47358"][quote]Tengo un problema extraño en la granja de gambas[/quote]

Pruebe a descargarlo desde [url=https://gambas.one/gambasfarm/?id=666&action=search]aquí.[/quote]


Gracias.
Ya descargue ese paquete y hice el deb para instalarlo pero me da el error supracitado arriba - qt5 y no soporta qt4 y un monton de errores si intentas cambiar a gtk.
 :D 

Gracias y un saludo a todos.


-----------------------------------
tincho
Viernes, 03 Enero 2020, 23:54

Re: Alguna Libreria Para Leer Metadatos De Fotos.
-----------------------------------
Bueno Vuott, adapte esta clase que nos compartiste para extraer los metadatos.
Logro extraer casi todos los metadatos que necesito para mi programa (que sirve para ordenar fotos y vídeos tomados con cámaras de fotos digitales), solo me falta extraer la fecha de creación del vídeo.
Algunos fabricantes llaman "Media Create Date" otros "Date/Time Original" etc. estas etiquetas se encuentran en los metadatos EXIF.
He buscado un rato largo en
https://www.olivieraubert.net/vlc/python-ctypes/doc/
Pero no encontré ninguna referencia a dichas etiquetas EXIF
Al parecer esta librería esta destinada a películas y no a vídeos familiares creados con una cámara digital (que es el tipo de archivos que intento ordenar)

Gracias Vuott por todos los aportes de código, son muy interesantes porque de a poco me voy metiendo en el uso de librerías C.

Pongo aquí el código tal como quedo.
[code linenumbers=false syntax=gambas]
' Gambas class file

Export

Library "libvlc:5.6.0"

Public Struct video_track_t
  i_height As Integer
  i_width As Integer
  i_sar_num As Integer
  i_sar_den As Integer
  i_frame_rate_num As Integer
  i_frame_rate_den As Integer
  i_orientation As Integer
  i_projection As Integer
  pose1 As Single
  pose2 As Single
  pose3 As Single
  pose4 As Single
  i_multiview As Byte
End Struct

Public Struct audio_track_t
  i_channels As Integer
  i_rate As Integer
End Struct

Private Enum libvlc_media_parse_local = 0,
  libvlc_media_parse_network,
  libvlc_media_fetch_local,
  libvlc_media_fetch_network = 4,
  libvlc_media_do_interact = 8

' libvlc_instance_t * libvlc_new (int argc, const char *const *argv)
' Create And initialize a libvlc instance.
Private Extern libvlc_new(argc As Integer, argv As String[]) As Pointer

' libvlc_media_t * libvlc_media_new_path (libvlc_instance_t *p_instance, const char *path)
' Create a media for a certain file path.
Private Extern libvlc_media_new_path(p_instance As Pointer, path As String) As Pointer

' int libvlc_media_parse_with_options (libvlc_media_t *p_md, libvlc_media_parse_flag_t parse_flag, int timeout)
' Parse the media asynchronously with options.
Private Extern libvlc_media_parse_with_options(p_md As Pointer, parse_flag As Integer, timeout As Integer) As Integer

' libvlc_time_t libvlc_media_get_duration(libvlc_media_t *p_md)
' Get duration (in ms) of media descriptor object item.
Private Extern libvlc_media_get_duration(p_md As Pointer) As Long

' char* libvlc_media_get_meta (libvlc_media_t * p_md, libvlc_meta_t e_meta)
' Read the meta of the media.
Private Extern libvlc_media_get_meta(p_md As Pointer, e_meta As Integer) As String

' unsigned libvlc_media_tracks_get (libvlc_media_t * p_md, libvlc_media_track_t *** tracks)
' Get media descriptor's elementary streams description.
Private Extern libvlc_media_tracks_get(p_md As Pointer, tracks As Pointer) As Integer

' const char * libvlc_media_get_codec_description (libvlc_track_type_t i_type, uint32_t i_codec)
' Get codec description from media elementary stream.
Private Extern libvlc_media_get_codec_description(i_type As Integer, i_codec As Integer) As String

' void libvlc_media_release (libvlc_media_t *p_md)
' Decrement the reference count of a media descriptor object.
Private Extern libvlc_media_release(p_md As Pointer)

' libvlc_release (libvlc_instance_t * p_instance)
' Decrement the reference count of a libvlc instance, and destroy it if it reaches zero.
Private Extern libvlc_release(p_instance As Pointer)

Public Function MediaData(f As String) As Collection

  Dim inst, md, p1, p2 As Pointer

  Dim tm As Long   ''Duración del flujo
  Dim b As Byte
  Dim s As String
  Dim tp, i As Integer
  Dim vt As Video_track_t
  Dim at As Audio_track_t

  Dim meta As String[] = ["Title:", "Artist:", "Genre", "Copyright:", "Album", "TrackNumber:",
    "Description:", "Rating:", "Date:", "Setting:", "URL:",
    "Language:", "NowPlaying:", "Publisher:", "EncodedBy:", "ArtworkURL:",
    "TrackID:", "TrackTotal:", "Director:", "Season:", "Episode:",
    "ShowName:", "Actors:", "AlbumArtist:", "DiscNumber:", "DiscTotal:"]

  Dim orient As String[] = ["Normal", "Flipped horizontally", "Flipped vertically", "Rotated 180 degrees",
    "Transposed", "Rotated 90 degrees clockwise", "Rotated 90 degrees anti-clockwise", "Anti-transposed"]

  Dim cn As New Collection
  Dim codec As String

  cn.Clear

  If Exist(f) Then

    inst = libvlc_new(0, Null)
    md = libvlc_media_new_path(inst, f)
    libvlc_media_parse_with_options(md, libvlc_media_parse_local, 0)

    Sleep 0.1

    tm = libvlc_media_get_duration(md)

    For b = 0 To meta.Max
      s = libvlc_media_get_meta(md, b)
      cn.Add(s, meta[b])
    Next

    p1 = Alloc(24)
    p2 = VarPtr(p1)

    i = libvlc_media_tracks_get(md, VarPtr(p2))

    For b = 0 To i - 1

      tp = Int@(Pointer@(p2 + (SizeOf(gb.Pointer) * b)) + 12)

      Select Case tp

        Case 0
          codec = libvlc_media_get_codec_description(tp, Int@(Pointer@(p2 + (SizeOf(gb.Pointer) * b))))
          cn.Add(codec, "AudioCodec")

          at = Pointer@(Pointer@(p2 + (SizeOf(gb.Pointer))) + 24)
          With at
            cn.Add(.i_channels, "Channels")
            cn.Add(.i_rate, "Rate")
          End With

        Case 1
          codec = libvlc_media_get_codec_description(tp, Int@(Pointer@(p2 + (SizeOf(gb.Pointer) * b))))
          cn.Add(codec, "VideoCodec")

          vt = Pointer@(Pointer@(p2) + 24)

          With vt
            cn.Add(.i_width & "x" & .i_height, "ImageSize")
            cn.Add(.i_frame_rate_num, "Frames/Sec")
            cn.Add(orient[.i_orientation], "Orientation")
          End With
        Case 2
          '
      End Select
    Next

    ' Libera la memoria:
    Free(p1)
    libvlc_media_release(md)
    libvlc_release(inst)

  Endif

  Return cn

End
[/code]

[u]Con la herramienta [b]exiftool[/b] recupero estos datos, entre otros[/u]
ImageWidth	1920
ImageHeight	1080
CompressorID	avc1
VideoFrameRate	29.932
MediaCreateDate	2019:01:01 01:01:01
MediaTimeScale	48000
MediaDuration	13.03 s
AudioFormat	mp4a
AudioChannels	2
AudioBitsPerSample	16
AudioSampleRate	48000
ImageSize	1920x1080
Rotation	0

[u]Mientras que con [b]libvlc[/b] recupero estos[/u]
Title:	test.mp4
Artist:	
Genre	
Copyright:	
Album	
TrackNumber:	
Description:	
Rating:	
Date:	
Setting:	
URL:	
Language:	
NowPlaying:	
Publisher:	
EncodedBy:	
ArtworkURL:	
TrackID:	
TrackTotal:	
Director:	
Season:	
Episode:	
ShowName:	
Actors:	
AlbumArtist:	
DiscNumber:	
DiscTotal:	
VideoCodec	H264 - MPEG-4 AVC (part 10)
ImageSize	1920x1080
Frames/Sec	17630
Orientation	Normal
AudioCodec	MPEG AAC Audio
Channels	2
Rate	48000

Saludos.


-----------------------------------
vuott
Sabado, 04 Enero 2020, 01:58

Re: Alguna Libreria Para Leer Metadatos De Fotos.
-----------------------------------
[quote user="tincho" post="47367"][u]Con la herramienta [b]exiftool[/b] recupero estos datos, entre otros[/u]
....
CompressorID	avc1
.......
AudioFormat	mp4a
[/quote]
Podemos obtener con VLC estos datos con estas lineas:
[code linenumbers=false syntax=gambas]c = mt.i_original_fourcc
...
Print "Formato audio:   "; Left(String@(VarPtr(c)), 4)
...
Print "CompressorID:    "; Left(String@(VarPtr(c)), 4)[/code]


es decir con este nuevisimo codigo:
[code linenumbers=false syntax=gambas]Library "libvlc:5.6.0"

Public Struct video_track_t
  i_height As Integer
  i_width As Integer
  i_sar_num As Integer
  i_sar_den As Integer
  i_frame_rate_num As Integer
  i_frame_rate_den As Integer
  i_orientation As Integer
  i_projection As Integer
  f_yaw As Single
  f_pitch As Single
  f_roll As Single
  f_field_of_view As Single
  i_multiview As Byte
End Struct

Public Struct audio_track_t
  i_channels As Integer
  i_rate As Integer
End Struct

Public Struct media_track_t
  i_codec As Integer
  i_original_fourcc As Integer
  i_id As Integer
  i_type As Integer
  i_profile As Integer
  i_level As Integer
  union As Pointer
  i_bitrate As Integer
  psz_language As Pointer
  psz_description As Pointer
End Struct

Private Enum libvlc_media_parse_local = 0,
             libvlc_media_parse_network,
             libvlc_media_fetch_local,
             libvlc_media_fetch_network = 4,
             libvlc_media_do_interact = 8

 'libvlc_instance_t * libvlc_new (int argc, const char *const *argv)
' Create And initialize a libvlc instance.
Private Extern libvlc_new(argc As Integer, argv As String[]) As Pointer

 'libvlc_media_t * libvlc_media_new_path (libvlc_instance_t *p_instance, const char *path)
' Create a media for a certain file path.
Private Extern libvlc_media_new_path(p_instance As Pointer, path As String) As Pointer

 'int libvlc_media_parse_with_options (libvlc_media_t *p_md, libvlc_media_parse_flag_t parse_flag, int timeout)
' Parse the media asynchronously with options.
Private Extern libvlc_media_parse_with_options(p_md As Pointer, parse_flag As Integer, timeout As Integer) As Integer

 'libvlc_time_t libvlc_media_get_duration(libvlc_media_t *p_md)
' Get duration (in ms) of media descriptor object item.
Private Extern libvlc_media_get_duration(p_md As Pointer) As Long

 'char* libvlc_media_get_meta (libvlc_media_t * p_md, libvlc_meta_t e_meta)
' Read the meta of the media.
Private Extern libvlc_media_get_meta(p_md As Pointer, e_meta As Integer) As String

 'unsigned libvlc_media_tracks_get (libvlc_media_t * p_md, libvlc_media_track_t *** tracks)
' Get media descriptor's elementary streams description.
Private Extern libvlc_media_tracks_get(p_md As Pointer, tracks As Pointer) As Integer

 'const char * libvlc_media_get_codec_description (libvlc_track_type_t i_type, uint32_t i_codec)
' Get codec description from media elementary stream.
Private Extern libvlc_media_get_codec_description(i_type As Integer, i_codec As Integer) As String

 'void libvlc_media_release (libvlc_media_t *p_md)
' Decrement the reference count of a media descriptor object.
Private Extern libvlc_media_release(p_md As Pointer)

 'libvlc_release (libvlc_instance_t * p_instance)
' Decrement the reference count of a libvlc instance, and destroy it if it reaches zero.
Private Extern libvlc_release(p_instance As Pointer)


Public Sub Main()

 Dim inst, md, p1, p2 As Pointer
 Dim tm As Long
 Dim b As Byte
 Dim s As String
 Dim tp, i, c As Integer
 Dim mt As Media_track_t
 Dim vt As Video_track_t
 Dim at As Audio_track_t
 Dim meta As String[] = ["Title:", "Artist:", "Genre", "Copyright:", "Album", "TrackNumber:",
                         "Description:", "Rating:", "Date:", "Setting:", "URL:",
                         "Language:", "NowPlaying:", "Publisher:", "EncodedBy:", "ArtworkURL:",
                         "TrackID:", "TrackTotal:", "Director:", "Season:", "Episode:",
                         "ShowName:", "Actors:", "AlbumArtist:", "DiscNumber:", "DiscTotal:"]
 Dim orient As String[] = ["Normal", "Flipped horizontally", "Flipped vertically", "Rotated 180 degrees",
                           "Transposed", "Rotated 90 degrees clockwise", "Rotated 90 degrees anti-clockwise", "Anti-transposed"]

 s = "/ruta/del/archivo/video"
 Print "Nome file:  "; s
 
 inst = libvlc_new(0, Null)
 
 md = libvlc_media_new_path(inst, s)
 
 libvlc_media_parse_with_options(md, libvlc_media_parse_local, 0)
 
 Sleep 0.1
 
 tm = libvlc_media_get_duration(md)
 Print "Durata:     "; Date(0, 0, 0, 0, 0, 0, tm)
 
 Print "\n- Metadati -"
 For b = 0 To meta.Max
   s = libvlc_media_get_meta(md, b)
   If Not IsNull(s) Then Print meta[b]; String(17 - Len(meta[b]), Chr(32)); s
 Next
 
 Print "\n- Codificatore -"
 p1 = Alloc(SizeOf(gb.Pointer), 3)
 p2 = VarPtr(p1)
  
 i = libvlc_media_tracks_get(md, VarPtr(p2))
 
 For b = 0 To i - 1
   mt = Pointer@(p2 + (SizeOf(gb.Pointer) * b))
   tp = mt.i_type

   c = mt.i_original_fourcc

   Print "Tipo media:      ";
   Select Case tp
     Case -1
       Print "Sconosciuto"
     Case 0
       Print "Audio"
       Print "Codifica:        "; libvlc_media_get_codec_description(tp, mt.i_codec)
       Print "Formato audio:   "; Left(String@(VarPtr(c)), 4)
       at = mt.union
       With at
         Print "Canali:          "; at.i_channels
         Print "Frequenza camp.: "; at.i_rate
       End With
     Case 1  
       Print "Video"
       Print "Codifica:        "; libvlc_media_get_codec_description(tp, mt.i_codec)
       Print "CompressorID:    "; Left(String@(VarPtr(c)), 4)
       vt = mt.union
       With vt
         Print "Risoluzione:     "; .i_width; "x"; .i_height
         Print "Fotogrammi/sec.: "; .i_frame_rate_num
         Print "Orientazione:    "; orient[.i_orientation]
       End With
     Case 2
       Print "Testo"
   End Select
   Print
 Next
 
 
' Libera la memoria:
 Free(p1)
 libvlc_media_release(md)
 libvlc_release(inst)
 
End[/code]


-----------------------------------
tincho
Sabado, 04 Enero 2020, 16:30

Re: Alguna Libreria Para Leer Metadatos De Fotos.
-----------------------------------
[quote user="vuott" post="47376"]...Podemos obtener con VLC estos datos con estas lineas...[/quote]
Perfecto gracias Vuott.
Por cierto Feliz cumpleaños !!  :mryellow: 

¿Has hecho algo con libmediainfo? ¿Esta escrita en c++ verdad?
¿Que hay de libffmpeg? ¿Esa si que es C verdad?
https://github.com/lince/libffmpeg-c/blob/master/src/libffmpeg.c

Saludos.


-----------------------------------
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.


-----------------------------------
vuott
Sabado, 04 Enero 2020, 19:00

Re: Alguna Libreria Para Leer Metadatos De Fotos.
-----------------------------------
[quote user="tincho" post="47377"]¿Has hecho algo con libmediainfo? ¿Esta escrita en c++ verdad?[/quote]
Sì.
En verdad es posible usar tambien C++, pero es más complejo, y su modalidad de escritura del codigo no me gusta.
Mira mi pagina en el wiki italiano:
https://www.gambas-it.org/wiki/index.php?title=Richiamare_funzioni_esterne_di_librerie_scritte_in_C%2B%2B




[quote user="tincho" post="47377"]¿Que hay de libffmpeg? ¿Esa si que es C verdad?[/quote]
Sì.


-----------------------------------
vuott
Sabado, 04 Enero 2020, 19:37

Re: Librerias Para Leer Metadatos De Fotos Y Videos.
-----------------------------------
[quote user="tincho" post="47378"]
[code linenumbers=false syntax=gambas]'// Agregado para intentar extraer la fecha de creción
.....
Private Extern lqt_get_creation_time(quicktime As Pointer, track As Integer) As Long[/code][/quote]
Una pregunta:
porque en Gambas tú declaras esta función con dos parametros formales, si ella solo tiene un parametro ?    :| 

   unsigned long lqt_get_creation_time ([color=#A50000]quicktime_t * file[/color])


