Recherche avancée

Médias (1)

Mot : - Tags -/getid3

Autres articles (67)

Sur d’autres sites (9318)

  • electron app fluent-ffmpeg " Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height"

    27 juillet 2020, par Martin

    I am trying to run an ffmpeg command in my electron app. I have created the function ffmpegTest() based off instructions for setting up ffmpeg here :

    


    https://alexandercleasby.dev/blog/use-ffmpeg-electron

    


    and the example query for ffmpeg-fluent here :

    


    https://github.com/fluent-ffmpeg/node-fluent-ffmpeg/blob/master/examples/image2video.js

    


    function ffmpegTest(){
    console.log('ffmpeg-test')
    //require the ffmpeg package so we can use ffmpeg using JS
    const ffmpeg = require('fluent-ffmpeg');
    //Get the paths to the packaged versions of the binaries we want to use
    const ffmpegPath = require('ffmpeg-static').replace(
        'app.asar',
        'app.asar.unpacked'
    );
    const ffprobePath = require('ffprobe-static').path.replace(
        'app.asar',
        'app.asar.unpacked'
    );
    //tell the ffmpeg package where it can find the needed binaries.
    ffmpeg.setFfmpegPath(ffmpegPath);
    ffmpeg.setFfprobePath(ffprobePath);
    
    var imgPath = "C:\\Users\\marti\\Documents\\martinradio\\uploads\\israel song festival 1979\\front.jpg"
    var outputPath = "C:\\Users\\marti\\Documents\\martinradio\\uploads\\israel song festival 1979\\output.m4v"

    // make sure you set the correct path to your video file
    var proc = ffmpeg(imgPath)
    // loop for 5 seconds
    .loop(5)
    // using 25 fps
    .fps(25)
    // setup event handlers
    .on('end', function() {
    console.log('file has been converted succesfully');
    })
    .on('error', function(err) {
    console.log('an error happened: ' + err.message);
    })
    // save to file
    .save(outputPath);

    console.log("end of ffmpeg-test")
}


    


    it is trying to convert an image to a video, my filepaths are accurate, but when I run this function, I get this output in console :

    


    ffmpeg-test
index.js:137 end of ffmpeg-test
index.js:132 an error happened: ffmpeg exited with code 1: Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Conversion failed!


    


    After the error prints out, I can see my output.m4v file inside my output folder, but it is 0KB in size and wont open. Is there some way I can specify my bit_rate / rate / width / height in my fluent-ffmpeg command so I can run this simple ffmpeg command ?

    


    thanks

    


  • Concatenating audio files and superimposing over video

    25 avril 2022, par kah

    I'm trying to write a program that takes a bunch of videos from a folder, compiles them, and then takes another bunch of audio files from a folder and concatenates them to then overlay the combined audio on top of the final video (hope that makes sense). I'm able to process the videos into one final output video, but I keep running into trouble combining the audio. Below I've provided two small sections of code pertaining to audio comp, I'm using moviepy to process the videos and attempting to use it for audio as well.

    


    songDirectory = './songs/'
songList = []
songs = []
audioclip=''

