Recherche avancée

Médias (1)

Mot : - Tags -/Christian Nold

Autres articles (51)

  • Submit bugs and patches

    13 avril 2011

    Unfortunately a software is never perfect.
    If you think you have found a bug, report it using our ticket system. Please to help us to fix it by providing the following information : the browser you are using, including the exact version as precise an explanation as possible of the problem if possible, the steps taken resulting in the problem a link to the site / page in question
    If you think you have solved the bug, fill in a ticket and attach to it a corrective patch.
    You may also (...)

  • Personnaliser les catégories

    21 juin 2013, par

    Formulaire de création d’une catégorie
    Pour ceux qui connaissent bien SPIP, une catégorie peut être assimilée à une rubrique.
    Dans le cas d’un document de type catégorie, les champs proposés par défaut sont : Texte
    On peut modifier ce formulaire dans la partie :
    Administration > Configuration des masques de formulaire.
    Dans le cas d’un document de type média, les champs non affichés par défaut sont : Descriptif rapide
    Par ailleurs, c’est dans cette partie configuration qu’on peut indiquer le (...)

  • HTML5 audio and video support

    13 avril 2011, par

    MediaSPIP uses HTML5 video and audio tags to play multimedia files, taking advantage of the latest W3C innovations supported by modern browsers.
    The MediaSPIP player used has been created specifically for MediaSPIP and can be easily adapted to fit in with a specific theme.
    For older browsers the Flowplayer flash fallback is used.
    MediaSPIP allows for media playback on major mobile platforms with the above (...)

