Recherche avancée

Médias (1)

Mot : - Tags -/musée

Autres articles (68)

  • Les autorisations surchargées par les plugins

    27 avril 2010, par

    Mediaspip core
    autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs

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

  • 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

Sur d’autres sites (10893)

  • FFmpeg(C/libav) VPX to mpeg2video stream cannot be reproduce in VLC

    21 septembre 2017, par caiomcg

    I am currently trying to transcode a VPX(VP8/VP9) video to a mpeg2video and stream it over UDP with mpegts.

    I have initialized all of the contexts and the streams and as long as I stream it to ffplay it works, if I send the stream to VLC or another player, the receiver only display the first frame and do nothing else. If I do the same thing through the command line it works flawlessly - ffmpeg -re -i video.webm -an -f mpegts udp://127.0.0.1:8080

    My output context :

    this->output_codec_ctx_->codec_type    = AVMEDIA_TYPE_VIDEO; // Set media type
    this->output_codec_ctx_->pix_fmt       = AV_PIX_FMT_YUV420P; // Set stream pixel format
    this->output_codec_ctx_->time_base.den = ceil(av_q2d(input_stream->r_frame_rate));     // Add the real video framerate. Eg.: 29.9
    this->output_codec_ctx_->time_base.num = 1;                  // Numerator of the framerate. Eg.: num/29.9
    this->output_codec_ctx_->width         = input_stream->codecpar->width;  // Video width
    this->output_codec_ctx_->height        = input_stream->codecpar->height; // Video height
    this->output_codec_ctx_->bit_rate      = 400000; // Video quality
    this->output_codec_ctx_->gop_size      = 12;
    this->output_codec_ctx_->max_b_frames  = 2;
    this->output_codec_ctx_->framerate     = this->input_codec_ctx_->framerate;
    this->output_codec_ctx_->sample_aspect_ratio     = this->input_codec_ctx_->sample_aspect_ratio;

    My av_dump :

    Output #0, mpegts, to 'udp://127.0.0.1:20010':
     Metadata:
       encoder         : Lavf57.72.101
       Stream #0:0: Video: mpeg2video (Main), 1 reference frame, yuv420p, 480x640 (0x0), q=2-31, 400 kb/s, SAR 1:1 DAR 3:4, 24 fps, 24 tbr, 90k tbn

    FFMPEG av_dump :

    Output #0, mpegts, to 'udp://127.0.0.1:20010':
     Metadata:
       title           : Tears of Steel
       encoder         : Lavf57.72.101
       Stream #0:0: Video: mpeg2video (Main), yuv420p, 480x640 [SAR 1:1 DAR 3:4], q=2-31, 200 kb/s, 24 fps, 90k tbn, 24 tbc (default)
       Metadata:
         encoder         : Lavc57.96.101 mpeg2video
       Side data:
         cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1

    Any ideia on what I may be doing wrong ?

  • ffmpeg create RTP stream

    27 novembre 2016, par DankMemes

    I’m trying to encode and stream using ffmpeg (libavcodec/libavformat - MSVC x64 with Zeranoe builds)

    Here is my code, largely adapted from the encoding example, error handling removed

    #include "stdafx.h"
    extern "C" {
    #include <libavformat></libavformat>avformat.h>
    #include <libavcodec></libavcodec>avcodec.h>

    #include <libavutil></libavutil>opt.h>
    #include <libavutil></libavutil>channel_layout.h>
    #include <libavutil></libavutil>common.h>
    #include <libavutil></libavutil>imgutils.h>
    #include <libavutil></libavutil>mathematics.h>
    #include <libavutil></libavutil>samplefmt.h>
    }
    #pragma comment(lib, "avformat.lib")
    #pragma comment(lib, "avutil.lib")
    #pragma comment(lib, "avcodec.lib")

    int main() {
       avcodec_register_all();
       av_register_all();
       avformat_network_init();

       AVCodecID codec_id = AV_CODEC_ID_H264;
       AVCodec *codec;
       AVCodecContext *c = NULL;
       int i, ret, x, y, got_output;
       AVFrame *frame;
       AVPacket pkt;

       codec = avcodec_find_encoder(codec_id);
       c = avcodec_alloc_context3(codec);

       c->bit_rate = 400000;
       c->width = 352;
       c->height = 288;
       c->time_base.num = 1;
       c->time_base.den = 25;
       c->gop_size = 25;
       c->max_b_frames = 1;
       c->pix_fmt = AV_PIX_FMT_YUV420P;
       c->codec_type = AVMEDIA_TYPE_VIDEO;
       c->flags = CODEC_FLAG_GLOBAL_HEADER;

       if (codec_id == AV_CODEC_ID_H264) {
           ret = av_opt_set(c->priv_data, "preset", "ultrafast", 0);
           ret = av_opt_set(c->priv_data, "tune", "zerolatency", 0);
       }

       avcodec_open2(c, codec, NULL)

       frame = av_frame_alloc();
       frame->format = c->pix_fmt;
       frame->width = c->width;
       frame->height = c->height;
       ret = av_image_alloc(frame->data, frame->linesize, c->width, c->height,
           c->pix_fmt, 32);

       AVFormatContext* avfctx;
       AVOutputFormat* fmt = av_guess_format("rtp", NULL, NULL);

       ret = avformat_alloc_output_context2(&amp;avfctx, fmt, fmt->name,
           "rtp://127.0.0.1:49990");

       printf("Writing to %s\n", avfctx->filename);

       avio_open(&amp;avfctx->pb, avfctx->filename, AVIO_FLAG_WRITE)

       struct AVStream* stream = avformat_new_stream(avfctx, codec);
       stream->codecpar->bit_rate = 400000;
       stream->codecpar->width = 352;
       stream->codecpar->height = 288;
       stream->codecpar->codec_id = AV_CODEC_ID_H264;
       stream->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
       stream->time_base.num = 1;
       stream->time_base.den = 25;

       avformat_write_header(avfctx, NULL);
       char buf[200000];
       AVFormatContext *ac[] = { avfctx };
       av_sdp_create(ac, 1, buf, 20000);
       printf("sdp:\n%s\n", buf);
       FILE* fsdp;
       fopen_s(&amp;fsdp, "test.sdp", "w");
       fprintf(fsdp, "%s", buf);
       fclose(fsdp);
       system("PAUSE");
       system("start "" \"C:\\Program Files (x86)\\VideoLAN\\VLC\\vlc.exe\" test.sdp");

       int j = 0;
       for (i = 0; i &lt; 10000; i++) {
           av_init_packet(&amp;pkt);
           pkt.data = NULL;    // packet data will be allocated by the encoder
           pkt.size = 0;
           fflush(stdout);
           /* prepare a dummy image */
           /* Y */
           for (y = 0; y &lt; c->height; y++) {
               for (x = 0; x &lt; c->width; x++) {
                   frame->data[0][y * frame->linesize[0] + x] = x + y + i * 3;
               }
           }
           /* Cb and Cr */
           for (y = 0; y &lt; c->height / 2; y++) {
               for (x = 0; x &lt; c->width / 2; x++) {
                   frame->data[1][y * frame->linesize[1] + x] = 128 + y + i * 2;
                   frame->data[2][y * frame->linesize[2] + x] = 64 + x + i * 5;
               }
           }
           frame->pts = i;
           /* encode the image */
           ret = avcodec_send_frame(c, frame);
           ret = avcodec_receive_packet(c, &amp;pkt);

           if (ret == AVERROR_EOF) {
               got_output = false;
               printf("Stream EOF\n");
           } else if(ret == AVERROR(EAGAIN)) {
               got_output = false;
               printf("Stream EAGAIN\n");
           } else {
               got_output = true;
           }

           if (got_output) {
               printf("Write frame %3d (size=%5d)\n", j++, pkt.size);
               av_interleaved_write_frame(avfctx, &amp;pkt);
               av_packet_unref(&amp;pkt);
           }

           Sleep(40);
       }

       // end
       ret = avcodec_send_frame(c, NULL);

       /* get the delayed frames */
       for (; ; i++) {
           fflush(stdout);
           ret = avcodec_receive_packet(c, &amp;pkt);
           if (ret == AVERROR_EOF) {
               printf("Stream EOF\n");
               break;
           } else if (ret == AVERROR(EAGAIN)) {
               printf("Stream EAGAIN\n");
               got_output = false;
           } else {
               got_output = true;
           }

           if (got_output) {
               printf("Write frame %3d (size=%5d)\n", j++, pkt.size);
               av_interleaved_write_frame(avfctx, &amp;pkt);
               av_packet_unref(&amp;pkt);
           }
       }

       avcodec_close(c);
       av_free(c);
       av_freep(&amp;frame->data[0]);
       av_frame_free(&amp;frame);
       printf("\n");
       system("pause");
       return 0;
    }

    However VLC (opened with the generated SDP file) isn’t able to play the stream. Messages has this

    core error: ES_OUT_RESET_PCR called

    followed by repeated

    packetizer_h264 warning: waiting for SPS/PPS
    core debug: Buffering <some percent="percent">%
    </some>

    What am I doing wrong ?

  • ffmpeg / libav encoding 264 from YUV420P [on hold]

    4 janvier 2017, par MrSmith

    I am having issues getting this thing to encode correctly. Either I get the container wrong or the content it seems.
    This code encodes a file just fine, but viewing it with VLC or Totem will just yield the first picture, not the remaining 100 frames.
    This is a step up from before as I dont get warnings that my container (mp4) is borked, however now the video wont play at all.. at least it played before :).

    If someone could put a finger somewhere on this code and call me a dumbass, that would be nice :)

    void encode_video(char *carrarr[]){
    av_log_set_level(AV_LOG_DEBUG);
    av_register_all();
    avcodec_register_all();
    AVCodec *codec = avcodec_find_encoder(AV_CODEC_ID_H264);
    AVOutputFormat * outputFormat = av_guess_format("mp4", NULL, NULL);

    int test = avformat_alloc_output_context2(&amp;outFmtCtx, outputFormat, NULL, NULL);
    if(test&lt;0) exit(-1);

    AVStream * outStrm = avformat_new_stream(outFmtCtx, codec);
    avcodec_get_context_defaults3(outStrm->codec, codec);

    outStrm->codec->codec_id = AV_CODEC_ID_H264;
    outStrm->codec->coder_type = AVMEDIA_TYPE_VIDEO;

    outStrm->codec->bit_rate = 400000;
    outStrm->codec->width = 320;
    outStrm->codec->height = 240;
    outStrm->codec->time_base= (AVRational){1,25};
    outStrm->time_base=(AVRational){1,25};
    outStrm->codec->gop_size = 10; // emit one intra frame every ten frames
    outStrm->codec->max_b_frames=1;
    outStrm->codec->pix_fmt = AV_PIX_FMT_YUV420P;
    outStrm->codec->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
    // FOR H264 ONLY
    test = av_opt_set(outStrm->codec->priv_data, "preset", "slow", 0);
    if(test&lt;0) exit(-2);
    test = avcodec_open2(outStrm->codec, codec, NULL);
    if(test&lt;0) exit(-3);
    test = avio_open2(&amp;outFmtCtx->pb, "myoutputfile.avi", AVIO_FLAG_WRITE, NULL, NULL);
    if(test&lt;0) exit(-4);

    test = avformat_write_header(outFmtCtx, NULL);
    if(test&lt;0) exit(-5);
    AVFrame * frame = avcodec_alloc_frame();
    if (!frame) exit(-6);

    frame->format = outStrm->codec->pix_fmt;
    frame->width  = outStrm->codec->width;
    frame->height = outStrm->codec->height;

    ret = av_image_alloc(frame->data, frame->linesize, frame->width, frame->height, outStrm->codec->pix_fmt, 32);
    if (ret &lt; 0) exit(-7);

    av_init_packet(&amp;pkt);
    pkt.data = NULL;
    pkt.size = 0;

    int yrange = 240*320;
    int vrange = 240*320*0.25;

    for(int i=0;i&lt;100;i++){
       char *carr = carrarr[i];

       char* Y = carr;
       char* U = carr+yrange;
       char* V = carr+yrange+vrange;
       frame->data[0] = (uint8_t*)Y;
       frame->data[1] = (uint8_t*)U;
       frame->data[2] = (uint8_t*)V;
       frame->pts = i;

       ret = avcodec_encode_video2(outStrm->codec, &amp;pkt, frame, &amp;got_output);
       if (ret &lt; 0) {
           fprintf(stderr, "Error encoding frame\n");
           exit (EXIT_FAILURE);
       }
       if (got_output) {
           printf("Write frame %3d (size=%5d)\n", i, pkt.size);
           //fwrite(pkt.data, 1, pkt.size, file_encoded_video);
           av_interleaved_write_frame(outFmtCtx, &amp;pkt);
           av_free_packet(&amp;pkt);
       }
    }
    av_write_trailer(outFmtCtx);
    avio_close(outFmtCtx->pb);
    }

    carrarr is holding 100 frames of nice valid YUV420P data, I know this cause I’ve encoded it before AND I can output it to screen with SDL.

    Any ideas welcome. Thanks !