def makeCompilation():
    for filename in os.listdir(songDirectory):
        f = os.path.join(songDirectory, filename)
        if os.path.isfile(f) and filename.endswith(".mp3"):
            audioclip = moviepy.editor.AudioFileClip(f)
            songList.append(filename)


    for song in os.listdir(songDirectory):
        c = os.path.join(songDirectory, song)
    audio_clips = moviepy.editor.AudioFileClip(c)
    audio_output = moviepy.editor.concatenate_audioclips(audio_clips)
    finalClip = concatenate_videoclips(videos, method="compose")
    final_duration = finalClip.duration    
    final_audio_output = audio_output.set_duration(final_duration)
    final_output= finalClip.set_audio(final_audio_output).fx(afx.audio_fadein, 3.0)


    audio_path = "./songs/tempaudiofile.m4a"

    #print(description)
    # Create compilation
    final_output.write_videofile(outputFile, threads=8, temp_audiofile=audio_path, remove_temp=True, codec="libx264", audio_codec="aac")

    return description


    


    The program appeared to be able to find the audio directory, but I needed to be able to use os.path.join(songDirectory, filename) to point directly to each mp3 file so I messed around with it until I got the above code. And when I attempted to iterate through songList, I, as expected, got an error saying that 'str' wasn't iterable, and other errors saying that 'str' has no attribute 'duration'. Essentially, all I need it to do is iterate though the input folder and combine the files by whatever means. Code currently returns the output :

    


    &#127794;Free Fredobagz x Aflacko x Flint type beat - &#x27;Default_Dance&#x27; [prod. kah]-jro0v6ogZ0Y.mp4&#xA;225.05&#xA;Total Length: 225.05&#xA;225.05&#xA;Traceback (most recent call last):&#xA;  File "/Users/daddyK/Desktop/comp_ bot/make_compilation3.py", line 127, in <module>&#xA;makeCompilation(path = "./videos/",&#xA;  File "/Users/daddyK/Desktop/comp_ bot/make_compilation3.py", line 110, in makeCompilation&#xA;audio_output = moviepy.editor.concatenate_audioclips(audio_clips)&#xA;  File "/Users/daddyK/Library/Python/3.10/lib/python/site-packages/moviepy/audio/AudioClip.py", line 315, in concatenate_audioclips&#xA;durations = [c.duration for c in clips]&#xA;TypeError: &#x27;AudioFileClip&#x27; object is not iterable&#xA;</module>

    &#xA;


    &#xA;

    At this point I'm a bit stumped, so if anybody could offer some insight as to what I should do to resolve the error and/or if I'm headed in the right direction code-wise I'd greatly appreciate it ! Sorry if the code doesn't make any sense I'll post the whole .py file if needed

    &#xA;

  • Anomalie #4543 (Nouveau) : Accessibilité des chargements ajax (live regions)

    2 septembre 2020, par nicod _

    Suite à un audit de site par Temesis, il remonte que les attributs aria qu’on utilise sont mal placés.

    Je cite :

    Il semble qu’il y a un problème plus global avec l’utilisation des live region :
    Je rencontre à nouveau le div englobant div.ariaformprop qui possèdent les attributs

    aria-live
    aria-atomic
    aria-relevant

    Cette utilisation de ces attributs est erronée :

    elle ne donne pas le résultat probablement attendu
    le support d’aria-relevant dans les assistances technologiques n’est pas assuré

    Il est donc nécessaire de ne pas utiliser de live region sur une div englobante comme là.
    Il faut supprimer ces attributs et utiliser aria-live et aria-atomic avec parcimonie.

    J’ai regardé l’exemple que tu donnes sur spip.net également.

    L’exemple était : https://www.spip.net/spip.php?page=recherche&recherche=plugin&debut_articles=0#pagination_articles

    Cette prolifération d’aria-live + aria-atomic part probablement d’un bon sentiment, mais comme parfois avec l’accessibilité, le mieux est l’ennemi du bien.

    En positionnant ces attributs, avec ces valeurs, sur des div englobantes, cela génère dans les lecteurs d’écran la lecture automatique des contenus qui ont été mis à jour.

    Certes la lecture peut être interrompue par l’utilisateur, mais cela revient, à mon avis à imposer quelque chose qui n’a pas été forcément souhaité. De cette manière le propriétaire du site impose une expérience différente aux utilisateurs de lecteur d’écran.
    Ensuite, il faut bien entendu prendre en compte le contexte. Il pourrait arriver que ce comportement soit pertinent. Ce n’est pas le cas ici.

    Dans le cas de rechargement ajax, il faut étudier chaque cas et son contexte, mais le plus souvent le principe est :

    Ne pas utiliser ces attributs lorsqu’il n’y a pas d’interactions / rechargement ajax . Exemple sur un formulaire, cela n’a pas de sens : on rempli un form et puis on valide le form. A priori (si j’ai bien compris le fonctionnement) il n ’y a aucune raison d’utiliser de live region. En théorie, la présence de ces attributs s’il n’y a pas de rechargement ne devrait pas gêner. Mais certains lecteurs d’écran peuvent prendre des libertés par rapport aux spécifications et vocaliser des contenus tout de même. C’est pourquoi il faut être parcimonieux.

    Lorsqu’ils sont utiles et nécessaires, utiliser ces attributs pour informer d’un changement. Exemple : donner le nouveau nombre de résultats après utilisation de filtre. Mais il faut bien penser que dans plusieurs cas ils ne sont pas nécessaires, en effet, un bouton d’action doit être explicite avant qu’on appuie dessus. Donc par exemple : lorsque je demande à afficher la page 2 dans une pagination de résultat, il n’y a pas d’info à vocaliser automatiquement, le fait que le bouton dise "afficher la page 2" est suffisant, il serait superflu, voire gênant d’aller plus loin dans ce qui est vocalisé.

    Enfin, il faut gérer le focus clavier. Cet aspect est essentiel dès qu’il y a des interactions ajax, mais il dépend totalement du contexte. Et cet aspect est indépendant de la nécessité d’utiliser les live regions. Exemple : dans une série de filtre on va laisser le focus sur le filtre pour que l’utilisateur puisse parcourir la série de filtre. A contrario, dans une pagination (ou quand on a un bouton de type "afficher plus d’articles", dans des news ou dans une page de produits pour un site de e-commerce) on va déplacer le focus sur le 1er nouveau élément qui vient de s’afficher (la zone qui a été mise à jour).