Recherche avancée

Médias (91)

Autres articles (64)

  • Participer à sa traduction

    10 avril 2011

    Vous pouvez nous aider à améliorer les locutions utilisées dans le logiciel ou à traduire celui-ci dans n’importe qu’elle nouvelle langue permettant sa diffusion à de nouvelles communautés linguistiques.
    Pour ce faire, on utilise l’interface de traduction de SPIP où l’ensemble des modules de langue de MediaSPIP sont à disposition. ll vous suffit de vous inscrire sur la liste de discussion des traducteurs pour demander plus d’informations.
    Actuellement MediaSPIP n’est disponible qu’en français et (...)

  • MediaSPIP v0.2

    21 juin 2013, par

    MediaSPIP 0.2 est la première version de MediaSPIP stable.
    Sa date de sortie officielle est le 21 juin 2013 et est annoncée ici.
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Comme pour la version précédente, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
    Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)

  • MediaSPIP version 0.1 Beta

    16 avril 2011, par

    MediaSPIP 0.1 beta est la première version de MediaSPIP décrétée comme "utilisable".
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Pour avoir une installation fonctionnelle, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
    Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)

Sur d’autres sites (7121)

  • Record Sound on Ubuntu Docker Image

    21 avril 2020, par Daniel Rasmuson

    I would like record audio with ffmpeg when I capture my screen. The error I'm getting when using alsa is that is that my image does not have a sound card -f alsa -ac 2 -i hw:0

    



    Here is how to reproduce on a fresh version of Ubuntu

    



    Start a session in a new ubuntu docker image.

    



    docker pull ubuntu
docker run -it --rm ubuntu


    



    Setup alsa (Advanced Linux Sound Architecture)

    



    apt-get update
apt-get install alsa-utils


    



    List the sound cards

    



    aplay -l
