Determine if file is audio or video

This forum is about all development around libVLC.
chundermike
New Cone
New Cone
Posts: 4
Joined: 18 Feb 2024 19:46

Determine if file is audio or video

Postby chundermike » 15 Mar 2024 23:17

Hi,

I'm trying to determine when reading a media file if it's audio only (i.e. mp3) or has video (i,e. mp4). If possible, I don't want to rely in the file extension. I've noticed a structure called libvlc_track_type_t (which has audio and video representations) but can't see any library function which uses it. Is it possible to determine if a file is audio only or is video using this structure or is there another way?

Thanks,
Mike

mfkl
Developer
Developer
Posts: 739
Joined: 13 Jun 2017 10:41

Re: Determine if file is audio or video

Postby mfkl » 20 Mar 2024 05:18

Sure I guess. These are tracks though, but if there is no video track, I guess you could assume it is an audio file.
https://mfkl.github.io

Gronky
Blank Cone
Blank Cone
Posts: 13
Joined: 31 Mar 2022 19:52

Re: Determine if file is audio or video

Postby Gronky » 14 Jun 2024 06:36

A quick and dirty (but far from foolproof) method would be to look at the first few bytes of the file - if it contains the string "ID3" you could be reasonably sure it's an MP3, or if it has the string "RIFF" you could be reasonably sure it's a wave audio file.


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 7 guests