Sur d’autres sites (11216)

  • Decoding an MKA audio file into raw data of the pcm_alaw type (MKA Audio to pcm_alaw)

    2 octobre 2020, par bbdd

    My task is to open an existing audio file with the mka extension (Matroska container) and extract the raw audio data. If the audio data is different from pcm_alaw, then convert it to pcm_alaw before saving it to another file ( or buffer). This example shows only an example of extracting raw data from an mp2 file. I do not know how to do this with the mka container. I would like to have something like this :

    


    UPD

    


    I found an option to save audio data in the format in which it was recorded in the audio file. An example is shown below.

    


    PS. This is only a test version and most likely there are memory leaks and other problems.

    


    &#xA;#include <qfile>&#xA;#include <qdebug>&#xA;#include "audiodecoder.h"&#xA;&#xA;int main(int argc, char* argv[])&#xA;{&#xA;    AudioDecoder decoder("/home/test/test.mka");&#xA;    bool started = decoder.start();&#xA;    if (!started) {&#xA;        return EXIT_FAILURE;&#xA;    }&#xA;&#xA;    QFile file("/home/test/rawData.bin");&#xA;    file.open(QIODevice::WriteOnly);&#xA;&#xA;    while (true) {&#xA;        auto data = decoder.getData(255);&#xA;        if (data.isEmpty()) {&#xA;            break;&#xA;        }&#xA;        file.write(data.data(), data.size());&#xA;    }&#xA;    file.close();&#xA;    return EXIT_SUCCESS;&#xA;}&#xA;&#xA;</qdebug></qfile>

    &#xA;

    audiodecoder.h

    &#xA;

    class AudioDecoder {&#xA;public:&#xA;    AudioDecoder(const QString&amp; fileName);&#xA;    AudioDecoder&amp; operator=(const AudioDecoder&amp; rhs) = delete;&#xA;    AudioDecoder&amp; operator=(AudioDecoder&amp;&amp; rhs) = delete;&#xA;    AudioDecoder(const AudioDecoder&amp; rhs) = delete;&#xA;    AudioDecoder(AudioDecoder&amp;&amp; rhs) = delete;&#xA;    virtual ~AudioDecoder(void);&#xA;&#xA;    virtual bool start(void) noexcept;&#xA;    virtual QByteArray getData(const quint16&amp; size) noexcept;&#xA;    virtual bool stop(void) noexcept;&#xA;&#xA;protected:&#xA;    bool m_initialized;&#xA;    QString m_fileName;&#xA;&#xA;    AVFrame* p_frame = nullptr;&#xA;    AVPacket* p_packet = nullptr;&#xA;    AVCodecContext* p_cdcCtx = nullptr;&#xA;    AVFormatContext* p_frmCtx = nullptr;&#xA;};&#xA;

    &#xA;

    audiodecoder.cpp

    &#xA;

    &#xA;static void logging(const char* message)&#xA;{&#xA;    qDebug() &lt;&lt; message;&#xA;}&#xA;&#xA;AudioDecoder::AudioDecoder(const QString&amp; fileName)&#xA;    : m_initialized(false)&#xA;    , m_fileName(fileName)&#xA;    , p_cdcCtx(nullptr)&#xA;    , p_frmCtx(nullptr)&#xA;{&#xA;    av_register_all();&#xA;}&#xA;&#xA;QByteArray AudioDecoder::getData(const quint16&amp; dataSize) noexcept&#xA;{&#xA;    QByteArray data;&#xA;    qint32 response = 0;&#xA;    if (av_read_frame(p_frmCtx, p_packet) >= 0) {&#xA;        //logging(QString("AVPacket->pts %1").arg(p_packet->pts).toStdString().c_str());&#xA;        //response = decode_packet(p_packet, p_cdcCtx, p_frame);&#xA;        response = avcodec_send_packet(p_cdcCtx, p_packet);&#xA;        if (response &lt; 0) {&#xA;            logging("Error while sending a packet to the decoder");&#xA;            return {};&#xA;        }&#xA;        while (response >= 0) {&#xA;            response = avcodec_receive_frame(p_cdcCtx, p_frame);&#xA;            if (response == AVERROR(EAGAIN) || response == AVERROR_EOF) {&#xA;                break;&#xA;            }&#xA;            else if (response &lt; 0) {&#xA;                logging("Error while receiving a frame from the decoder");&#xA;                return {};&#xA;            }&#xA;            if (response >= 0) {&#xA;                logging(QString("Frame %1 (type=%2, size=%3 bytes) pts %4 key_frame %5 [DTS %6], duration[%7]")&#xA;                            .arg(p_cdcCtx->frame_number)&#xA;                            .arg(av_get_picture_type_char(p_frame->pict_type))&#xA;                            .arg(p_frame->pkt_size)&#xA;                            .arg(p_frame->pts)&#xA;                            .arg(p_frame->key_frame)&#xA;                            .arg(p_frame->coded_picture_number)&#xA;                            .arg(p_frame->pkt_duration)&#xA;                            .toStdString()&#xA;                            .c_str());&#xA;&#xA;                for (int i = 0; i &lt; p_frame->linesize[0]; &#x2B;&#x2B;i) {&#xA;                    data.push_back(p_frame->data[0][i]);&#xA;                }&#xA;            }&#xA;        }&#xA;        av_packet_unref(p_packet);&#xA;        return data;&#xA;    }&#xA;    return {};&#xA;}&#xA;&#xA;bool AudioDecoder::start(void) noexcept&#xA;{&#xA;    if (m_initialized) {&#xA;        return true;&#xA;    }&#xA;&#xA;    int error;&#xA;    // Open the input file to read from it.&#xA;    if ((error = avformat_open_input(&amp;p_frmCtx,&#xA;             m_fileName.toStdString().c_str(), nullptr, nullptr))&#xA;        &lt; 0) {&#xA;        qDebug() &lt;&lt; "Could not open input file: " &lt;&lt; m_fileName;&#xA;        p_frmCtx = nullptr;&#xA;        return false;&#xA;    }&#xA;    // Get information on the input file (number of streams etc.).&#xA;    if ((error = avformat_find_stream_info(p_frmCtx, nullptr)) &lt; 0) {&#xA;        avformat_close_input(&amp;p_frmCtx);&#xA;        qDebug() &lt;&lt; __LINE__;&#xA;        return false;&#xA;    }&#xA;    // Make sure that there is only one stream in the input file.&#xA;    if ((p_frmCtx)->nb_streams != 1) {&#xA;        avformat_close_input(&amp;p_frmCtx);&#xA;        qDebug() &lt;&lt; __LINE__;&#xA;        return false;&#xA;    }&#xA;&#xA;    if (p_frmCtx->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_AUDIO) {&#xA;        avformat_close_input(&amp;p_frmCtx);&#xA;        qDebug() &lt;&lt; __LINE__;&#xA;        return false;&#xA;    }&#xA;&#xA;    // Find a decoder for the audio stream.&#xA;    AVCodec* input_codec = nullptr;&#xA;    if (!(input_codec = avcodec_find_decoder((p_frmCtx)->streams[0]->codecpar->codec_id))) {&#xA;        avformat_close_input(&amp;p_frmCtx);&#xA;        qDebug() &lt;&lt; __LINE__;&#xA;        return false;&#xA;    }&#xA;    // Allocate a new decoding context.&#xA;    AVCodecContext* avctx = avcodec_alloc_context3(input_codec);&#xA;    if (!avctx) {&#xA;        avformat_close_input(&amp;p_frmCtx);&#xA;        qDebug() &lt;&lt; __LINE__;&#xA;        return false;&#xA;    }&#xA;    // Initialize the stream parameters with demuxer information.&#xA;    error = avcodec_parameters_to_context(avctx, (p_frmCtx)->streams[0]->codecpar);&#xA;    if (error &lt; 0) {&#xA;        avformat_close_input(&amp;p_frmCtx);&#xA;        avcodec_free_context(&amp;avctx);&#xA;        qDebug() &lt;&lt; __LINE__;&#xA;        return false;&#xA;    }&#xA;    /* Open the decoder for the audio stream to use it later. */&#xA;    if ((error = avcodec_open2(avctx, input_codec, NULL)) &lt; 0) {&#xA;        avcodec_free_context(&amp;avctx);&#xA;        avformat_close_input(&amp;p_frmCtx);&#xA;        qDebug() &lt;&lt; __LINE__;&#xA;        return false;&#xA;    }&#xA;    /* Save the decoder context for easier access later. */&#xA;    p_cdcCtx = avctx;&#xA;    av_dump_format(p_frmCtx, 0, m_fileName.toStdString().c_str(), 0);&#xA;&#xA;    p_frame = av_frame_alloc();&#xA;    if (!p_frame) {&#xA;        logging("failed to allocated memory for AVFrame");&#xA;        return false;&#xA;    }&#xA;    p_packet = av_packet_alloc();&#xA;    if (!p_packet) {&#xA;        logging("failed to allocated memory for AVPacket");&#xA;        return false;&#xA;    }&#xA;    return m_initialized = true;&#xA;}&#xA;&#xA;bool AudioDecoder::stop(void) noexcept&#xA;{&#xA;    if (p_cdcCtx != nullptr) {&#xA;        avcodec_free_context(&amp;p_cdcCtx);&#xA;    }&#xA;    if (p_frmCtx != nullptr) {&#xA;        avformat_close_input(&amp;p_frmCtx);&#xA;    }&#xA;    return true;&#xA;}&#xA;&#xA;AudioDecoder::~AudioDecoder(void)&#xA;{&#xA;    stop();&#xA;}&#xA;

    &#xA;

    But the problem in this example is that I didn't implement the ability to get exactly the requested size of audio data. In my case, it's just ignored. And also, in this case, I extract and save audio data in the format in which it was originally recorded. How do I convert any audio data format to the one I need. For example, I get PCM_S16LE, but I want to convert it to PCM_ALAW.

    &#xA;

  • Trying to change extension of filename on an ffmpeg script

    22 janvier 2019, par prat67

    (first time posting a question here)

    So I’m looking to write a ffmmpeg script to automate encoding my files to VP9.
    The problem I’m having is when I try to strip the extension and add a new one.

    For example
    Demo.mp4

    Should change to
    Demo.webm

    I’m running this on a Ubuntu-16.04 (Server Non-GI Version)
    I’ve tried a few different ways to accomplish this (using google and other posts on StackOverflow) but I can’t seem to make it work

    This is the error I keep getting..

    line 31 : Demo.mp4+.vp9 : syntax error : invalid arithmetic operator (error token is ".mp4+.vp9")

    I’ve also commented (in the code below) where the syntax error is pointing to..

    #!/bin/bash

    # Welcome Message

    clear
    printf "====================================\n"
    printf "FFMPEG Encoder\n"
    printf "(Using HDR-4k Profile)\n"
    printf "====================================\n\n"
    printf " Loading Files in Current Directory...\n\n"
    sleep 3s


    # Variables

    i=1
    ext=".webm"
    vadd=4000000
    vsub=2000000


    # Iterate through files in current directory

    for j in *.{mp4,mkv};
    do
    echo "$i.$j"
    file[i]=$j
    i=$(( i + 1 ))
    done


    # Select File &amp; Bitrate

    printf "Enter file number\n"
    read fselect
    printf "${file[$fselect]}: Selected for encoding\n\n"

    printf "Enter Average Bitrate (Eg: 8000000)\n\n"
    read bselect


    # ***THIS IS WHERE THE PROBLEM IS***
    # Prepare output file, strip trailing extension (eg .mkv) and add .webm

    ftemp1="${file[$fselect]}"
    ftemp2="${ftemp1::-4}"
    fout="$(($ftemp2+$ext))"
    printf "Output file will be: $fout"
    printf "Preparing to encode..."
    sleep 5s


    # Encode with User-Defined Parameters

    ffmpeg -y -report -i ${file[$fselect]} -b:v $bselect -speed 4 -pass 1 \
     -pix_fmt yuv420p10le \
     -color_primaries 9 -color_trc 16 -colorspace 9 -color_range 1 \
     -maxrate "$(($bselect+$vadd))" -minrate "$(($bselect-$vsub))" \
     -profile:v 2 -vcodec libvpx-vp9 -f webm /dev/null &amp;&amp; \
    ffmpeg -y -report -i ${file[$fselect]} -b:v $bselect -pass 2 \
     -pix_fmt yuv420p10le \
     -color_primaries 9 -color_trc 16 -colorspace 9 -color_range 1 \
     -maxrate "$(($bselect+$vadd))" -minrate "$(($bselect-$vsub))" \
     -profile:v 2 -vcodec libvpx-vp9 \
    $fout

    I’m certain there is a much cleaner way to do this - but I’m not expecting help with that :P

    My suspicion is that I’m trying to add two different types of variables ? But I thought I defined them as strings..I could be wrong

    Please Help... lol

  • ffmpeg build from source fails in docker container ?

    24 mars 2016, par John Allard

    I’m trying to make some changes to the ffmpeg source code (yes, I’m a masochist), and to start I booted an Arch Linux docker container, installed the requirements, downloaded ffmpeg source code, and tried to compile, but I’m getting some extremely odd errors.

    compile command :

    ./configure --bindidr=~/ffmpeg_build --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libx264 --enable-nonfree

    Output :

    ./configure:unset:3338: no such has table element: mktemp
    pr: /tmp/ffconf.uQI7CeV.c: No such file or directory.
    pr: /tmp/ffconf.uQI7CeV.c: No such file or directory.
    pr: /tmp/ffconf.uQI7CeV.c: No such file or directory.
    pr: /tmp/ffconf.uQI7CeV.c: No such file or directory.
    ... (24 times)
    pr: /tmp/ffconf.uQI7CeV.c: No such file or directory.
    pr: /tmp/ffconf.r547UgWy.m: No such file or directory.
    ./configure:53378: parse error near '}'
    ==> ERROR" A failure occured in build()
       Aborting...
    The build failed.

    This doesn’t seem to be a problem with ffmpeg, more a problem with the container. If I check find /tmp -name ffconf\* I see that the files do exist and they contain

    extern int getrusage();
    int main(void){ getrusage(); }

    what in the hell is going on ? hash tabled ? mktemp not working ? files not being found ?

    edit-

    here is what is on the line numbers in the files that give the errors

    3338:configure - unset -f mktemp
    5338:configure - check_builtin gmtime_r time.g "time_t * time; strict tm*; gmtime_r(time, tm)"

    edit2 - Here’s the dockerfile (cloned from here https://hub.docker.com/r/greyltc/archlinux/ /dockerfile/)

    # Arch Linux baseline docker container
    # Generated on Sat Mar 19 14:26:28 GMT 2016 using code in this GitHub repo:
    # https://github.com/greyltc/docker-archlinux
    FROM scratch
    MAINTAINER Grey Christoforo &lt;grey@christoforo.net&gt;

    # copy in super minimal root filesystem archive
    ADD archlinux.tar.xz /

    # perform initial container setup tasks
    RUN setup-arch-docker-container

    # this allows the system profile to be sourced at every shell
    ENV ENV /etc/profile