Recherche avancée

Médias (91)

Autres articles (48)

  • Websites made ​​with MediaSPIP

    2 mai 2011, par

    This page lists some websites based on MediaSPIP.

  • Creating farms of unique websites

    13 avril 2011, par

    MediaSPIP platforms can be installed as a farm, with a single "core" hosted on a dedicated server and used by multiple websites.
    This allows (among other things) : implementation costs to be shared between several different projects / individuals rapid deployment of multiple unique sites creation of groups of like-minded sites, making it possible to browse media in a more controlled and selective environment than the major "open" (...)

  • Emballe Médias : Mettre en ligne simplement des documents

    29 octobre 2010, par

    Le plugin emballe médias a été développé principalement pour la distribution mediaSPIP mais est également utilisé dans d’autres projets proches comme géodiversité par exemple. Plugins nécessaires et compatibles
    Pour fonctionner ce plugin nécessite que d’autres plugins soient installés : CFG Saisies SPIP Bonux Diogène swfupload jqueryui
    D’autres plugins peuvent être utilisés en complément afin d’améliorer ses capacités : Ancres douces Légendes photo_infos spipmotion (...)

Sur d’autres sites (6964)

  • Create an audio file and fill it with the RTP package payload using ffmpeg

    24 août 2020, par WithoutExperience

    My task is to extract the payload of an RTP packet and save it as an audio file. In my case, I get the payload type - 8 (PCMA). I process RTP packets and store all the payload in a separate buffer. After that, I have to process this buffer and create an audio file. And that's my problem :(

    


    First, the specification says that in payload 8 (PCMA), audio samples are U8(bitRate / clockRate = 64000 / 8000) in size. But I can't even find a decoder for this sample size. What might be the problem ?

    


    Second, if I create synthetic sound, I can't record it in mka audio format.

    


    As a cheat sheet, I use this link.

    


    Based on this example, I wrote something similar :

    


    
class AudioGenerater
{
public:

    enum AudioFormatType
    {
        AudioFormat_WAV,
        AudioFormat_MP3
    };

public:

    AudioGenerater();
   ~AudioGenerater() = default;

    void generateAudioFileWithOptions(
            QString        fileName,
            QByteArray     pcmData,
            AVCodecID      codecID,
            int            channel,
            int            bitRate,
            int            sampleRate,
            AVSampleFormat format);

private:

    // init Format
    bool initFormat(QString audioFileName);

private:

    AVCodec         *m_AudioCodec        = nullptr;
    AVCodecContext  *m_AudioCodecContext = nullptr;
    AVFormatContext *m_FormatContext     = nullptr;
    AVOutputFormat  *m_OutputFormat      = nullptr;
};



    


    Cpp file :

    


    AudioGenerater::AudioGenerater()
{
    av_register_all();
    avcodec_register_all();
}

bool AudioGenerater::initFormat(QString audioFileName)
{
     // Create an output Format context
    int result = avformat_alloc_output_context2(&m_FormatContext, nullptr, nullptr, audioFileName.toLocal8Bit().data());
    if (result < 0) {
        return false;
    }

    m_OutputFormat = m_FormatContext->oformat;

     // Create an audio stream
    AVStream *audioStream = avformat_new_stream(m_FormatContext, m_AudioCodec);
    if (audioStream == nullptr) {
        avformat_free_context(m_FormatContext);
        return false;
    }

     // Set the parameters in the stream
    audioStream->id = m_FormatContext->nb_streams - 1;
    audioStream->time_base = { 1, 64000 };
    result = avcodec_parameters_from_context(audioStream->codecpar, m_AudioCodecContext);
    if (result < 0) {
        avformat_free_context(m_FormatContext);
        return false;
    }

     // Print FormatContext information
    av_dump_format(m_FormatContext, 0, audioFileName.toLocal8Bit().data(), 1);

     // Open file IO
    if (!(m_OutputFormat->flags & AVFMT_NOFILE)) {
        result = avio_open(&m_FormatContext->pb, audioFileName.toLocal8Bit().data(), AVIO_FLAG_WRITE);
        if (result < 0) {
            avformat_free_context(m_FormatContext);
            return false;
        }
    }

    return true;
}

