Recherche avancée

Médias (1)

Mot : - Tags -/belgique

Autres articles (37)

  • Support de tous types de médias

    10 avril 2011

    Contrairement à beaucoup de logiciels et autres plate-formes modernes de partage de documents, MediaSPIP a l’ambition de gérer un maximum de formats de documents différents qu’ils soient de type : images (png, gif, jpg, bmp et autres...) ; audio (MP3, Ogg, Wav et autres...) ; vidéo (Avi, MP4, Ogv, mpg, mov, wmv et autres...) ; contenu textuel, code ou autres (open office, microsoft office (tableur, présentation), web (html, css), LaTeX, Google Earth) (...)

  • List of compatible distributions

    26 avril 2011, par

    The table below is the list of Linux distributions compatible with the automated installation script of MediaSPIP. Distribution nameVersion nameVersion number Debian Squeeze 6.x.x Debian Weezy 7.x.x Debian Jessie 8.x.x Ubuntu The Precise Pangolin 12.04 LTS Ubuntu The Trusty Tahr 14.04
    If you want to help us improve this list, you can provide us access to a machine whose distribution is not mentioned above or send the necessary fixes to add (...)

  • Selection of projects using MediaSPIP

    2 mai 2011, par

    The examples below are representative elements of MediaSPIP specific uses for specific projects.
    MediaSPIP farm @ Infini
    The non profit organizationInfini develops hospitality activities, internet access point, training, realizing innovative projects in the field of information and communication technologies and Communication, and hosting of websites. It plays a unique and prominent role in the Brest (France) area, at the national level, among the half-dozen such association. Its members (...)

Sur d’autres sites (6269)

  • moviepy VideoFileClip IndexError : list index out of range, OSError : MoviePy error : failed to read the duration of file

    21 mai 2022, par Mohamed Medhat

    We are recording videos from the browser with the following encoding
'video/webm ; codecs="vp8, opus"', then we upload these videos to an AWS S3 bucket.
Our ML model works on these videos, and one of the models needs to extarct the audio and process it.
Here is a code snapit for extracting the audio

    


    import speech_recognition as sr
import moviepy.editor as me
from denoise2 import denoise
from sentence_transformers import SentenceTransformer
from sklearn.metrics.pairwise import cosine_similarity
import math

model_name = 'bert-base-nli-mean-tokens'
model = SentenceTransformer(model_name)


class recomm:
    y = 0.0

    def __init__(self, path, keywords):
        video_clip = me.VideoFileClip(r"{}".format(path))
        path2 = "y2.wav"
        video_clip.audio.write_audiofile(r"{}".format(path2), nbytes=2)
        recognizer = sr.Recognizer()
        """a = AudioSegment.from_wav(path2)
        a = a + 5
        a.export(path2, "wav")"""
        audio_clip = sr.AudioFile("{}".format(path2))
        with audio_clip as source:
            audio_file = recognizer.record(source)
        sent = []
        result = ""
        try:
            result = recognizer.recognize_google(audio_file)
        except sr.UnknownValueError:
            print("Can not process audio ")
        if not result:
            self.y = 0
        else:
            print(result)
            sent.append(result)
            sent = sent + keywords
            sent_vec3 = model.encode(sent)
            x = cosine_similarity(
                [sent_vec3[0]],
                sent_vec3[1:]
            )
            for i in range(len(x)):
                self.y = self.y + x[0][i]
            self.y = (self.y / (len(sent) - 1)) * 1000.0

    def res(self):
        if self.y < 0:
            self.y = 0
        return self.y


    


    And that's the traceback,
the error occurred at this line

    


    video_clip = me.VideoFileClip(r"{}".format(path))


    


    Traceback (most recent call last):
