Recherche avancée

Médias (1)

Mot : - Tags -/Christian Nold

Autres articles (55)

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

  • 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 (...)

  • Support audio et vidéo HTML5

    10 avril 2011

    MediaSPIP utilise les balises HTML5 video et audio pour la lecture de documents multimedia en profitant des dernières innovations du W3C supportées par les navigateurs modernes.
    Pour les navigateurs plus anciens, le lecteur flash Flowplayer est utilisé.
    Le lecteur HTML5 utilisé a été spécifiquement créé pour MediaSPIP : il est complètement modifiable graphiquement pour correspondre à un thème choisi.
    Ces technologies permettent de distribuer vidéo et son à la fois sur des ordinateurs conventionnels (...)

Sur d’autres sites (8863)

  • 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;

  • Getting realtime output of ffmpeg with pexpect or winpexpect

    27 février 2014, par Shuman

    hi i'm trying to get the progress info when calling ffmpeg command line tool, with pexpect, i can get the progress with regex, but the problem is after a few seconds, maybe 20 or 10sec, pexpect stops getting new print outs from ffmpeg, it's still running, i saw the output file size growing. am i doing something wrong ?

    cmd = &#39;ffmpeg -i rtmp://xxxx -c copy -absf aac_adtstoasc /usr/tmp/tmp/out.mp4&#39;

    import os
    import re
    import time
    import subprocess


    import pexpect

    thread = pexpect.spawn(cmd)

    print &#39;started&#39;

    reo = re.compile("""\S+\s+(?P\d+)  # frame
                        \s\S+\s+(?P<fps>\d+)           # fps
                        \sq=(?P<q>\S+)                    # q
                        \s\S+\s+(?P<size>\S+)          # size
                        \stime=(?P<time>\S+)           # time
                        \sbitrate=(?P<bitrate>[\d\.]+) # bitrate
                        """, re.X)

    durationReo = (&#39;(?&lt;=Duration:\s)\S+(?=,)&#39;)

    cpl = thread.compile_pattern_list([
       pexpect.EOF,
       reo,
       durationReo
    ])


    while True:
       i = thread.expect_list(cpl, timeout=None)
       if i == 0: # EOF
           print "the sub process exited"
           break
       elif i == 1:
           frame_number = thread.match.group(0)
           print frame_number
       elif i == 2:
           durationLine = thread.match.group(0).strip()
           print &#39;Duration:&#39;, durationLine
    </bitrate></time></size></q></fps>

    the output is

    started                                                                                  
    Duration: 03:55:42.00                                                                    
    frame=   74 fps= 55 q=-1.0 size=     984kB time=00:00:06.17 bitrate=1304.5                
    frame=   89 fps= 43 q=-1.0 size=    1197kB time=00:00:07.43 bitrate=1319.8                
    frame=  113 fps= 41 q=-1.0 size=    1407kB time=00:00:09.33 bitrate=1234.8
    frame=  125 fps= 32 q=-1.0 size=    1613kB time=00:00:10.35 bitrate=1275.6
    frame=  132 fps= 29 q=-1.0 size=    1705kB time=00:00:10.95 bitrate=1274.7
    frame=  135 fps= 26 q=-1.0 size=    1825kB time=00:00:11.23 bitrate=1330.6
    frame=  140 fps= 24 q=-1.0 size=    2022kB time=00:00:11.60 bitrate=1426.5
    frame=  140 fps= 21 q=-1.0 size=    2097kB time=00:00:11.70 bitrate=1467.7
    frame=  142 fps= 19 q=-1.0 size=    2224kB time=00:00:11.79 bitrate=1544.4
    frame=  143 fps= 17 q=-1.0 size=    2447kB time=00:00:11.98 bitrate=1672.8
    frame=  145 fps= 16 q=-1.0 size=    2687kB time=00:00:12.07 bitrate=1822.8
    frame=  155 fps= 15 q=-1.0 size=    2780kB time=00:00:12.95 bitrate=1757.6
    frame=  163 fps= 15 q=-1.0 size=    2940kB time=00:00:13.65 bitrate=1764.2
    frame=  167 fps= 14 q=-1.0 size=    3062kB time=00:00:13.83 bitrate=1812.3
    frame=  168 fps= 13 q=-1.0 size=    3149kB time=00:00:14.02 bitrate=1839.4
    frame=  190 fps= 14 q=-1.0 size=    3322kB time=00:00:15.78 bitrate=1723.6
    frame=  213 fps= 15 q=-1.0 size=    3481kB time=00:00:17.78 bitrate=1603.4
    frame=  235 fps= 16 q=-1.0 size=    3671kB time=00:00:19.59 bitrate=1534.3
    frame=  244 fps= 16 q=-1.0 size=    3790kB time=00:00:20.29 bitrate=1530.0
    frame=  256 fps= 16 q=-1.0 size=    3909kB time=00:00:21.31 bitrate=1502.1
    frame=  276 fps= 16 q=-1.0 size=    4029kB time=00:00:22.94 bitrate=1438.8
    frame=  299 fps= 17 q=-1.0 size=    4177kB time=00:00:24.93 bitrate=1372.1
    frame=  339 fps= 19 q=-1.0 size=    4388kB time=00:00:28.28 bitrate=1270.9
    frame=  363 fps= 19 q=-1.0 size=    4557kB time=00:00:30.18 bitrate=1236.8
    frame=  405 fps= 20 q=-1.0 size=    4587kB time=00:00:33.76 bitrate=1113.1
    frame=  421 fps= 20 q=-1.0 size=    4598kB time=00:00:35.15 bitrate=1071.4

    it stops here but the code is still running. the file size is still growing and the code didn't exit, so it's not because of the timeout bug in pexpect.

    and also , if user press ctrl+c to terminate the main program, ffmpeg still runs in the bg, how do i also tell it to exit ?

    edit : i found that the culprit might be ffmpeg is not printing out all the info after 10 lines or so. it only update the display where it needs to be changed.so the regex is not matching, so what to do now , make 6 seperate regex ?

    edit2 : it seems if i use this regex, it works...

    reo = re.compile("""frame=\s*(?P\d+)  # frame
                        \sfps=\s*(?P<fps>\d+)           # fps
                        \sq=\s*(?P<q>\S+)                    # q
                        \ssize=\s*(?P<size>\S+)          # size
                        \stime=\s*(?P<time>\S+)           # time
                        \sbitrate=\s*(?P<bitrate>[\d\.]+) # bitrate
                        """, re.X)
    </bitrate></time></size></q></fps>

    it's saying only match when frame number is updated, ( maybe this implies all the other text are also updated ? )

    edit3 : in linux it's working, but under windows, i don't know how to get it to work with this latest forked winpexpect

    basically i'm using the same code

    import winpexpect
    thread = winpexpect.winspawn(cmd,timeout=99999999999 )

    there is another problem winpexpect.EOF seems not working, every new line caused a match

  • I Really Like My New EeePC

    29 août 2010, par Multimedia Mike — General

    Fair warning : I’m just going to use this post to blather disconnectedly about a new-ish toy.

    I really like my new EeePC. I was rather enamored with the original EeePC 701 from late 2007, a little box with a tiny 7″ screen that is credited with kicking off the netbook revolution. Since then, Asus has created about a hundred new EeePC models.

    Since I’m spending so much time on a train these days, I finally took the plunge to get a better netbook. I decided to stay loyal to Asus and their Eee lineage and got the highest end EeePC they presently offer (which was still under US$500)– the EeePC 1201PN. The ’12′ in the model number represents a 12″ screen size and the rest of the specs are commensurately as large. Indeed, it sort of blurs the line between netbook and full-blown laptop.



    Incidentally, after I placed the order for the 1201PN nearly 2 months ago, and I mean the very literal next moment, this Engadget headline came across announcing the EeePC 1215N. My new high-end (such as it is) computer purchase was immediately obsoleted ; I thought that only happened in parody. (As of this writing, the 1215N still doesn’t appear to be shipping, though.)

    It’s a sore point among Linux aficionados that Linux was used to help kickstart the netbook trend but that now it’s pretty much impossible to find Linux pre-installed on a netbook. So it is in this case. This 1201PN comes with Windows 7 Home Premium installed. This is a notable differentiator from most netbooks which only have Windows 7 Home Starter, a.k.a., the Windows 7 version so crippled that it doesn’t even allow the user to change the background image.

    I wished to preserve the Windows 7 installation (you never know when it will come in handy) and dual boot Linux. I thought I would have to use the Windows partition tool to divide work some magic. Fortunately, the default installation already carved the 250 GB HD in half ; I was able to reformat the second partition and install Linux. The details are a little blurry, but I’m pretty sure one of those external USB optical drives shown in my last post actually performed successfully for this task. Lucky break.



    The EeePC 1201PN, EeePC 701, Belco Alpha-400, and even a comparatively gargantuan Sony Vaio full laptop– all of the portable computers in the household

    So I got Ubuntu 10.04 Linux installed in short order. This feels like something of a homecoming for me. You see, I used Linux full-time at home from 1999-2006. In 2007, I switched to using Windows XP full-time, mostly because my home use-case switched to playing a lot of old, bad computer games. By the end of 2008, I had transitioned to using the Mac Mini that I had originally purchased earlier that year for running FATE cycles. That Mac served as my main home computer until I purchased the 1201PN 2 months ago.

    Mostly, I have this overriding desire for computers to just work, at least in their basic functions. And that’s why I’m so roundly impressed with the way Linux handles right out of the box. Nearly everything on the 1201PN works in Linux. The video, the audio, the wireless networking, the webcam, it all works out of the box. I had to do the extra installation step to get the binary nVidia drivers installed but even that’s relatively seamless, especially compared to “the way things used to be” (drop to a prompt, run some binary installer from the prompt as root, watch it fail in arcane ways because the thing is only certified to run on one version of one Linux distribution). The 1201PN, with its nVidia Ion2 graphics, is able to drive both its own 1366×768 screen simultaneously with an external monitor running at up on 2560×1600.

    The only weird hiccup in the whole process was that I had a little trouble with the special volume keys on the keyboard (specifically, the volume up/down/mute keys didn’t do anything). But I quickly learned that I had to install some package related to ACPI and they magically started to do the right thing. Now I get to encounter the Linux Flash Player bug where modifying volume via those special keys forces fullscreen mode to exit. Adobe really should fix that.

    Also, trackpad multitouch gestures don’t work right away. Based on my reading, it is possible to set those up in Linux. But it’s largely a preference thing– I don’t care much for multitouch. This creates a disparity when I use Windows 7 on the 1201PN which is configured per default to use multitouch.



    The same 4 laptops stacked up

    So, in short, I’m really happy with this little machine. Traditionally, I have had absolutely no affinity for laptops/notebooks/portable computers at all even if everyone around was always completely enamored with the devices. What changed for me ? Well for starters, as a long-time Linux user, I was used to having to invest in very specific, carefully-researched hardware lest I not be able to use it under the Linux OS. This was always a major problem in the laptop field which typically reign supreme in custom, proprietary hardware components. These days, not so much, and these netbooks seem to contain well-supported hardware. Then there’s the fact that laptops always cost so much more than similarly capable desktop systems and that I had no real reason for taking a computer with me when I left home. So my use case changed, as did the price point for relatively low-power laptops/netbooks.

    Data I/O geek note : The 1201PN is capable of wireless-N networking — as many netbooks seem to have — but only 100 Mbit ethernet. I wondered why it didn’t have gigabit ethernet. Then I remembered that 100 Mbit ethernet provides 11-11.5 Mbytes/sec of transfer speed which, in my empirical experience, is approximately the maximum write speed of a 5400 RPM hard drive– which is what the 1201PN possesses.