MoviePy error: failed to read the duration of file

348 Views Asked by At

I am making a proyect that i need to take one video and extract its audio. after extracting the audio, we use this audio to transcribe and put it in a txt file. Below i put the code i have been using. This evening i get an error i have never had. `

from numpy import clip
import speech_recognition as sr
import moviepy.editor as mp
from moviepy.editor import *



#lectura de video
clip = mp.VideoFileClip("/Users/leti/OneDrive - Universidad Europea de Madrid/Proyecto Computacion I/Videos sin procesar/Sergio Procesados/Arroz_meloso_carabineros.mp4").subclip(0,150)

#extraemos el audio
clip.audio.write_audiofile("/Users/leti/OneDrive - Universidad Europea de Madrid/Proyecto Computacion I/Videos sin procesar/Sergio Procesados/Arroz_meloso_carabineros.wav")

#iniciamos el speechrecognition
r = sr.Recognizer()

#leemos el archivo audio extraido
audio = sr.AudioFile("/Users/leti/OneDrive - Universidad Europea de Madrid/Proyecto Computacion I/Videos sin procesar/Sergio Procesados/Arroz_meloso_carabineros.wav")
print("audio extraido")

#lectura de audio
with audio as source:
    r.adjust_for_ambient_noise(source)
    clean_file = r.record(source)

print("lectura terminada")
#reconocemos la voz del audio
result = r.recognize_google(clean_file,language="es-ES")



print("")
print(result)
#escribimos el texto en un nuevo archivo txt
with open('/Users/leti/OneDrive - Universidad Europea de Madrid/Proyecto Computacion I/Videos sin procesar/Sergio Procesados/Trans/Arroz_meloso_carabineros.txt','w') as file:
    file.write("RECOGNIZED SPEECH: \n") 
    file.write(result)
    #file.write(" "+result)

print("\nEscritura terminada")

``

the error I have had is as follows: `

OSError: MoviePy error: failed to read the duration of file /Users/leti/OneDrive - Universidad Europea de Madrid/Proyecto Computacion I/Videos sin procesar/Sergio Procesados/Arroz_meloso_carabineros.mp4.
Here are the file infos returned by ffmpeg:

ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9.2.1 (GCC) 20200122
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
/Users/leti/OneDrive - Universidad Europea de Madrid/Proyecto Computacion I/Videos sin procesar/Sergio Procesados/Arroz_meloso_carabineros.mp4: Invalid argument

`

0

There are 0 best solutions below