Using ffmpeg to obtain video durations in python

后端 未结 7 1095
故里飘歌
故里飘歌 2020-12-10 06:46

I\'ve installed ffprobe using the pip ffprobe command on my PC, and installed ffmpeg from here.

However, I\'m still having trouble running the code listed here.

7条回答
  •  情歌与酒
    2020-12-10 07:16

    I think Chamath's second comment answers the question: you have a strange character somewhere in your script, either because you are using a ` instead of a ' or you have a word with non-english accents, something like this.

    As a remark, for what you are doing you can also try MoviePy which parses the ffmpeg output like you do (but maybe in the future I'll use Chamath's ffprobe method it looks cleaner):

    import moviepy.editor as mp
    duration =  mp.VideoFileClip("my_video.mp4").duration
    

提交回复
热议问题