Gambas France BETA


Pas de compte ? Incription

Retrouver Informations VLC

Ce sujet est résolu.

1
AuteurMessages
valaquarus#1 Posté le 7/8/2024 à 17:31:53
-- Unus Ex Altera --Quand j'utilise ce morceau de code pour retrouver les informations de la video avec VLC, le lecteur se fige et plus rien ne se passe sans erreur.
Ça se fige ici, puisque j'y ai mis des balises
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
REPEAT
WAIT 0.01
i = libvlc_media_tracks_get(md, VarPtr(p))
'---------------- fige ici -------------
UNTIL i > 0

FOR b = 0 TO i - 1
mt = Pointer@(p + (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 "Dimensione: "; .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:
libvlc_media_release(md)
libvlc_release(inst)

END

J'aurais simplement besoin des dimensions de la video pour adapter la fenêtre.
Système d'exploitation : KDE neon 6.0 ~ Version Gambas : 3.19.5
vuott#2 Posté le 7/8/2024 à 18:57:30
Ne cedere ineluctabili possimus...fonctionne pour moi.
Essayez ceci:

<codex>
Library "libvlc:5"

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

'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, p 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 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:"]

s = "/chemin/du/FICHIER/vidéo"

Print "Chemin du fichier vidéo: "; s

inst = libvlc_new(0, Null)
If inst == 0 Then Error.Raise("Errore !")

md = libvlc_media_new_path(inst, s)
If md == 0 Then Error.Raise("Errore !")

libvlc_media_parse_with_options(md, libvlc_media_parse_local, 0)

tm = libvlc_media_get_duration(md)
Print "Durée: "; Time(0, 0, 0, tm)

Print "\n- \e[1mMétadonnées \e[0m-\n"
For n = 0 To meta.Max
s = libvlc_media_get_meta(md, n)
If Not IsNull(s) Then Print meta[n]; String(17 - Len(meta[n]), Chr(32)); s
Next

Repeat
Wait 0.01
i = libvlc_media_tracks_get(md, VarPtr(p))
Until i > 0

For n = 0 To i - 1
mt = Pointer@(p + (SizeOf(gb.Pointer) * n))
tp = mt.i_type

c = mt.i_original_fourcc

If tp == 1 Then
vt = mt.union
Print "\n\e[31mDimensions de la vidéo: \e[1m"; vt.i_width; "x"; vt.i_height
Endif
Next

' Libère la mémoire:
libvlc_media_release(md)
libvlc_release(inst)

End
</codex>
« Vita non suavis esse potest, nec Mors amara. »
valaquarus#3 Posté le 7/8/2024 à 19:14:28
-- Unus Ex Altera --Pas de chance :

Système d'exploitation : KDE neon 6.0 ~ Version Gambas : 3.19.5
vuott#4 Posté le 7/8/2024 à 20:47:04
Ne cedere ineluctabili possimusIl y a un problème de formatage:
La ligne est comme ceci :

Print "\n\e[31mDimensions de la vidéo: \e[1m"; vt.i_width; "x"; vt.i_height
« Vita non suavis esse potest, nec Mors amara. »
1