Recherche avancée

Médias (91)

Autres articles (71)

  • Personnaliser en ajoutant son logo, sa bannière ou son image de fond

    5 septembre 2013, par

    Certains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;

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

  • Ecrire une actualité

    21 juin 2013, par

    Présentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
    Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
    Vous pouvez personnaliser le formulaire de création d’une actualité.
    Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...)

Sur d’autres sites (11087)

  • How to compensate frame rate underrun while muxing video to mp4 container with libav

    17 septembre 2021, par Nuno Santos

    I have a process that generates video frames in real time. I’m muxing the generated video frames stream in a video file (x264 codec on a mp4 container).

    


    I'm using ffmpeg-libav and I'm basing myself on the muxing.c example. The problem with the example is that isn't a real world scenario as frames are being generated on a while loop for a given stream duration, never missing a frame.

    


    On my program, frames are supposed to be generated at FPS, however, depending on the hardware capacity it might produce less than FPS. When I initialize the video stream context I declare that frame rate is FPS :

    


    AVRational r = { 1, FPS };
ost->st->time_base = r;


    


    This specifies that the video is going to have FPS frame rate but if less frames are produced, the playback will be faster because it will still reproduce the video as it if had all the declared frames per second.

    


    After googling a lot about this topic I understand that the key to fix this is to manipulate pts and dts but I still haven't found a solution that works.

    


    There are two key functions when writing video frames in the muxing.c example, routines that I'm using in my program :

    


    AVFrame* get_video_frame(int timestamp, OutputStream *ost, const QImage &image)
{
    /* when we pass a frame to the encoder, it may keep a reference to it
     * internally; make sure we do not overwrite it here */
    if (av_frame_make_writable(ost->frame) < 0)
        exit(1);

    av_image_fill_arrays(ost->tmp_frame->data, ost->tmp_frame->linesize, image.bits(), AV_PIX_FMT_RGBA, ost->frame->width, ost->frame->height, 8);
    libyuv::ABGRToI420(ost->tmp_frame->data[0], ost->tmp_frame->linesize[0], ost->frame->data[0], ost->frame->linesize[0], ost->frame->data[1], ost->frame->linesize[1], ost->frame->data[2], ost->frame->linesize[2], ost->tmp_frame->width, -ost->tmp_frame->height);

    #if 1 // this is my attempt to rescale pts, but crashes with ptsframe->pts = av_rescale_q(timestamp, AVRational{1, 1000}, ost->st->time_base);
    #else
    ost->frame->pts = ost->next_pts++;
    #endif

    return ost->frame;
}


    


    On the original code, the pts is simply an incremeting integer for each frame. What I'm trying to do is to pass a timestamp in ms since the beggining of the recording so that I can rescale the pts. When I rescale pts the program crashes complaining that pts is lower then dts.

    


    From what I've been reading, the pts/dts manipulation is supposed to be done at the packet level so I have also tried to manipulate things on write_frame routine without success.

    


    int write_frame(AVFormatContext *fmt_ctx, AVCodecContext *c, AVStream *st, AVFrame *frame)
{
    int ret;

    // send the frame to the encoder
    ret = avcodec_send_frame(c, frame);

    if (ret<0)
    {
        fprintf(stderr, "Error sending a frame to the encoder\n");
        exit(1);
    }

    while (ret >= 0)
    {
        AVPacket pkt = { 0 };

        ret = avcodec_receive_packet(c, &pkt);

        if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
        {
            break;
        }
        else if (ret<0)
        {
            //fprintf(stderr, "Error encoding a frame: %s\n", av_err2str(ret));
            exit(1);
        }

        /* rescale output packet timestamp values from codec to stream timebase */
        av_packet_rescale_ts(&pkt, c->time_base, st->time_base);
        pkt.stream_index = st->index;

        /* Write the compressed frame to the media file. */
        //log_packet(fmt_ctx, &pkt);
        ret = av_interleaved_write_frame(fmt_ctx, &pkt);
        av_packet_unref(&pkt);

        if (ret < 0)
        {
            //fprintf(stderr, "Error while writing output packet: %s\n", av_err2str(ret));
            exit(1);
        }
    }

    return ret == AVERROR_EOF ? 1 : 0;
}


    


    How should I manipulate dts and pts so that I can achieve a video at certain frame that does not have all the frames as specified in the stream initialization ? Where should I do that manipulation ? On get_video_frame ? On write_frame ? On both ?

    


    Am I heading in the right direction ? What am I missing ?

    


  • lavc : Implement Dolby Vision RPU parsing

    3 janvier 2022, par Niklas Haas
    lavc : Implement Dolby Vision RPU parsing
    

    Based on a mixture of guesswork, partial documentation in patents, and
    reverse engineering of real-world samples. Confirmed working for all the
    samples I've thrown at it.

    Contains some annoying machinery to persist these values in between
    frames, which is needed in theory even though I've never actually seen a
    sample that relies on it in practice. May or may not work.

    Since the distinction matters greatly for parsing the color matrix
    values, this includes a small helper function to guess the right profile
    from the RPU itself in case the user has forgotten to forward the dovi
    configuration record to the decoder. (Which in practice, only ffmpeg.c
    and ffplay do..)

    Notable omissions / deviations :
    - CRC32 verification. This is based on the MPEG2 CRC32 type, which is
    similar to IEEE CRC32 but apparently different in subtle enough ways
    that I could not get it to pass verification no matter what parameters
    I fed to av_crc. It's possible the code needs some changes.
    - Linear interpolation support. Nothing documents this (beyond its
    existence) and no samples use it, so impossible to implement.
    - All of the extension metadata blocks, but these contain values that
    seem largely congruent with ST2094, HDR10, or other existing forms of
    side data, so I will defer parsing/attaching them to a future commit.
    - The patent describes a mechanism for predicting coefficients from
    previous RPUs, but the bit for the flag whether to use the
    prediction deltas or signal entirely new coefficients does not seem to
    be present in actual RPUs, so we ignore this subsystem entirely.
    - In the patent's spec, the NLQ subsystem also loops over
    num_nlq_pivots, but even in the patent the number is hard-coded to one
    iteration rather than signalled. So we only store one set of coefs.

    Heavily influenced by https://github.com/quietvoid/dovi_tool
    Documentation drawn from US Patent 10,701,399 B2 and ETSI GS CCM 001

    Signed-off-by : Niklas Haas <git@haasn.dev>
    Signed-off-by : Andreas Rheinhardt <andreas.rheinhardt@outlook.com>

    • [DH] configure
    • [DH] libavcodec/Makefile
    • [DH] libavcodec/dovi_rpu.c
    • [DH] libavcodec/dovi_rpu.h
  • How to visualize matplotlib animation in Jupyter notebook

    23 avril 2020, par anonymous13

    I am trying to create a racing bar chart similar to the one in the link (https://towardsdatascience.com/bar-chart-race-in-python-with-matplotlib-8e687a5c8a41). &#xA;However I am unable to see the animation in my Jupyter notebook

    &#xA;&#xA;

    code

    &#xA;&#xA;

    import pandas as pd&#xA;import matplotlib.pyplot as plt&#xA;import matplotlib.ticker as ticker&#xA;import matplotlib.animation as animation&#xA;from IPython.display import HTML&#xA;&#xA;df = pd.read_csv(&#x27;https://gist.githubusercontent.com/johnburnmurdoch/4199dbe55095c3e13de8d5b2e5e5307a/raw/fa018b25c24b7b5f47fd0568937ff6c04e384786/city_populations&#x27;, &#xA;                 usecols=[&#x27;name&#x27;, &#x27;group&#x27;, &#x27;year&#x27;, &#x27;value&#x27;])&#xA;&#xA;current_year = 2018&#xA;dff = (df[df[&#x27;year&#x27;].eq(current_year)]&#xA;       .sort_values(by=&#x27;value&#x27;, ascending=True)&#xA;       .head(10))&#xA;&#xA;colors = dict(zip(&#xA;    [&#x27;India&#x27;, &#x27;Europe&#x27;, &#x27;Asia&#x27;, &#x27;Latin America&#x27;,&#xA;     &#x27;Middle East&#x27;, &#x27;North America&#x27;, &#x27;Africa&#x27;],&#xA;    [&#x27;#adb0ff&#x27;, &#x27;#ffb3ff&#x27;, &#x27;#90d595&#x27;, &#x27;#e48381&#x27;,&#xA;     &#x27;#aafbff&#x27;, &#x27;#f7bb5f&#x27;, &#x27;#eafb50&#x27;]&#xA;))&#xA;group_lk = df.set_index(&#x27;name&#x27;)[&#x27;group&#x27;].to_dict()&#xA;&#xA;&#xA;fig, ax = plt.subplots(figsize=(15, 8))&#xA;def draw_barchart(year):&#xA;    dff = df[df[&#x27;year&#x27;].eq(year)].sort_values(by=&#x27;value&#x27;, ascending=True).tail(10)&#xA;    ax.clear()&#xA;    ax.barh(dff[&#x27;name&#x27;], dff[&#x27;value&#x27;], color=[colors[group_lk[x]] for x in dff[&#x27;name&#x27;]])&#xA;    dx = dff[&#x27;value&#x27;].max() / 200&#xA;    for i, (value, name) in enumerate(zip(dff[&#x27;value&#x27;], dff[&#x27;name&#x27;])):&#xA;        ax.text(value-dx, i,     name,           size=14, weight=600, ha=&#x27;right&#x27;, va=&#x27;bottom&#x27;)&#xA;        ax.text(value-dx, i-.25, group_lk[name], size=10, color=&#x27;#444444&#x27;, ha=&#x27;right&#x27;, va=&#x27;baseline&#x27;)&#xA;        ax.text(value&#x2B;dx, i,     f&#x27;{value:,.0f}&#x27;,  size=14, ha=&#x27;left&#x27;,  va=&#x27;center&#x27;)&#xA;    # ... polished styles&#xA;    ax.text(1, 0.4, year, transform=ax.transAxes, color=&#x27;#777777&#x27;, size=46, ha=&#x27;right&#x27;, weight=800)&#xA;    ax.text(0, 1.06, &#x27;Population (thousands)&#x27;, transform=ax.transAxes, size=12, color=&#x27;#777777&#x27;)&#xA;    ax.xaxis.set_major_formatter(ticker.StrMethodFormatter(&#x27;{x:,.0f}&#x27;))&#xA;    ax.xaxis.set_ticks_position(&#x27;top&#x27;)&#xA;    ax.tick_params(axis=&#x27;x&#x27;, colors=&#x27;#777777&#x27;, labelsize=12)&#xA;    ax.set_yticks([])&#xA;    ax.margins(0, 0.01)&#xA;    ax.grid(which=&#x27;major&#x27;, axis=&#x27;x&#x27;, linestyle=&#x27;-&#x27;)&#xA;    ax.set_axisbelow(True)&#xA;    ax.text(0, 1.12, &#x27;The most populous cities in the world from 1500 to 2018&#x27;,&#xA;            transform=ax.transAxes, size=24, weight=600, ha=&#x27;left&#x27;)&#xA;    ax.text(1, 0, &#x27;by @pratapvardhan; credit @jburnmurdoch&#x27;, transform=ax.transAxes, ha=&#x27;right&#x27;,&#xA;            color=&#x27;#777777&#x27;, bbox=dict(facecolor=&#x27;white&#x27;, alpha=0.8, edgecolor=&#x27;white&#x27;))&#xA;    plt.box(False)&#xA;&#xA;draw_barchart(2018)&#xA;&#xA;import matplotlib.animation as animation&#xA;from IPython.display import HTML&#xA;fig, ax = plt.subplots(figsize=(15, 8))&#xA;animator = animation.FuncAnimation(fig, draw_barchart, frames=range(1968, 2019))&#xA;HTML(animator.to_jshtml()) &#xA;&#xA;

    &#xA;&#xA;

    Below is what I tried using and the errors

    &#xA;&#xA;

    HTML(animator.to_jshtml())  &lt;-- Static output with buttons unable to visualize animation&#xA;plt.rcParams["animation.html"] = "jshtml"  &lt;- no error and output&#xA;HTML(animator.to_html5_video())  &lt;---Requested MovieWriter (ffmpeg) not available &#xA;&#xA;

    &#xA;&#xA;

    Note I have FFmpeg installed in my system.&#xA;Can you help me with the issue

    &#xA;