void AudioGenerater::generateAudioFileWithOptions(
        QString _fileName,
        QByteArray _pcmData,
        AVCodecID _codecID,
        int _channel,
        int _bitRate,
        int _sampleRate,
        AVSampleFormat _format)
{
    AVCodecID codecID = _codecID;
    // Find Codec
    m_AudioCodec = avcodec_find_encoder(codecID);
    if (m_AudioCodec == nullptr) {
        return;
    }

     // Create an encoder context
    m_AudioCodecContext = avcodec_alloc_context3(m_AudioCodec);
    if (m_AudioCodecContext == nullptr){
        return;
    }

        // Setting parameters
    m_AudioCodecContext->bit_rate    = _bitRate;
    m_AudioCodecContext->sample_rate = _sampleRate;
    m_AudioCodecContext->sample_fmt  = _format;
    m_AudioCodecContext->channels    = _channel;


    m_AudioCodecContext->channel_layout = av_get_default_channel_layout(_channel);
    m_AudioCodecContext->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;

     // Turn on the encoder
    int result = avcodec_open2(m_AudioCodecContext, m_AudioCodec, nullptr);
    if (result < 0) {
        avcodec_free_context(&m_AudioCodecContext);
        if (m_FormatContext != nullptr)
            avformat_free_context(m_FormatContext);
        return;
    }

     // Create a package
    if (!initFormat(_fileName)) {
        avcodec_free_context(&m_AudioCodecContext);
        if (m_FormatContext != nullptr)
            avformat_free_context(m_FormatContext);
        return;
    }

     // write to the file header
    result = avformat_write_header(m_FormatContext, nullptr);
    if (result < 0) {
        avcodec_free_context(&m_AudioCodecContext);
        if (m_FormatContext != nullptr)
            avformat_free_context(m_FormatContext);
        return;
    }

     // Create Frame
    AVFrame *frame = av_frame_alloc();
    if (frame == nullptr) {
        avcodec_free_context(&m_AudioCodecContext);
        if (m_FormatContext != nullptr)
            avformat_free_context(m_FormatContext);
        return;
    }

    int nb_samples = 0;
    if (m_AudioCodecContext->codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE) {
        nb_samples = 10000;
    }
    else {
        nb_samples = m_AudioCodecContext->frame_size;
    }

    // Set the parameters of the Frame
    frame->nb_samples = nb_samples;
    frame->format = m_AudioCodecContext->sample_fmt;
    frame->channel_layout = m_AudioCodecContext->channel_layout;

    // Apply for data memory
    result = av_frame_get_buffer(frame, 0);
    if (result < 0)
    {
        av_frame_free(&frame); {
            avcodec_free_context(&m_AudioCodecContext);
            if (m_FormatContext != nullptr)
                avformat_free_context(m_FormatContext);
            return;
        }
    }

    // Set the Frame to be writable
    result = av_frame_make_writable(frame);
    if (result < 0)
    {
        av_frame_free(&frame); {
            avcodec_free_context(&m_AudioCodecContext);
            if (m_FormatContext != nullptr)
                avformat_free_context(m_FormatContext);
            return;
        }
    }

    int perFrameDataSize = frame->linesize[0];
    int count = _pcmData.size() / perFrameDataSize;
    bool needAddOne = false;
    if (_pcmData.size() % perFrameDataSize != 0)
    {
        count++;
        needAddOne = true;
    }

    int frameCount = 0;
    for (int i = 0; i < count; ++i)
    {
         // Create a Packet
        AVPacket *pkt = av_packet_alloc();
        if (pkt == nullptr) {
            avcodec_free_context(&m_AudioCodecContext);
            if (m_FormatContext != nullptr)
                avformat_free_context(m_FormatContext);
            return;
        }
        av_init_packet(pkt);

        if (i == count - 1)
            perFrameDataSize = _pcmData.size() % perFrameDataSize;

        // Synthesize WAV files
       memset(frame->data[0], 0, perFrameDataSize);
       memcpy(frame->data[0], &(_pcmData.data()[perFrameDataSize * i]), perFrameDataSize);


        frame->pts = frameCount++;
         // send Frame
        result = avcodec_send_frame(m_AudioCodecContext, frame);
        if (result < 0)
            continue;

         // Receive the encoded Packet
        result = avcodec_receive_packet(m_AudioCodecContext, pkt);
        if (result < 0)
        {
            av_packet_free(&pkt);
            continue;
        }

         // write to file
        av_packet_rescale_ts(pkt, m_AudioCodecContext->time_base, m_FormatContext->streams[0]->time_base);
        pkt->stream_index = 0;
        result = av_interleaved_write_frame(m_FormatContext, pkt);
        if (result < 0)
            continue;

        av_packet_free(&pkt);
    }

     // write to the end of the file
    av_write_trailer(m_FormatContext);
     // Close file IO
    avio_closep(&m_FormatContext->pb);
    // Release Frame memory
    av_frame_free(&frame);

    avcodec_free_context(&m_AudioCodecContext);
    if (m_FormatContext != nullptr)
        avformat_free_context(m_FormatContext);
}


    


    Main :

    


    int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    AudioGenerater generator;
    
    av_log_set_level(AV_LOG_DEBUG);
    av_log_set_flags(av_log_get_flags());
    
    QFile file("pcma.raw");
    if (!file.open(QIODevice::ReadOnly)) {
        return EXIT_FAILURE;
    }
    QByteArray pcmaData(file.readAll());
    
    generator.generateAudioFileWithOptions(
                "test.mka",
                pcmaData,
                AV_CODEC_ID_PCM_ALAW,
                1, 64000, 8000,
                AV_SAMPLE_FMT_U8);

    return a.exec();
}



    


    After I run the program, here are the errors that come out :

    


    [pcm_alaw @ 0x19229a0] Specified sample format u8 is invalid or not supported


    


    But if I set s16p instead of U8 format :

    


    generator.generateAudioFileWithOptions(
                "test.mka",
                pcmaData,
                AV_CODEC_ID_PCM_ALAW,
                1, 64000, 8000,
                AV_SAMPLE_FMT_S16P);


    


    I get twice as fast audio track, with a lot of noise. I need a sequential instruction encoding raw audio data into an audio file. Unfortunately, I don't understand what my error is.

    


  • Compile vlc-android on macos Sierra, many errors

    12 février 2017, par appworks

    This is the error message capture,Under MAC mini(macOS Sierra 10.12.3) :


    I’m trying to compile VLC-android player using MAC mini, the error message is below :

    {standard input}: Assembler messages:
    {standard input}:146: Error: unknown register alias 'GP'
    clang38: error: assembler command failed with exit code 1 (use -v to see invocation)
    make[1]: *** [libavcodec/arm/ac3dsp_armv6.o] Error 1
    make[1]: *** Waiting for unfinished jobs....
    {standard input}: Assembler messages:
    {standard input}:446: Error: unknown register alias 'POUT'
    {standard input}:448: Error: unknown register alias 'PIN'
    {standard input}:450: Error: unknown register alias 'PCOEF'
    {standard input}:452: Error: unknown register alias 'OLDFPSCR'

    What am I doing wrong ?

  • FATE Ends the Mac

    8 juin 2010, par Multimedia Mike — FATE Server

    Did you know Mac OS X can even blue-screen ? To be fair, it doesn’t actually present a blue screen. But when Mac OS X encounters a kernel panic, it looks like this :



    True to form, Mac just has to be prettier and glossier than other operating systems, even in the area of system crashes.

    The reason I bring this up is that the FATE system is bringing down my Mac. My Mac Mini is reliably dying every single time I try to execute my FATE client Python script. Maybe the weather is getting too warm.

    Update, 2010-6-8 : Following advice in the comments, I tried to run Memtest86 on the Mac Mini in question. I couldn’t get the machine to boot the CD I made. As an alternative, I turned the machine off and let it rest for a night. In the morning, I turned it on and ran the FATE client script. It’s working for now.