Recherche avancée

Médias (91)

Autres articles (94)

  • MediaSPIP 0.1 Beta version

    25 avril 2011, par

    MediaSPIP 0.1 beta is the first version of MediaSPIP proclaimed as "usable".
    The zip file provided here only contains the sources of MediaSPIP in its standalone version.
    To get a working installation, you must manually install all-software dependencies on the server.
    If you want to use this archive for an installation in "farm mode", you will also need to proceed to other manual (...)

  • Multilang : améliorer l’interface pour les blocs multilingues

    18 février 2011, par

    Multilang est un plugin supplémentaire qui n’est pas activé par défaut lors de l’initialisation de MediaSPIP.
    Après son activation, une préconfiguration est mise en place automatiquement par MediaSPIP init permettant à la nouvelle fonctionnalité d’être automatiquement opérationnelle. Il n’est donc pas obligatoire de passer par une étape de configuration pour cela.

  • Amélioration de la version de base

    13 septembre 2013

    Jolie sélection multiple
    Le plugin Chosen permet d’améliorer l’ergonomie des champs de sélection multiple. Voir les deux images suivantes pour comparer.
    Il suffit pour cela d’activer le plugin Chosen (Configuration générale du site > Gestion des plugins), puis de configurer le plugin (Les squelettes > Chosen) en activant l’utilisation de Chosen dans le site public et en spécifiant les éléments de formulaires à améliorer, par exemple select[multiple] pour les listes à sélection multiple (...)

