Recherche avancée

Médias (0)

Mot : - Tags -/optimisation

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (30)

  • 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

  • ANNEXE : Les plugins utilisés spécifiquement pour la ferme

    5 mars 2010, par

    Le site central/maître de la ferme a besoin d’utiliser plusieurs plugins supplémentaires vis à vis des canaux pour son bon fonctionnement. le plugin Gestion de la mutualisation ; le plugin inscription3 pour gérer les inscriptions et les demandes de création d’instance de mutualisation dès l’inscription des utilisateurs ; le plugin verifier qui fournit une API de vérification des champs (utilisé par inscription3) ; le plugin champs extras v2 nécessité par inscription3 (...)

  • Contribute to a better visual interface

    13 avril 2011

    MediaSPIP is based on a system of themes and templates. Templates define the placement of information on the page, and can be adapted to a wide range of uses. Themes define the overall graphic appearance of the site.
    Anyone can submit a new graphic theme or template and make it available to the MediaSPIP community.

Sur d’autres sites (5915)

  • Encoding to h264 failed to send some frames using ffmpeg c api

    8 juillet 2020, par Vuwox

    Using FFMPEG C API, Im trying to push generated image to MP4 format.

    


    When I push frame-by-frame, the muxing seems to failed on avcodec_receive_packet(...) which return AVERROR(EAGAIN) on the first frames, but after a while is starting to add my frame, but the first one.

    


    What I mean, is that when push frame 1 to 13, I have errors, but after frame 14 to end (36), the frame are added to the video, but the encoded image are not the 14 to 36, instead its the frame 1 to 23 that are added.

    


    I don't understand, is this a problem with the framerate (which i want 12 fps), or with key/inter- frame ?

    


    Here the code for different part of the class,

    


    NOTE :

    


      

    • m_filename = "C :\tmp\test.mp4"
    • 


    • m_framerate = 12
    • 


    • m_width = 1080
    • 


    • m_height = 1080
    • 


    


    ctor

    


    // Allocate the temporary buffer that hold the our generated image in RGB.
picture_rgb24 = av_frame_alloc();
picture_rgb24->pts = 0;
picture_rgb24->data[0] = NULL;
picture_rgb24->linesize[0] = -1;
picture_rgb24->format = AV_PIX_FMT_RGB24;
picture_rgb24->height = m_height;
picture_rgb24->width = m_width;

if ((_ret = av_image_alloc(picture_rgb24->data, picture_rgb24->linesize, m_width, m_height, (AVPixelFormat)picture_rgb24->format, 24)) < 0)
    throw ...

// Allocate the temporary frame that will be convert from RGB to YUV using ffmpeg api.
frame_yuv420 = av_frame_alloc();
frame_yuv420->pts = 0;
frame_yuv420->data[0] = NULL;
frame_yuv420->linesize[0] = -1;
frame_yuv420->format = AV_PIX_FMT_YUV420P;
frame_yuv420->width = m_height;
frame_yuv420->height = m_width;

if ((_ret = av_image_alloc(frame_yuv420->data, frame_yuv420->linesize, m_width, m_height, (AVPixelFormat)frame_yuv420->format, 32)) < 0)
    throw ...

init_muxer(); // see below.

m_inited = true;
    
m_pts_increment = av_rescale_q(1, { 1, m_framerate }, ofmt_ctx->streams[0]->time_base);

// Context that convert the RGB24 to YUV420P format (using this instead of filter similar to GIF).
swsCtx = sws_getContext(m_width, m_height, AV_PIX_FMT_RGB24, m_width, m_height, AV_PIX_FMT_YUV420P, SWS_BICUBIC, 0, 0, 0);


    


    init_muxer :

    


    AVOutputFormat* oformat = av_guess_format(nullptr, m_filename.c_str(), nullptr);
if (!oformat) throw ...

_ret = avformat_alloc_output_context2(&ofmt_ctx, oformat, nullptr, m_filename.c_str());
if (_ret) throw ...

AVCodec *codec = avcodec_find_encoder(oformat->video_codec);
if (!codec) throw ...

AVStream *stream = avformat_new_stream(ofmt_ctx, codec);
if (!stream) throw ...

o_codec_ctx = avcodec_alloc_context3(codec);
if (!o_codec_ctx) throw ...

stream->codecpar->codec_id = oformat->video_codec;
stream->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
stream->codecpar->width = m_width;
stream->codecpar->height = m_height;
stream->codecpar->format = AV_PIX_FMT_YUV420P;
stream->codecpar->bit_rate = 400000;

avcodec_parameters_to_context(o_codec_ctx, stream->codecpar);
o_codec_ctx->time_base = { 1, m_framerate };

// Using gop_size == 0, we want 'intra' frame, so no b-frame will be generated.
o_codec_ctx->max_b_frames = 0;
o_codec_ctx->gop_size = 0;
o_codec_ctx->b_quant_offset = 0;
//o_codec_ctx->framerate = { m_framerate , 1 };

if (stream->codecpar->codec_id == AV_CODEC_ID_H264)
    av_opt_set(o_codec_ctx, "preset", "ultrafast", 0);      // Lossless H.264
else if (stream->codecpar->codec_id == AV_CODEC_ID_H265)
    av_opt_set(o_codec_ctx, "preset", "ultrafast", 0);      // Lossless H.265

avcodec_parameters_from_context(stream->codecpar, o_codec_ctx);

if ((_ret = avcodec_open2(o_codec_ctx, codec, NULL)) < 0)
    throw ...

