Zulko / moviepy

Video editing with Python
https://zulko.github.io/moviepy/
MIT License
12.49k stars 1.56k forks source link

How to determine a file is audio or video? #704

Open yeonghoey opened 6 years ago

yeonghoey commented 6 years ago

I'm writing a Qt5 application, and want to set a widget's size based on the size of the media. The problem is, in my application, the media can be either audio or video, but VideoFileClip can be instantiated .mp3 files without error. On top of that, the videofileclip.size give an arbitrary size, even if its source file is an audio file.

I currently made do with checking the source file's extension. However, in the long run, I think this is not a proper way. I don't want to enumerate all types of audio file extensions in my code.

If it's possible, it will be great that moviepy supports this kind of function.

Anyway, thank you for the great value moviepy provides!

cranticumar commented 6 years ago

As moviepy installs imageio, which inturn installs ffmpeg. Cannot we use ffprobe filename, which will yield all streams media information?

If this implementation is OK, i can go ahead and submit a commit for review

mgaitan commented 6 years ago

I'm using the dictionary provided by moviepy at moviepy.tools.extensions_dict https://github.com/Zulko/moviepy/blob/master/moviepy/tools.py#L141

Check it here. https://github.com/mgaitan/miau/blob/master/miau.py#L261-L274

maybe we could generalize that as a little builtin function?

FujiwaraChoki commented 9 months ago

+1