# aplay: device_list:268: no soundcards found...


    



    And playing this sound will fail because this image doesn't have any sound cards

    



    sudo aplay /usr/share/sounds/alsa/Front_Center.wav


    


  • Problem when adding background music to video without sound

    27 avril 2020, par Nguyễn Trọng

    I am trying to cut a piece of background music and loop them into a video and change the speed of the video with the command below.

    



     String[] cmd = {"-y", "-i", input, "-i", shortsound,
            "-filter_complex",
            "[0:v]trim=0:120,setpts=1/2*(PTS-STARTPTS)[v1]," +
                    "[0:v]trim=120:240,setpts=1/2*(PTS-STARTPTS)[v2];" +
                    "[1:a]atrim=0:6,asetpts=PTS-STARTPTS," +
                    "asetrate=44100,aloop=-1:2e+09," +
                    "aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo,volume=1.0[bg];" +
                    "[0:a]atrim=0:120,asetpts=PTS-STARTPTS,atempo=2.0" +
                    ",aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo[a1]," +
                    "[0:a]atrim=120:240,asetpts=PTS-STARTPTS,atempo=2.0," +
                    "aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo[a2];" +
                    "[v1][a1][v2][a2]concat=n=2:v=1:a=1[video][audio];[audio]volume=0.5[avolume];" +
                    "[avolume][bg]amerge=2,pan=stereo|c0code>

    



    Everything was fine until I tried with a video without sound, it didn't work.
How when input is a video without sound ?

    


  • FFmpeg Opus choppy sound

    15 mai 2020, par easy_breezy

    I'm using FFmpeg and try to encode and decode a raw PCM sound to Opus using a built-in FFmpeg "opus" codec. My input samples are raw PCM 8000 Hz 16 bit mono, in AV_SAMPLE_FMT_S16 format. Since Opus requires sample format AV_SAMPLE_FMT_FLTP and sample rate 48000 Hz only, so I resample my samples before encode them.

    



    I have two instances of ResamplerAudio class that does the work of resampling audio samples and has a member of SwrContext, I use the first instance of ResamplerAudio for resampling a raw PCM input audio before encoding and the second for resampling decoded audio to get it's format and sample rate the same as source values of input raw audio.

    



    ResamplerAudio class has a function that init it's SwrContext member like this :

    



    void ResamplerAudio::init(AVCodecContext *codecContext, int inSampleRate, int outSampleRate, AVSampleFormat inSampleFmt, AVSampleFormat outSampleFmt)
{
    swrContext = swr_alloc();
    if (!swrContext)
    {
        LOGE(TAG, "[init] Couldn't allocate swr context");
        return;
    }

    av_opt_set_int(swrContext, "in_channel_layout", (int64_t) codecContext->channel_layout, 0);
    av_opt_set_int(swrContext, "out_channel_layout", (int64_t) codecContext->channel_layout,  0);

    av_opt_set_int(swrContext, "in_channel_count", codecContext->channels, 0);
    av_opt_set_int(swrContext, "out_channel_count", codecContext->channels, 0);

    av_opt_set_int(swrContext, "in_sample_rate", inSampleRate, 0);
    av_opt_set_int(swrContext, "out_sample_rate", outSampleRate, 0);

    av_opt_set_sample_fmt(swrContext, "in_sample_fmt", inSampleFmt, 0);
    av_opt_set_sample_fmt(swrContext, "out_sample_fmt", outSampleFmt,  0);

    int ret = swr_init(swrContext);
    if (ret < 0)
    {
        LOGE(TAG, "[init] swr_init error: %s", av_err2str(ret));
        return;
    }

    LOGD(TAG, "[init] success codecContext->channel_layout: %d; inSampleRate: %d; outSampleRate: %d; inSampleFmt: %d; outSampleFmt: %d", (int) codecContext->channel_layout, inSampleRate, outSampleRate, inSampleFmt, outSampleFmt);
}


    



    And I call ResamplerAudio::init function for the first instance of ResamplerAudio (this instance do resamping a raw PCM input audio before encoding and I called it resamplerEncoder) with the following args :

    



    resamplerEncoder->init(contextEncoder, 8000, 48000, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP);


    



    The second instance of ResamplerAudio (this instance do resamping after decoding audio from Opus and I called it resamplerDecoder) I init with the following args :

    



    resamplerDecoder->init(contextDecoder, 48000, 8000, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_S16);


    



    The function of ResamplerAudio that do resampling looks like this :

    



    std::vector ResamplerAudio::convert(uint8_t **inData, int inSamplesCount, int outChannels, int outFormat)
{
    std::vector result;
    uint8_t *dstData = NULL;
    const int dstNbSamples = swr_get_out_samples(swrContext, inSamplesCount);
    av_samples_alloc(&dstData, NULL, outChannels, dstNbSamples, AVSampleFormat(outFormat), 1);
    int resampledSize = swr_convert(swrContext, &dstData, dstNbSamples, (const uint8_t **)inData, inSamplesCount);
    int dstBufSize = av_samples_get_buffer_size(NULL, outChannels, resampledSize, AVSampleFormat(outFormat), 1);

    if (dstBufSize <= 0) return result;

    std::copy(&dstData[0], &dstData[dstBufSize], std::back_inserter(result));

    return result;
}


    



    And I call ResamplerAudio::convert function before encoding with the following args :

    



    // data - an array of raw pcm audio
// dataLength - the length of data array
// getSamplesCount() - function that calculates samples count
// frameEncode - AVFrame that using for encode audio
std::vector resampledData = resamplerEncoder->convert(&data, getSamplesCount(dataLength, frameEncode->channels, AV_SAMPLE_FMT_S16), frameEncode->channels, frameEncode->format);


    



    getSamplesCount() function looks like this :

    



    getSamplesCount(int bytesCount, int channels, AVSampleFormat format)
{
    return bytesCount / av_get_bytes_per_sample(format) / channels;
}


    



    After that I fill my frameEncode with resampled samples :

    



    memcpy(&frame->data[0][0], &resampledData[0], sizeof(uint8_t) * resampledDataLength);


    



    And pass frameEncode to encoding like this encodeFrame(resampledDataLength) :

    



    void encodeFrame(int dataLength)
{
    /* send the frame for encoding */
    int ret = avcodec_send_frame(contextEncoder, frameEncode);
    if (ret < 0)
    {
        LOGE(TAG, "[encodeFrame] avcodec_send_frame error: %s", av_err2str(ret));
        return;
    }

    /* read all the available output packets (in general there may be any number of them */
    while (ret >= 0)
    {
        ret = avcodec_receive_packet(contextEncoder, packetEncode);
        if (ret < 0 && ret != AVERROR(EAGAIN)) LOGE(TAG, "[encodeFrame] error in avcodec_receive_packet: %s", av_err2str(ret));
        if (ret < 0) break;

        // encodedData - std::vector that stores encoded data
        std::copy(&packetEncode->data[0], &packetEncode->data[dataLength], std::back_inserter(encodedData));
        av_packet_unref(packetEncode);
    }
}


    



    Then I decode my encoded samples and do resampling to get back them in source sample format and sample rate so I call ResamplerAudio::convert function for resamplerDecoder with the following args :

    



    // frameDecode - AVFrame that holds decoded audio
std::vector resampledData = resamplerDecoder->convert(frameDecode->data, frameDecode->nb_samples, AV_SAMPLE_FMT_S16, frameDecode->channels);


    



    And result sound is choppy and I also noticed that the decoded array size is bigger than the source array size with raw pcm audio.

    



    Please any ideas what I'm doing wrong ?