File "/home/medo/Dev/Smart-remotely-interviewing-system/backend/Process-interview/test/lib/python3.8/site-packages/moviepy/video/io/ffmpeg_reader.py", line 286, in ffmpeg_parse_infos
match = re.findall("([0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9])", line)[0]
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "main.py", line 90, in
main()
File "main.py", line 85, in main
interviews_channel.start_consuming()
File "/home/medo/Dev/Smart-remotely-interviewing-system/backend/Process-interview/test/lib/python3.8/site-packages/pika/adapters/blocking_connection.py", line 1865, in start_consuming
self._process_data_events(time_limit=None)
File "/home/medo/Dev/Smart-remotely-interviewing-system/backend/Process-interview/test/lib/python3.8/site-packages/pika/adapters/blocking_connection.py", line 2026, in _process_data_events
self.connection.process_data_events(time_limit=time_limit)
File "/home/medo/Dev/Smart-remotely-interviewing-system/backend/Process-interview/test/lib/python3.8/site-packages/pika/adapters/blocking_connection.py", line 833, in process_data_events
self._dispatch_channel_events()
File "/home/medo/Dev/Smart-remotely-interviewing-system/backend/Process-interview/test/lib/python3.8/site-packages/pika/adapters/blocking_connection.py", line 567, in _dispatch_channel_events
impl_channel._get_cookie()._dispatch_events()
File "/home/medo/Dev/Smart-remotely-interviewing-system/backend/Process-interview/test/lib/python3.8/site-packages/pika/adapters/blocking_connection.py", line 1492, in _dispatch_events
consumer_info.on_message_callback(self, evt.method,
File "main.py", line 79, in callback
processing(json.loads(body))
File "main.py", line 34, in processing
r = recomm(path, keywords)
File "/home/medo/Dev/Smart-remotely-interviewing-system/backend/Process-interview/recommendation.py", line 17, in init
video_clip = me.VideoFileClip(r"{}".format(path))
File "/home/medo/Dev/Smart-remotely-interviewing-system/backend/Process-interview/test/lib/python3.8/site-packages/moviepy/video/io/VideoFileClip.py", line 88, in init
self.reader = FFMPEG_VideoReader(filename, pix_fmt=pix_fmt,
File "/home/medo/Dev/Smart-remotely-interviewing-system/backend/Process-interview/test/lib/python3.8/site-packages/moviepy/video/io/ffmpeg_reader.py", line 35, in init
infos = ffmpeg_parse_infos(filename, print_infos, check_duration,
File "/home/medo/Dev/Smart-remotely-interviewing-system/backend/Process-interview/test/lib/python3.8/site-packages/moviepy/video/io/ffmpeg_reader.py", line 289, in ffmpeg_parse_infos
raise IOError(("MoviePy error: failed to read the duration of file %s.\n"
OSError: MoviePy error: failed to read the duration of file 74b74292-3642-486a-8319-255bb7e7da5a-1647363285285.webm.
Here are the file infos returned by ffmpeg:

ffmpeg version 4.2.2-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 8 (Debian 8.3.0-6)
configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-libgme --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi --enable-libzimg
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
Input #0, matroska,webm, from '74b74292-3642-486a-8319-255bb7e7da5a-1647363285285.webm':
Metadata:
encoder : Chrome
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0(eng): Audio: opus, 48000 Hz, mono, fltp (default)
Stream #0:1(eng): Video: vp8, yuv420p(progressive), 640x480, SAR 1:1 DAR 4:3, 29.42 fps, 29.42 tbr, 1k tbn, 1k tbc (default)
Metadata:
alpha_mode : 1
At least one output file must be specified


    


  • Error with IO.popen and ffmepg

    6 mars 2015, par Florian Dano Clement

    I received files in mp3 (2 minutes/files) I want to concatenate together and create a bigger file. So I created my model a function to do this using ffmpeg and IO.popen

    FileUtils.mkdir_p "#{Rails.root}/tmp/files"
    imported_dir = "#{Rails.root}/tmp/files/#{SecureRandom.uuid}"
    links.each_with_index do |link, index|
     file_path = "#{imported_dir}_#{index}#{File.extname(link)}"
     File.open(file_path, 'wb') do |file|
       file.write open(link).read
     end
     concat_list << "file '#{file_path}'\n"
    end
    File.open("#{imported_dir}.txt", 'w'){ |f| f.write(concat_list)}
    io = IO.popen("#{Rails.root}/lib/ffmpeg/ffmpeg -f concat -i #{imported_dir}.txt -c copy #{imported_dir}.mp3").readlines
    if sound = Sound.create(user_id: user.id, file: File.open("#{imported_dir}.mp3"), lang: lang, title: title)
     audio = FFMPEG::Movie.new("#{imported_dir}.mp3")
     if !audio.valid?
       puts "//_!_\\\\ Failed reading with ffmpeg (#{sound.id})#{sound.title} //_!_\\\\"
       return false
     end
    end

    the problem is that my .txt file containing the file path

    file '/home/test/apps/example/releases/20150305224026/tmp/files/4dbe9707-cfef-467b-ab2c-a5e1e1165953_0.mp3'

    created files as well but the final file is not created and i got the error message :

    No such file or directory @ rb_sysopen - /home/test/apps/example/releases/20150305224026/tmp/files/4dbe9707-cfef-467b-ab2c-a5e1e1165953.mp3

    If anyone could help me

  • how to add header info to a wav file to get a same result as ffmpeg ?

    30 avril 2023, par Q.Tong

    I'm trying to generate a .wav file with Fastspeech. When I save the data as .pcm file, and transfer it to .wav by ffmpeg, it works well.But when I just add a wav header info and save it into .wav, it sounds very noisy, What's wrong with my code ?

    


    code for pcm :

    


        wav = wav.astype(np.float32)
    wav = wav.tostring()
    with open('test.pcm', 'wb') as f:
        f.write(wav)


    


    ffmpeg command :

    


    ffmpeg -f f32le -ar 16000 -i test.pcm file.wav  # works well


    


    write wav straightly :

    


    import struct

def pcm2wav(sample_rate, pcm_voice):
    if pcm_voice.startswith("RIFF".encode()):
        return pcm_voice
    else:
        sampleNum = len(pcm_voice)
        rHeaderInfo = "RIFF".encode()
        rHeaderInfo += struct.pack('i', sampleNum + 44)
        rHeaderInfo += 'WAVEfmt '.encode()
        rHeaderInfo += struct.pack('i', 16)
        rHeaderInfo += struct.pack('h', 1)
        rHeaderInfo += struct.pack('h', 1)
        rHeaderInfo += struct.pack('i', sample_rate)
        rHeaderInfo += struct.pack('i', sample_rate * int(32 / 8))
        rHeaderInfo += struct.pack("h", int(32 / 8))
        rHeaderInfo += struct.pack("h", 32)
        rHeaderInfo += "data".encode()
        rHeaderInfo += struct.pack('i', sampleNum)
        rHeaderInfo += pcm_voice
        return rHeaderInfo

# .......
# get data with FastSpeech model
wav = wav.astype(np.float32)
wav = wav.tostring()
wav = pcm2wav(16000, wav)
with open('test.wav', 'wb') as f:
    f.write(wav)   # many noisy sounds