Recherche avancée

Médias (0)

Mot : - Tags -/clipboard

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

Autres articles (103)

  • MediaSPIP 0.1 Beta version

    25 avril 2011, par

    MediaSPIP 0.1 beta is the first version of MediaSPIP proclaimed as "usable".
    The zip file provided here only contains the sources of MediaSPIP in its standalone version.
    To get a working installation, you must manually install all-software dependencies on the server.
    If you want to use this archive for an installation in "farm mode", you will also need to proceed to other manual (...)

  • Multilang : améliorer l’interface pour les blocs multilingues

    18 février 2011, par

    Multilang est un plugin supplémentaire qui n’est pas activé par défaut lors de l’initialisation de MediaSPIP.
    Après son activation, une préconfiguration est mise en place automatiquement par MediaSPIP init permettant à la nouvelle fonctionnalité d’être automatiquement opérationnelle. Il n’est donc pas obligatoire de passer par une étape de configuration pour cela.

  • Des sites réalisés avec MediaSPIP

    2 mai 2011, par

    Cette page présente quelques-uns des sites fonctionnant sous MediaSPIP.
    Vous pouvez bien entendu ajouter le votre grâce au formulaire en bas de page.

Sur d’autres sites (13285)

  • FFmpeg live streaming RGB frame buffer

    23 février 2018, par Mher Didaryan

    When we have a local video file This code works for streaming. What we want to achieve is to change input file with RGB frame buffer that we grab from screen. The code below uses input file’s time_base for PTS and DTS calculation.

    if(pkt.stream_index==videoindex) {
       AVRational time_base=ifmt_ctx->streams[videoindex]->time_base;
       AVRational time_base_q={1,AV_TIME_BASE};
       int64_t pts_time = av_rescale_q(pkt.dts, time_base, time_base_q);
       int64_t now_time = av_gettime() - start_time;
       if (pts_time > now_time)
           av_usleep(pts_time - now_time);
    }

    in_stream  = ifmt_ctx->streams[pkt.stream_index];
    out_stream = ofmt_ctx->streams[pkt.stream_index];
    /* copy packet */
    //Convert PTS/DTS
    pkt.pts = av_rescale_q_rnd(pkt.pts, in_stream->time_base, out_stream->time_base, (AVRounding)(AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX));
    pkt.dts = av_rescale_q_rnd(pkt.dts, in_stream->time_base, out_stream->time_base, (AVRounding)(AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX));
    pkt.duration = av_rescale_q(pkt.duration, in_stream->time_base, out_stream->time_base);

    Following this answer which increments PTS value by one for every frame VideoSt.Frame->pts = VideoSt.NextPts++; saving in local file or streaming to Wowza server works (low quality) but fails on Youtube and Twitch. av_interleaved_write_frame function returns error -22. To improve quality we lowered qmin and qmax values but the bit-rate of video increased too much (30Mb/s and even more for HD video).

    VideoSt.Ctx->codec_id = VideoCodec->id;
    VideoSt.Ctx->width = ViewportSize.X;
    VideoSt.Ctx->height = ViewportSize.Y;
    VideoSt.Stream->time_base = VideoSt.Ctx->time_base = { 1, 30 };
    VideoSt.Ctx->time_base = timeBase;
    VideoSt.Ctx->gop_size = 60;
    VideoSt.Ctx->bit_rate = 400000;
    VideoSt.Ctx->pix_fmt = AV_PIX_FMT_YUV420P;
    VideoSt.Ctx->qmin = 1;
    VideoSt.Ctx->qmax = 2;
    VideoSt.Ctx->max_qdiff = 3;
    VideoSt.Ctx->qcompress = 1.0f;

    How can we stream lossless quality video with reasonable bit-rate using flv1 codec ? If streaming to Youtube or Twitch fails is it just a problem with requirements of this services or there’s an issue with encoding ?

    Regarding error code -22 there’s a detailed explanation which explains how we should increment PTS and DTS values.

    In which cases calculating PTS and DTS values are necessary ?

    And by the way what are these PTS and DTS ? After reading many posts and Understanding PTS and DTS in video frames accepted answer I still do not understand.

  • Using AVStream.codec.time_base as a timebase hint to the muxer is deprecated. Set AVStream.time_base instead

    28 février 2018, par user1496491

    I’m using C API of MMPEG and getting this message. So I added time_base to my stream

    videoStream = avformat_new_stream(formatContext, codec);
    videoStream->time_base = AVRational{1, fps};

    and got rid of it in context

    codecContext->bit_rate = 400000;
    codecContext->width = width;
    codecContext->height = height;
    codecContext->gop_size = 10;
    codecContext->max_b_frames = 1;
    //codecContext->time_base = AVRational{1, fps};
    codecContext->pix_fmt = AV_PIX_FMT_YUV420P;

    avcodec_open2(codecContext, codec, NULL) immediately breaks

    WHY ? Do I need to apply the value to both of them ? I’ve duplicated values to both, and the message gone. But isn’t it just wrong ?

  • FFMPEG (C++) convert & compress a single image out of buffer

    27 mars 2018, par MrEinsa

    i try to encode (with compression) and decode (without compression) a image with ffmpeg. But if i want to get the sent image back with avcodec_receive_packet i get only the error AVERROR(EAGAIN).

    It doesnt matter what i change ... allways AVERROR(EAGAIN) is the outcome. Is it maybe a problem of sending just one single frame to the encoder ? And if yes, how to fix it ?

    Code (only relevant stuff shown) :

           avcodec_register_all();


       /* ------ init codec ------------------*/
       AVCodec *codec;
       codec = avcodec_find_decoder(AV_CODEC_ID_H264);
       if (!codec)
       {
           print("compressH264, could not find decoder:\"AV_CODEC_ID_H264\"!!!");
           return false;
       }

       AVCodec *nVidiaCodec = avcodec_find_encoder_by_name("h264_nvenc");
       if (!nVidiaCodec)
       {
           print("err");
       }
       /* ------ ------------ ------------------*/

       /* ------ init context ------------------*/
       AVCodecContext* av_codec_context_ = NULL;
       av_codec_context_ = avcodec_alloc_context3(nVidiaCodec);
       if (!av_codec_context_)
       {
           print("compressH264, avcodec_alloc_context3 failed!!!");
           return false;
       }
       int w = imgSrc.width();
       int h = imgSrc.height();
       if ((w % 2) != 0)
       {
           ++w;
       }
       if ((h % 2) != 0)
       {
           ++h;
       }
       av_codec_context_->width = w;
       av_codec_context_->height = h;
       av_codec_context_->pix_fmt = AV_PIX_FMT_YUV420P;
       av_codec_context_->gop_size = 1;
       av_codec_context_->max_b_frames = 1;
       av_codec_context_->bit_rate = 400000;
       av_codec_context_->time_base.den = 1;
       av_codec_context_->time_base.num = 1;

       av_opt_set(av_codec_context_->priv_data, "preset", "slow", 0);

       int ret = avcodec_open2(av_codec_context_, nVidiaCodec, NULL);
       if (0 > ret)
       {
           print("compressH264, could not open codec context for decoder:\"AV_CODEC_ID_H264\"!!!");
           return false;
       }


       AVFrame *picture = av_frame_alloc();
       picture->format = AV_PIX_FMT_RGB24;
       picture->width = w;
       picture->height = h;

       ret = avpicture_fill((AVPicture *)picture, imgSrc.bits(), AV_PIX_FMT_RGB24, w, h);
       if (0 > ret)
       {
           print("compressH264, avpicture_fill - failed!!!");
           return false;
       }

       AVFrame *tmp_picture = av_frame_alloc();
       tmp_picture->format = AV_PIX_FMT_YUV420P;
       tmp_picture->width = w;
       tmp_picture->height = h;

       ret = av_frame_get_buffer(tmp_picture, 32);

       SwsContext *img_convert_ctx = sws_getContext(av_codec_context_->width, av_codec_context_->height, AV_PIX_FMT_RGB24, av_codec_context_->width, av_codec_context_->height, av_codec_context_->pix_fmt, SWS_BICUBIC, NULL, NULL, NULL);

       ret = sws_scale(img_convert_ctx, picture->data, picture->linesize, 0, av_codec_context_->height, tmp_picture->data, tmp_picture->linesize);

       int h264Size = avpicture_get_size(AV_PIX_FMT_YUV420P, w, h);

       ret = avcodec_send_frame(av_codec_context_, tmp_picture);
       if (0 > ret)
       {
           char err[AV_ERROR_MAX_STRING_SIZE];
           av_make_error_string(err, AV_ERROR_MAX_STRING_SIZE, ret);
           print("compressH264, avcodec_send_frame: %s", err);
       }


       AVPacket *pkt = av_packet_alloc();

       while (ret >= 0)
       {
           ret = avcodec_receive_packet(av_codec_context_, pkt);
           if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
           {
               break;
           }
           else if (ret < 0)
           {
               fprintf(stderr, "Error during encoding\n");
               exit(1);
           }
           av_packet_unref(pkt);
       }
       print("success");

    Everything works well until :
    - avcodec_receive_packet ... i get all time the error AVERROR(EAGAIN).

    I can start decoding just if i have the compressed image.

    Thanks for your help guys.

    Edit :
    If i do now the following code, i get a packet and ret == 0, but i have to send 46 times the same image ... for me this makes no sence.

           do
       {
           ret = avcodec_receive_packet(av_codec_context_, &pkt);
           if (ret == 0)
           {
               break;
           }
           else if ((ret < 0) && (ret != AVERROR(EAGAIN)))
           {
               coutF("error");
           }
           else if (ret == AVERROR(EAGAIN))
           {
               ret = avcodec_send_frame(av_codec_context_, tmp_picture);
               if (0 > ret)
               {
                   char err[AV_ERROR_MAX_STRING_SIZE];
                   av_make_error_string(err, AV_ERROR_MAX_STRING_SIZE, ret);
                   coutFRed("compressH264, avcodec_send_frame: %s", err);
               }
               coutF("cnt:%d", ++cnt);
           }

       } while (ret == 0);

    Edit :

    Good morning,

    after more invest, i got the issue. I have to send the same frame a lot of time, because of the keyframe stuff for h264. The question now is, if it is possible to remove the h264 standart stuff from the encoder and just let FFMPEG convert one single frame.