if ((_ret = avio_open(&ofmt_ctx->pb, m_filename.c_str(), AVIO_FLAG_WRITE)) < 0)
    throw ...

if ((_ret = avformat_write_header(ofmt_ctx, NULL)) < 0)
    throw ...

av_dump_format(ofmt_ctx, 0, m_filename.c_str(), 1);


    


    add_frame :

    


    // loop to transfer our image format to ffmpeg one.
for (int y = 0; y < m_height; y++)
{
    for (int x = 0; x < m_width; x++)
    {
        picture_rgb24->data[0][idx] = ...;
        picture_rgb24->data[0][idx + 1] = ...;
        picture_rgb24->data[0][idx + 2] = ...;
    }
}

// From RGB to YUV
sws_scale(swsCtx, (const uint8_t * const *)picture_rgb24->data, picture_rgb24->linesize, 0, m_height, frame_yuv420->data, frame_yuv420->linesize);

// mux the YUV frame
muxing_one_frame(frame_yuv420);

// Increment the FPS of the picture for the next add-up to the buffer.      
picture_rgb24->pts += m_pts_increment;
frame_yuv420->pts += m_pts_increment;


    


    muxing_one_frame :

    


    int ret = avcodec_send_frame(o_codec_ctx, frame);
AVPacket *pkt = av_packet_alloc();
av_init_packet(pkt);

while (ret >= 0) {
    ret = avcodec_receive_packet(o_codec_ctx, pkt);
    if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) break;        
    av_write_frame(ofmt_ctx, pkt);
}
av_packet_unref(pkt);


    


    close_file :

    


    av_write_trailer(ofmt_ctx);
avio_close(ofmt_ctx->pb);


    


  • avcodec/v4l2_m2m_dec : remove redundant packet and fix double free

    16 juillet 2020, par Andriy Gelman
    avcodec/v4l2_m2m_dec : remove redundant packet and fix double free
    

    v4l2_receive_frame() uses two packets s->buf_pkt and avpkt. If avpkt
    cannot be enqueued, the packet is buffered in s->buf_pkt and enqueued in
    the next call. Currently the ownership transfer between the two packets
    is not properly handled. A double free occurs if
    ff_v4l2_context_enqueue_packet() returns EAGAIN and v4l2_try_start
    returns EINVAL.

    In fact, having two AVPackets is not needed and everything can be
    handled by s->buf_pkt.

    This commit removes the local avpkt from v4l2_receive_frame(), meaning
    that the ownership transfer doesn't need to be handled and the double
    free is fixed.

    Signed-off-by : Andriy Gelman <andriy.gelman@gmail.com>

    • [DH] libavcodec/v4l2_m2m_dec.c
  • FFMPEG how to use https dynamic url as input for amovie filter

    2 juillet 2020, par Johny Sharma

    Basically what i am trying to do is to calling a dynamic php url which is generating a audio file for me and just want to use that file as an input for amovie filter.&#xA;I hope you have understand my question.

    &#xA;

    What i have done so far ?

    &#xA;

    I have a FFMPEG code which is :

    &#xA;

    ffmpeg-y -i &#x27;bg-file.mp3&#x27; -c copy -map 0:0 -map 1:0 -filter_complex "amovie=&#x27;/auth.php?input=string&amp;l=hi&amp;f.mp3&#x27;:loop=999[sc][mix];[0:a][sc]sidechaincompress=threshold=0.100:ratio=20,volume=10dB:precision=fixed[bg], [bg][mix]amix=duration=first"  -c:a libmp3lame -ac 2  "save.mp3"&#xA;

    &#xA;

    This line is calling my dynamic url for generating the required song.

    &#xA;

    "amovie=&#x27;/auth.php?input=string&amp;l=hi&amp;f.mp3&#x27;&#xA;

    &#xA;

    Everything is working if i check them apart. but when i use them together the ffmpeg is giving the following error.

    &#xA;

    [22] => [Parsed_amovie_0 @ 0x1378140] Failed to avformat_open_input &#x27;/auth.php?input=string&amp;l=hi&amp;f.mp3&#x27;:loop=999&#x27;&#xA;[23] => [AVFilterGraph @ 0x1368ca0] Error initializing filter &#x27;amovie&#x27; with args &#x27;/auth.php?input=string&amp;l=hi&amp;f.mp3&#x27;:loop=999&#x27;&#xA;[24] => Error initializing complex filters.&#xA;[25] => No such file or directory&#xA;

    &#xA;

    I dont know is it possible to put a dynamically generated url as an input for amovie filter or not ?&#xA;if i open my dynamic url in browser its works like a mp3 file and play similar to any mp3 file.

    &#xA;

    using this code to play that mp3 :

    &#xA;

    header(&#x27;Content-Description: File Transfer&#x27;);&#xA;header(&#x27;Content-Type: application/octet-stream&#x27;);&#xA;header(&#x27;Content-Disposition: attachment; filename=&#x27;.basename($path));&#xA;header(&#x27;Content-Transfer-Encoding: binary&#x27;);&#xA;header(&#x27;Expires: 0&#x27;);&#xA;header(&#x27;Cache-Control: must-revalidate, post-check=0, pre-check=0&#x27;);&#xA;header(&#x27;Pragma: public&#x27;);&#xA;ob_clean();&#xA;flush();&#xA;readfile($path);&#xA;exit;&#xA;

    &#xA;

    This one looks similar to my query but slightly different and that's why i am still looking for a solution

    &#xA;

    How to use https input with ffmpeg "amovie" filter ?

    &#xA;