Recherche avancée

Médias (0)

Mot : - Tags -/navigation

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (67)

  • La file d’attente de SPIPmotion

    28 novembre 2010, par

    Une file d’attente stockée dans la base de donnée
    Lors de son installation, SPIPmotion crée une nouvelle table dans la base de donnée intitulée spip_spipmotion_attentes.
    Cette nouvelle table est constituée des champs suivants : id_spipmotion_attente, l’identifiant numérique unique de la tâche à traiter ; id_document, l’identifiant numérique du document original à encoder ; id_objet l’identifiant unique de l’objet auquel le document encodé devra être attaché automatiquement ; objet, le type d’objet auquel (...)

  • ANNEXE : Les plugins utilisés spécifiquement pour la ferme

    5 mars 2010, par

    Le site central/maître de la ferme a besoin d’utiliser plusieurs plugins supplémentaires vis à vis des canaux pour son bon fonctionnement. le plugin Gestion de la mutualisation ; le plugin inscription3 pour gérer les inscriptions et les demandes de création d’instance de mutualisation dès l’inscription des utilisateurs ; le plugin verifier qui fournit une API de vérification des champs (utilisé par inscription3) ; le plugin champs extras v2 nécessité par inscription3 (...)

  • Ajouter des informations spécifiques aux utilisateurs et autres modifications de comportement liées aux auteurs

    12 avril 2011, par

    La manière la plus simple d’ajouter des informations aux auteurs est d’installer le plugin Inscription3. Il permet également de modifier certains comportements liés aux utilisateurs (référez-vous à sa documentation pour plus d’informations).
    Il est également possible d’ajouter des champs aux auteurs en installant les plugins champs extras 2 et Interface pour champs extras.

Sur d’autres sites (6452)

  • Run python ffmpeg audio convertion code file from subprocess.call() within a flask server

    11 novembre 2019, par Kasun

    I have build a small flask server to handle the request. I have 3 parameters in the api function that i want to get. those are type, user_id, audio_file, One is a file. Since it’s used for the audio file conversion. I have to get a file.. I have tested with this in Postman audio file get saved but the subprocess.call(command) in the api function doesn’t work..

    this is the flask server code

    @app.route('/voice', methods=['GET','POST'])
    def process_audio():
    try:
       if request.method == 'POST':
           input_type = request.form['type']
           user_id = request.form['user_id']
           static_file = request.files['audio_file']
           audio_name = secure_filename(static_file.filename)
           path = 't/'
           status = static_file.save(path + audio_name)
           full_file = path + audio_name
           if input_type == 1:
               cmd = "python t/convert_english.py --audio " + full_file
               res = subprocess.call([cmd],shell=True)
               f = open('t/ress.txt', 'w')
               f.write(str(res))
               f.close()
               return "true"
           else:
               cmd = "python t/convert_sinhala.py --audio " + full_file
               os.system(cmd)
               return "true"
       else:
           return "false"

    except Exception as e:
       print(e)
       logger.error(e)
       return e

    The audio file get saved in the directory as expected..

    this is the convert_english.py

    import subprocess
    import argparse
    import os
    import logging
    import speech_recognition as sr
    from tqdm import tqdm
    from multiprocessing.dummy import Pool

    #subprocess.call('pip install pydub',shell=True)

    from os import path
    from pydub import AudioSegment

    logging.basicConfig(filename='/var/www/img-p/t/ee.log', level=logging.DEBUG,
                       format='%(asctime)s %(levelname)s %(name)s %(message)s')
    logger=logging.getLogger(__name__)

    ap = argparse.ArgumentParser()
    ap.add_argument("-a", "--audio", required=True,
       help="path to input audio file")
    args = vars(ap.parse_args())

    src = args["audio"]
    dst = "audio.wav"

    sound = AudioSegment.from_mp3(src)
    sound.export(dst, format="wav")

    #subprocess.call('pip install ffmpeg-python',shell=True)

    subprocess.call('mkdir parts',shell=True)

    subprocess.call('ffmpeg -i audio.wav -f segment -segment_time 30 -c copy parts/out%09d.wav',shell=True)

    #subprocess.call('pip install SpeechRecognition',shell=True)


    pool = Pool(8) # Number of concurrent threads

    with open("api-key.json") as f:
       GOOGLE_CLOUD_SPEECH_CREDENTIALS = f.read()

    r = sr.Recognizer()
    files = sorted(os.listdir('parts/'))

    def transcribe(data):
       idx, file = data
       name = "parts/" + file
       print(name + " started")
       # Load audio file
       with sr.AudioFile(name) as source:
           audio = r.record(source)
       # Transcribe audio file
       text = r.recognize_google_cloud(audio, credentials_json=GOOGLE_CLOUD_SPEECH_CREDENTIALS)
       print(name + " done")
       return {
           "idx": idx,
           "text": text
       }

    all_text = pool.map(transcribe, enumerate(files))
    pool.close()
    pool.join()

    transcript = ""
    for t in sorted(all_text, key=lambda x: x['idx']):
       total_seconds = t['idx'] * 30
       # Cool shortcut from:
       # https://stackoverflow.com/questions/775049/python-time-seconds-to-hms
       # to get hours, minutes and seconds
       m, s = divmod(total_seconds, 60)
       h, m = divmod(m, 60)

       # Format time as h:m:s - 30 seconds of text
       transcript = transcript + "{:0>2d}:{:0>2d}:{:0>2d} {}\n".format(h, m, s, t['text'])

    print(transcript)

    with open("transcript.txt", "w") as f:
       f.write(transcript)

    f = open("transcript.txt")
    lines = f.readlines()
    f.close()
    f = open("transcript.txt", "w", encoding="utf-8")
    for line in lines:
       f.write(line[8:])
    f.close()

    The thing is above code works when i manually run the command -> python t/convert_english.py —audio t/tttttttttt.mp3 like this in the terminal..

    But when i try to run from the flask server itself it doesn’t works.. And I’m not getting an error either.

  • FFMPEG not executing fully through python code but works from cmd

    3 mars 2020, par Shaun Micallef

    I am new to python and am trying to execute a cmd command using python like the following :

    os.system('cmd /c "ffmpeg -i {} -t 00:30 {}"'.format(videURLlink, video_name))

    when executing the above on my laptop it is working but on my pc it is not. the below is the result of the command execution but it doesn’t continue and stops there

    ffmpeg version 4.2 Copyright (c) 2000-2019 the FFmpeg developers
     built with gcc 9.1.1 (GCC) 20190807
     configuration: --disable-static --enable-shared --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
    [hls @ 0000016fa1800fc0] Skip ('#EXT-X-VERSION:3')
    [hls @ 0000016fa1800fc0] Opening 'https://hddn01.skylinewebcams.com/02900101X8TS-1583232346899.ts' for reading
    [hls @ 0000016fa1800fc0] Opening 'https://hddn01.skylinewebcams.com/02900101X8TS-1583232354899.ts' for reading
    [hls @ 0000016fa1800fc0] Could not find codec parameters for stream 1 (Audio: aac ([15][0][0][0] / 0x000F), 0 channels, fltp): unspecified sample rate
    Consider increasing the value for the 'analyzeduration' and 'probesize' options
    Input #0, hls, from 'https://hddn01.skylinewebcams.com/live.m3u8?a=bmnvut6ok8qfirptmtgu2j37c5':
     Duration: N/A, start: 18396.450000, bitrate: N/A
     Program 0
       Metadata:
         variant_bitrate : 0
       Stream #0:0: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 1280x1024, 12 fps, 12 tbr, 90k tbn, 180k tbc
       Metadata:
         variant_bitrate : 0
       Stream #0:1: Audio: aac ([15][0][0][0] / 0x000F), 0 channels, fltp
       Metadata:
         variant_bitrate : 0

    I am using anaconda as the python interpreter and migrated the environment from my laptop to my pc.If I execute the cmd directly through cmd it works. Any idea why ?

  • Error compiling FFMPEG / libav code after adding avfilter

    9 mai 2020, par Daniel Kobe

    My encoding and decoding was working fine using ffmpeg and libav, but then I added a filter in the encoding step to rotate my video and it no longer works in my docker machine, BUT it does work locally.

    



    The error message when compiling in docker is

    



    //usr/local/lib/libavfilter.a(vf_pp.o): In function `pp_init':
