Recherche avancée

Médias (91)

Autres articles (84)

  • Le profil des utilisateurs

    12 avril 2011, par

    Chaque utilisateur dispose d’une page de profil lui permettant de modifier ses informations personnelle. Dans le menu de haut de page par défaut, un élément de menu est automatiquement créé à l’initialisation de MediaSPIP, visible uniquement si le visiteur est identifié sur le site.
    L’utilisateur a accès à la modification de profil depuis sa page auteur, un lien dans la navigation "Modifier votre profil" est (...)

  • Dépôt de média et thèmes par FTP

    31 mai 2013, par

    L’outil MédiaSPIP traite aussi les média transférés par la voie FTP. Si vous préférez déposer par cette voie, récupérez les identifiants d’accès vers votre site MédiaSPIP et utilisez votre client FTP favori.
    Vous trouverez dès le départ les dossiers suivants dans votre espace FTP : config/ : dossier de configuration du site IMG/ : dossier des média déjà traités et en ligne sur le site local/ : répertoire cache du site web themes/ : les thèmes ou les feuilles de style personnalisées tmp/ : dossier de travail (...)

  • Configurer la prise en compte des langues

    15 novembre 2010, par

    Accéder à la configuration et ajouter des langues prises en compte
    Afin de configurer la prise en compte de nouvelles langues, il est nécessaire de se rendre dans la partie "Administrer" du site.
    De là, dans le menu de navigation, vous pouvez accéder à une partie "Gestion des langues" permettant d’activer la prise en compte de nouvelles langues.
    Chaque nouvelle langue ajoutée reste désactivable tant qu’aucun objet n’est créé dans cette langue. Dans ce cas, elle devient grisée dans la configuration et (...)

Sur d’autres sites (7114)

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

  • Error in video streaming using libavformat : VBV buffer size not set, muxing may fail

    18 octobre 2017, par Blue Sky

    I stream a video using libavformat as follows :

    static AVStream *add_stream(AVFormatContext *oc, AVCodec **codec,
                           enum AVCodecID codec_id)
    {
    AVCodecContext *c;
    AVStream *st;
    /* find the encoder */
    *codec = avcodec_find_encoder(codec_id);
    if (!(*codec)) {
       fprintf(stderr, "Could not find encoder for '%s'\n",
               avcodec_get_name(codec_id));
       exit(1);
    }
    st = avformat_new_stream(oc, *codec);
    if (!st) {
       fprintf(stderr, "Could not allocate stream\n");
       exit(1);
    }
    st->id = oc->nb_streams-1;
    c = st->codec;
    switch ((*codec)->type) {
    case AVMEDIA_TYPE_AUDIO:
       c->sample_fmt  = (*codec)->sample_fmts ?
           (*codec)->sample_fmts[0] : AV_SAMPLE_FMT_FLTP;
       c->bit_rate    = 64000;
       c->sample_rate = 44100;
       c->channels    = 2;
       break;
    case AVMEDIA_TYPE_VIDEO:
       c->codec_id = codec_id;
       c->bit_rate = 400000;
       /* Resolution must be a multiple of two. */
       c->width    = outframe_width;
       c->height   = outframe_height;
       /* timebase: This is the fundamental unit of time (in seconds) in terms
        * of which frame timestamps are represented. For fixed-fps content,
        * timebase should be 1/framerate and timestamp increments should be
        * identical to 1. */
       c->time_base.den = STREAM_FRAME_RATE;
       c->time_base.num = 1;
       c->gop_size      = 12; /* emit one intra frame every twelve frames at most */
       c->pix_fmt       = STREAM_PIX_FMT;
       if (c->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
           /* just for testing, we also add B frames */
           c->max_b_frames = 2;
       }
       if (c->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
           /* Needed to avoid using macroblocks in which some coeffs overflow.
            * This does not happen with normal video, it just happens here as
            * the motion of the chroma plane does not match the luma plane. */
           c->mb_decision = 2;
       }
    break;
    default:
       break;
    }
    /* Some formats want stream headers to be separate. */
    if (oc->oformat->flags &amp; AVFMT_GLOBALHEADER)
       c->flags |= CODEC_FLAG_GLOBAL_HEADER;
    return st;
    }

    But when I run this code, I get the following error/warning :

    [mpeg @ 01f3f040] VBV buffer size not set, muxing may fail

    Do you know how I can set the VBV buffer size in the code ? In fact, when I use ffplay to display the streamed video, ffplay doesn’t show anything for short videos but for long videos, it start displaying the video immediately. So, it looks like ffplay needs a buffer to be filled up by some amount so that it can start displaying the stream. Am I right ?