Recherche avancée

Médias (91)

Autres articles (62)

  • Le profil des utilisateurs

    12 avril 2011, par

    Chaque utilisateur dispose d’une page de profil lui permettant de modifier ses informations personnelle. Dans le menu de haut de page par défaut, un élément de menu est automatiquement créé à l’initialisation de MediaSPIP, visible uniquement si le visiteur est identifié sur le site.
    L’utilisateur a accès à la modification de profil depuis sa page auteur, un lien dans la navigation "Modifier votre profil" est (...)

  • Configurer la prise en compte des langues

    15 novembre 2010, par

    Accéder à la configuration et ajouter des langues prises en compte
    Afin de configurer la prise en compte de nouvelles langues, il est nécessaire de se rendre dans la partie "Administrer" du site.
    De là, dans le menu de navigation, vous pouvez accéder à une partie "Gestion des langues" permettant d’activer la prise en compte de nouvelles langues.
    Chaque nouvelle langue ajoutée reste désactivable tant qu’aucun objet n’est créé dans cette langue. Dans ce cas, elle devient grisée dans la configuration et (...)

  • XMP PHP

    13 mai 2011, par

    Dixit Wikipedia, XMP signifie :
    Extensible Metadata Platform ou XMP est un format de métadonnées basé sur XML utilisé dans les applications PDF, de photographie et de graphisme. Il a été lancé par Adobe Systems en avril 2001 en étant intégré à la version 5.0 d’Adobe Acrobat.
    Étant basé sur XML, il gère un ensemble de tags dynamiques pour l’utilisation dans le cadre du Web sémantique.
    XMP permet d’enregistrer sous forme d’un document XML des informations relatives à un fichier : titre, auteur, historique (...)

Sur d’autres sites (3778)

  • fluent-ffmpeg from an array of input files

    30 juillet 2017, par leonard vertighel

    I want to use fluent-ffmpeg to create a video of last n images of a directory, or database entries.

    Which is the correct syntax ?

    These are my tries :

    Mimic shell command

    ffmpeg()
     .addInput('ls *png | tail -n 17')
     .inputOptions("-pattern_type glob")
     .output("output.mp4").run()

    but it does not accept shell commands ;

    space - separated paths

    ffmpeg()
     .addInput('a*.png b*.png ')
     .inputOptions("-pattern_type glob")
     .output("output.mp4").run()

    but it does not accept list of files separated by spaces ;

    Array of image paths

    ffmpeg()
     .addInput(array) // ['aa.png', 'a1.png',,,'bbb.png']
     .inputOptions("-pattern_type glob")
     .output("output.mp4").run()

    but it does not accept arrays.

    EDIT :

    Also, from Merge Multiple Videos using node fluent ffmpeg, I am able to add multiple inputs using an array of files as

    var ffmpeg= require('fluent-ffmpeg');
    var f=ffmpeg()
    pngarr.forEach(p => f.input(p)) /// pngarr is my array of png paths

    But running

    f.output("./output.mp4").run()

    I obtain just a video of 0 seconds containing the first png of the list.

  • 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.

  • How to plot animated time series in R ?

    28 août 2016, par pOrlando

    I am trying use the ’animation’ package in R to plot an animated time series.

    My dataset consists of a time vector and a value vector, each with 1800 rows.

    I keep getting an error message after running the loop which reads :

    Error in jpeg(gname[i]) : unable to start jpeg() device
    In addition: Warning messages:
    1: In jpeg(gname[i]) : unable to open file 'g11:30:00.jpg' for writing
    2: In jpeg(gname[i]) : opening device failed

    Here’s the source code

    timemax<-1800
    setwd("~/Documents/Animation/")
    graphdata<-read.csv("filling_line_data_construction_v2.csv")
    attach(graphdata)
    gname<-paste("g",time, ".jpg", sep="")
    for (i in 1:timemax){
       jpeg(gname[i])
       plot(time[1],value[1],type="l",ylim=c(0,35), xlim=c(0,100),
         ylim = c(0, 35),ylab = "", xlab="time")
       lines(time[1:i],value[1:i])
       dev.off(dev.cur())
    }

    The end goal is to string together these 1800 plots as a stop animation video by calling the ffmpeg shell :

    shell("C:/ffmpeg/bin/ffmpeg.exe -report -i g%d.jpg -b:v 2048k fillin_lineR.mpg",mustWork=FALSE)

    This is code that I’ve been trying to adapt from http://www.animatedgraphs.co.uk/LondonR.html#slide-30, but this example uses a .tif file instead of .jpg, and my computer gives me 1800 error messages when trying to make a video from .tif files...

    Thanks in advance !