/var/tmp/ffmpeg/libavfilter/vf_pp.c:56: undefined reference to `pp_get_mode_by_name_and_quality'
//usr/local/lib/libavfilter.a(vf_pp.o): In function `pp_uninit':
/var/tmp/ffmpeg/libavfilter/vf_pp.c:161: undefined reference to `pp_free_mode'
/var/tmp/ffmpeg/libavfilter/vf_pp.c:163: undefined reference to `pp_free_context'
//usr/local/lib/libavfilter.a(vf_pp.o): In function `pp_filter_frame':
/var/tmp/ffmpeg/libavfilter/vf_pp.c:142: undefined reference to `pp_postprocess'
//usr/local/lib/libavfilter.a(vf_pp.o): In function `pp_config_props':
/var/tmp/ffmpeg/libavfilter/vf_pp.c:115: undefined reference to `pp_get_context'
collect2: error: ld returned 1 exit status


    



    These are my relevant configurations in docker file

    



    # Install libx264 for video encoding.
RUN cd /var/tmp && curl -L http://ftp.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20190103-2245-stable.tar.bz2 > x264.tar.bz2 && \
    echo "21cb6e2bb660f863713fb9f752654c65191e032dac1329ec113786c69f0f75c1  x264.tar.bz2" > x264.sha256sum && \
    shasum -a 256 -c x264.sha256sum && \
    tar xjf x264.tar.bz2 && \
    cd x264-snapshot-20190103-2245-stable && \
    ./configure \
        --enable-static \
        --enable-pic \
        --disable-cli \
        --disable-avs \
        --disable-opencl && \
    make -j8 && \
    make install-lib-static

# Compile ffmpeg.
COPY ffmpeg.tar /var/tmp/ffmpeg.tar
RUN cd /var/tmp && tar xf ffmpeg.tar && \
    cd ffmpeg && \
    ./configure \
        --cc=/usr/bin/clang-6.0 \
        --cxx=/usr/bin/clang++-6.0 \
        --extra-libs="-lpthread" \
        --enable-gpl \
        # without pic - opencv will throw up errors
        --enable-pic \
        --enable-libx264 \
        --disable-network && \
     make -j 8 && \
     make install


    



    Not sure this is relevant but here are my flags

    



    LDFLAGS: -lavcodec -lavfilter -lswscale -lavutil -lswresample -lx264 -lm -lz


    



    Here's my local ffmpeg configuration and version

    



    ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with Apple clang version 11.0.0 (clang-1100.0.33.17)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.2.2_2 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack
  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
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100


    



    Here's the output from my docker machine

    



    ffmpeg version 4.1.1 Copyright (c) 2000-2019 the FFmpeg developers
  built with clang version 6.0.0-1~bpo9+1 (tags/RELEASE_600/final)
  configuration: --cc=/usr/bin/clang-6.0 --cxx=/usr/bin/clang++-6.0 --extra-libs=-lpthread --enable-gpl --enable-pic --enable-libx264 --disable-network
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100


    



    How can I get my configuration fixed so it works like in local ? I didn't specifically configure my local environment so it's going to be using default configuration.