Sur d’autres sites (6155)

  • HEVC with Alpha Encoding on Windows

    14 juillet 2023, par CodeVortex

    I know, this question has been asked before, but most of the answers to them are very old.

    


    Actually, I am developing a website which uses transparent videos. So, I am using .webm format for them. However, as you know it is not possible to run .webm with transparency on Apple products. So, after researching on internet(stackoverflow etc), I found a solution that I should convert my video into a series of PNGs and then convert them into HEVC with alpha channel. However, according to the research I done, only the Apple hardware can properly encode HEVC with alpha channel.

    


    I am a newbie to these codecs and formats stuff. So, I think that I read somewhere that latest versions of FFMPEG can also encode HEVC with alpha. However, being a noob I can't figure out any way to write a command for this purpose. Being a beginner with almost non-existent skills in this field of expertise, it is nearly impossible for me to understand the documentations correctly. I also tried using shutterencoder and some other tools but failed.

    


    Although, there is a quicktime .mov solution but with that the file size becomes too large for my 10 sec video, almost 334 mb and as you know this size is too large for a animation video on a landing-page style basic website.

    


    So, now my question is there any way to properly encode HEVC with alpha on Windows or Linux to maintain transparency ?

    


    If this is not possible, then is there any other way to create such transparent videos on Windows or Linux which can be played on browsers of Apple devices ?

    


    I am stuck on this for 3 days, So, any type of help is greatly regarded. I am also providing the link to my videos, if someone wants to take a closer look on codes and formats of these videos : Videos Link

    


    P.S : if anyone with a mac device can encode these transparent videos for me, then that would be best and I shall be very grateful to you

    


  • wav file from fluent-ffmpeg not working for asterisk if returned as stream nodejs

    7 mars 2023, par Sunil Garg

    I am using aws polly for text to speech and generating mp3 out of it, to get the certain wav as asterisk needs wav with specific paramters, I am using fluent-ffmpeg npm package.

    


    I generated the file by providing the destination path, and returned from the api using sendFile method on response. Here is the code

    


    _convertMp3ToWav(mp3Buffer, destPath) {
        const { options } = this;
        return new Promise((resolve, reject) => {
            ffmpeg(mp3Buffer)
                .audioFilter(`highpass=f=300, lowpass=f=3400`)
                .outputOptions([`-ar 8000`, `-ac 1`]
                .output(destPath)
                .on('error', (err) => {
                    log.error(`An error occured: ${err?.message || err?.stack}`);
                    reject({ err: 'Failed to convert from mp3 to wav' });
                })
                .on('end', async () => {
                    log.info(`successfully converted mp3 to wav at ${destPath}`);
                    resolve({ msg: "voice file generated" });
                }).run();
        });
    }

res.status(200).sendFile(wavFilePath)


    


    file is playable on local machine as well as working on asterisk server.

    


    But i tried to avoid intermediate file generation, generated the stream and returned that stream using res.send(buffer)

    


    Here is the code

    


    _convertMp3ToWav(mp3Buffer) {
        return new Promise((resolve, reject) => {
            // create a writable output stream to store wav stream
            const outputStream = new Stream.Writable();
            const buffer = [];
            // redefining _write function to write wav stream
            outputStream._write = function (chunk, encoding, done) {
                buffer.push(chunk);
                done();
            };
            // convert mp3 buffer to wav buffer 
            ffmpeg(mp3Buffer)
                .audioFilter(`highpass=f=300, lowpass=f=3400`)
                .outputOptions([`-ar 8000`, `-ac 1`])
                .output(outputStream)
                .format('wav')
                .on('error', (err) => {
                    log.error(`An error occured: ${err?.message || err?.stack}`);
                    reject({ err: 'Failed to convert from mp3 to wav' });
                })
                .on('end', async () => {
                    try {
                        // create wav buffer 
                        const wavBuffer = Buffer.concat(buffer);
                        log.info(`successfully converted mp3 to wav buffer`);
                        
                        resolve({ wavBuffer });
                    }
                    catch (err) {
                        log.error(`failed to create wav buffer : ${err?.message || err?.stack}`);
                        reject({ err: 'Failed to create wav buffer' });
                    }
                }).run();
        });
    }

const buffer = await this._convertMp3ToWav(bufferStream);
res.send(buffer.wavBuffer);


    


    I tried using as well

    


    // set content type to audio/wav
res.set('Content-Type', 'audio/wav');


    


    the file is playable on local but not working on asterisk.

    


    Is there any problem with sending or encoding issues ?

    


    Update1

    


    tried writing directly to the res like this

    


    _convertMp3ToWav(mp3Buffer, res) {
    return new Promise((resolve, reject) => {
        // create a writable output stream to send wav stream in response
        const outputStream = new Stream.Writable();
        outputStream._write = function (chunk, encoding, done) {
            res.write(chunk, encoding);
            done();
        };
        // convert mp3 buffer to wav buffer
        ffmpeg(mp3Buffer)
            .audioFilter(`highpass=f=300, lowpass=f=3400`)
            .outputOptions([`-ar 8000`, `-ac 1`])
            .output(outputStream)
            .format('wav')
            .on('error', (err) => {
              reject({ err: 'Failed to convert from mp3 to wav' });
            })
            .on('end', async () => {
                try {
         // end the response stream
                    res.end();
                    resolve();
                }
                catch (err) {
                    reject({ err: 'Failed to send wav buffer in response' });
                }
            }).run();
    });
}


    


    files generated from both functions mentioned in questions are not playable on asterisk, I checked the properties of these files using this website

    


    and both files are showing

    


    at least one of the list chunks has an incorrect length


    


    other properties that asterisk understands are the same

    


    enter image description here

    


    and this file i can play on windows machine. Any help ?

    


  • Use C# to converting apng to webm with ffmpeg from pipe input and output

    30 novembre 2022, par martin wang

    I was using ffmpeg to convert Line sticker from apng file to webm file.
And the result is weird, some of them was converted successed and some of them failed.
not sure what happend with these failed convert.

    


    Here is my c# code to convert Line sticker to webm,
and I use CliWrap to run ffmpeg command line.

    


    async Task Main()
{

    var downloadUrl = @"http://dl.stickershop.LINE.naver.jp/products/0/0/1/23303/iphone/stickerpack@2x.zip";
    var arg = @$"-i pipe:.png -vf scale=512:512:force_original_aspect_ratio=decrease:flags=lanczos -pix_fmt yuva420p -c:v libvpx-vp9 -cpu-used 5 -minrate 50k -b:v 350k -maxrate 450k -to 00:00:02.900 -an -y -f webm pipe:1";

    var errorCount = 0;
    try
    {
        using (var hc = new HttpClient())
        {
            var imgsZip = await hc.GetStreamAsync(downloadUrl);

            using (ZipArchive zipFile = new ZipArchive(imgsZip))
            {
                var files = zipFile.Entries.Where(entry => Regex.IsMatch(entry.FullName, @"animation@2x\/\d+\@2x.png"));
                foreach (var entry in files)
                {
                    try
                    {
                        using (var fileStream = File.Create(Path.Combine("D:", "Projects", "ffmpeg", "Temp", $"{Path.GetFileNameWithoutExtension(entry.Name)}.webm")))
                        using (var pngFileStream = File.Create(Path.Combine("D:", "Projects", "ffmpeg", "Temp", $"{entry.Name}")))
                        using (var entryStream = entry.Open())
                        using (MemoryStream ms = new MemoryStream())
                        {
                            entry.Open().CopyTo(pngFileStream);

                            var result = await Cli.Wrap("ffmpeg")
                                         .WithArguments(arg)
                                         .WithStandardInputPipe(PipeSource.FromStream(entryStream))
                                         .WithStandardOutputPipe(PipeTarget.ToStream(ms))
                                         .WithStandardErrorPipe(PipeTarget.ToFile(Path.Combine("D:", "Projects", "ffmpeg", "Temp", $"{Path.GetFileNameWithoutExtension(entry.Name)}Info.txt")))
                                         .WithValidation(CommandResultValidation.ZeroExitCode)
                                         .ExecuteAsync();
                            ms.Seek(0, SeekOrigin.Begin);
                            ms.WriteTo(fileStream);
                        }
                    }
                    catch (Exception ex)
                    {
                        entry.FullName.Dump();
                        ex.Dump();
                        errorCount++;
                    }
                }
            }

        }
    }
    catch (Exception ex)
    {
        ex.Dump();
    }
    $"Error Count:{errorCount.Dump()}".Dump();

}


    


    This is the failed convert file's error information from ffmpeg :

    


    enter image description here

    


    And the successed convert file from ffmpeg infromation :
enter image description here

    


    It's strange when I was manually converted these failed convert file from command line, and it will be converted successed.
enter image description here

    


    The question is the resource of images are all the same apng file,
so I just can't understan why some of files will convert failed from my c# code
but also when I manually use command line will be converted successed ?

    



    


    I have written same exampe from C# to Python...
and here is python code :

    


    from io import BytesIO
import os
import re
import subprocess
import zipfile

import requests


downloadUrl = "http://dl.stickershop.LINE.naver.jp/products/0/0/1/23303/iphone/stickerpack@2x.zip"
args = [
    'ffmpeg',
    '-i', 'pipe:',
    '-vf', 'scale=512:512:force_original_aspect_ratio=decrease:flags=lanczos',
    '-pix_fmt', 'yuva420p',
    '-c:v', 'libvpx-vp9',
    '-cpu-used', '5',
    '-minrate', '50k',
    '-b:v', '350k',
    '-maxrate', '450k', '-to', '00:00:02.900', '-an', '-y', '-f', 'webm', 'pipe:1'
]


imgsZip = requests.get(downloadUrl)
with zipfile.ZipFile(BytesIO(imgsZip.content)) as archive:
    files = [file for file in archive.infolist() if re.match(
        "animation@2x\/\d+\@2x.png", file.filename)]
    for entry in files:
        fileName = entry.filename.replace(
            "animation@2x/", "").replace(".png", "")
        rootPath = 'D:\\' + os.path.join("Projects", "ffmpeg", "Temp")
        # original file
        apngFile = os.path.join(rootPath, fileName+'.png')
        # output file
        webmFile = os.path.join(rootPath, fileName+'.webm')
        # output info
        infoFile = os.path.join(rootPath, fileName+'info.txt')

        with archive.open(entry) as file, open(apngFile, 'wb') as output_apng, open(webmFile, 'wb') as output_webm, open(infoFile, 'wb') as output_info:
            p = subprocess.Popen(args, stdin=subprocess.PIPE,
                                 stdout=subprocess.PIPE, stderr=output_info)
            outputBytes = p.communicate(input=file.read())[0]

            output_webm.write(outputBytes)
            file.seek(0)
            output_apng.write(file.read())



    


    And you can try it,the result will be the as same as C#.