Recherche avancée

Médias (1)

Mot : - Tags -/biographie

Autres articles (12)

  • Support de tous types de médias

    10 avril 2011

    Contrairement à beaucoup de logiciels et autres plate-formes modernes de partage de documents, MediaSPIP a l’ambition de gérer un maximum de formats de documents différents qu’ils soient de type : images (png, gif, jpg, bmp et autres...) ; audio (MP3, Ogg, Wav et autres...) ; vidéo (Avi, MP4, Ogv, mpg, mov, wmv et autres...) ; contenu textuel, code ou autres (open office, microsoft office (tableur, présentation), web (html, css), LaTeX, Google Earth) (...)

  • Supporting all media types

    13 avril 2011, par

    Unlike most software and media-sharing platforms, MediaSPIP aims to manage as many different media types as possible. The following are just a few examples from an ever-expanding list of supported formats : images : png, gif, jpg, bmp and more audio : MP3, Ogg, Wav and more video : AVI, MP4, OGV, mpg, mov, wmv and more text, code and other data : OpenOffice, Microsoft Office (Word, PowerPoint, Excel), web (html, CSS), LaTeX, Google Earth and (...)

  • Menus personnalisés

    14 novembre 2010, par

    MediaSPIP utilise le plugin Menus pour gérer plusieurs menus configurables pour la navigation.
    Cela permet de laisser aux administrateurs de canaux la possibilité de configurer finement ces menus.
    Menus créés à l’initialisation du site
    Par défaut trois menus sont créés automatiquement à l’initialisation du site : Le menu principal ; Identifiant : barrenav ; Ce menu s’insère en général en haut de la page après le bloc d’entête, son identifiant le rend compatible avec les squelettes basés sur Zpip ; (...)

Sur d’autres sites (4073)

  • ffmpeg nvenc encode too slow

    13 août 2016, par sweetsource

    i use ffmpeg 3.1 compile with nvenc,when i run the ffmpeg encode example like this:

    #include

    #include <libavutil></libavutil>opt.h>
    #include <libavcodec></libavcodec>avcodec.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>
    #include <ace></ace>ace_os.h>

    #define INBUF_SIZE 4096
    #define AUDIO_INBUF_SIZE 20480
    #define AUDIO_REFILL_THRESH 4096



    /*
    * Video encoding example
    */
    static void video_encode_example(const char *filename, const char* codec_name)
    {
       AVCodec *codec;
       AVCodecContext *c= NULL;
       int i, ret, x, y, got_output;
       ACE_INT64 nstart,nend;
       FILE *f;
       AVFrame *frame;
       AVPacket pkt;
       uint8_t endcode[] = { 0, 0, 1, 0xb7 };

       printf("Encode video file %s\n", filename);

       /* find the video encoder */
       codec = avcodec_find_encoder_by_name(codec_name);
       if (!codec) {
           fprintf(stderr, "Codec not found\n");
           exit(1);
       }

       c = avcodec_alloc_context3(codec);
       if (!c) {
           fprintf(stderr, "Could not allocate video codec context\n");
           exit(1);
       }

       /* put sample parameters */
       c->bit_rate = 400000;
       /* resolution must be a multiple of two */
       c->width = 352;
       c->height = 288;
       /* frames per second */
       c->time_base = (AVRational){1,25};
       /* emit one intra frame every ten frames
        * check frame pict_type before passing frame
        * to encoder, if frame->pict_type is AV_PICTURE_TYPE_I
        * then gop_size is ignored and the output of encoder
        * will always be I frame irrespective to gop_size
        */
       c->gop_size = 25;
       c->max_b_frames = 0;
       c->thread_count = 1;
       c->refs = 4;
       c->pix_fmt = AV_PIX_FMT_YUV420P;

       if(!strcmp(codec_name,"libx264")
       {
           av_opt_set(c->priv_data, "preset", "superfast", 0);
           av_opt_set(c->priv_data, "tune", "zerolatency", 0);
       }

       if(!strcmp(codec_name,"h264_nvenc")
       {
           av_opt_set(m_pEncodeCtx->priv_data, "gpu","any",0);
           av_opt_set(m_pEncodeCtx->priv_data, "preset", "llhp", 0);
           av_opt_set(m_pEncodeCtx->priv_data,"profile","main",0);
           m_pEncodeCtx->refs = 0;
           m_pEncodeCtx->flags = 0;
           m_pEncodeCtx->qmax = 31;
           m_pEncodeCtx->qmin = 2;
       }

       /* open it */
       if (avcodec_open2(c, codec, NULL) &lt; 0) {
           fprintf(stderr, "Could not open codec\n");
           exit(1);
       }

       f = fopen(filename, "wb");
       if (!f) {
           fprintf(stderr, "Could not open %s\n", filename);
           exit(1);
       }

       frame = av_frame_alloc();
       if (!frame) {
           fprintf(stderr, "Could not allocate video frame\n");
           exit(1);
       }
       frame->format = c->pix_fmt;
       frame->width  = c->width;
       frame->height = c->height;

       /* the image can be allocated by any means and av_image_alloc() is
        * just the most convenient way if av_malloc() is to be used */
       ret = av_image_alloc(frame->data, frame->linesize, c->width, c->height,
                            c->pix_fmt, 32);
       if (ret &lt; 0) {
           fprintf(stderr, "Could not allocate raw picture buffer\n");
           exit(1);
       }

       /* encode 1 second of video */
       for (i = 0; i &lt; 25; 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 */
           nstart = ACE_OS::gettimeofday().get_msec();
           ret = avcodec_encode_video2(c, &amp;pkt, frame, &amp;got_output);
           if (ret &lt; 0) {
               fprintf(stderr, "Error encoding frame\n");
               exit(1);
           }

           if (got_output) {
               printf("%s take time:%d\n",codec_name,ACE_OS::gettimeofday().get_msec()-nstart);
               printf("Write frame %3d (size=%5d)\n", i, pkt.size);
               fwrite(pkt.data, 1, pkt.size, f);
               av_packet_unref(&amp;pkt);
           }
       }

       /* get the delayed frames */
       for (got_output = 1; got_output; i++) {
           fflush(stdout);

           ret = avcodec_encode_video2(c, &amp;pkt, NULL, &amp;got_output);
           if (ret &lt; 0) {
               fprintf(stderr, "Error encoding frame\n");
               exit(1);
           }

           if (got_output) {
               printf("Write frame %3d (size=%5d)\n", i, pkt.size);
               fwrite(pkt.data, 1, pkt.size, f);
               av_packet_unref(&amp;pkt);
           }
       }

       /* add sequence end code to have a real MPEG file */
       fwrite(endcode, 1, sizeof(endcode), f);
       fclose(f);

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



    int main(int argc, char **argv)
    {
       const char *output_type;

       /* register all the codecs */
       avcodec_register_all();
       video_encode_example("test.h264", "h264_nvenc");


       return 0;
    }

    it encode one frame to a packet about 1800ms,this is too slow. I use Nvidia Grid K1.Is there some parameter error ? Thanke you very much

  • In using FFmpeg SDK, the mp4 file encoded with HEVC(x265) codec not playing in general player

    26 octobre 2016, par Wiktor Kostus

    Everyone !

    I am going to encode mp4 file (x264 codec) to HEVC(x265) codec using FFmpeg SDK.
    Also, I am going to write the encoded file into .mp4 file container.

    The problem I am facing is that the encoded file is played well in FFplay and VLC player but it isn’t played in general HEVC player.

    I used the general method to encode the codec in FFmpeg SDK. I think I have a mistake to use the avformat_write_header() function. It seems that some parameters to pass AVFormatContext, AVOutputFormat or AVCodecContext for HEVC codec are missing.

    Finally, I would like to know the way to write the HEVC codec into mp4 container. I also would like to know the right parameters related to Context instances for HEVC codec.

    Below is my tiny demo code. (I have skipped the code related to InputStream since I think I have a mistake in OutputStream)

    AVFormatContext* pFormatCtx;
    AVOutputFormat* fmt;
    AVStream* video_st;
    AVCodecContext* pCodecCtx;

    const char* out_file = "output.mp4";

    pFormatCtx = avformat_alloc_context();
    fmt = av_guess_format(NULL, out_file, NULL);
    pFormatCtx->oformat = fmt;

    if (avio_open(&amp;pFormatCtx->pb, out_file, AVIO_FLAG_READ_WRITE) &lt; 0){
       printf("Failed to open output file! \n");
       return -1;
    }

    video_st = avformat_new_stream(pFormatCtx, 0);
    video_st->time_base.num = 1;
    video_st->time_base.den = 25;  

    if (video_st==NULL){
       return -1;
    }
    //Param that must set
    pCodecCtx = video_st->codec;
    pCodecCtx->codec_id =AV_CODEC_ID_HEVC;
    pCodecCtx->codec_id = fmt->video_codec;
    pCodecCtx->codec_type = AVMEDIA_TYPE_VIDEO;
    pCodecCtx->pix_fmt = PIX_FMT_YUV420P;
    pCodecCtx->width = in_w;  
    pCodecCtx->height = in_h;
    pCodecCtx->time_base.num = 1;  
    pCodecCtx->time_base.den = 25;  
    pCodecCtx->bit_rate = 400000;  
    pCodecCtx->gop_size=250;
    pCodecCtx->qmin = 10;
    pCodecCtx->qmax = 51;
    pCodecCtx->max_b_frames = 1;

    // Set Option
    AVDictionary *param = 0;
    av_dict_set(&amp;param, "preset", "ultrafast", 0);
    av_dict_set(&amp;param, "tune", "zero-latency", 0);
    av_dict_set(&amp;param, "x265-params", "crf=25", 0);

    pCodec = avcodec_find_encoder(pCodecCtx->codec_id);
    if (!pCodec){
       printf("Can not find encoder! \n");
       return -1;
    }
    if (avcodec_open2(pCodecCtx, pCodec,&amp;param) &lt; 0){
       printf("Failed to open encoder! \n");
       return -1;
    }

    //Write File Header
    avformat_write_header(pFormatCtx, NULL); &lt;------ I think it takes any error in here.

    Help me what I am doing wrong.

    Thank you for your consider.

  • C++ h264 ffmpeg/libav encode/decode(lossless) issues

    1er février 2017, par MrSmith

    Insights to encode/decode video with ffmpeg h264 (lossless)

    So I got something working on the encoding part, encode an avi in 264 however VLC wont play it, however Totem will.
    Decoding the same file proves troublesome. (I want the exact same data/frame going in as going out), I get these ;

    saving frame   5
    Video decoding
    [h264 @ 0x1d19880] decode_slice_header error
    frame :6
    saving frame   6
    Video decoding
    [h264 @ 0x1d19880] error while decoding MB 15 7, bytestream -27
    [h264 @ 0x1d19880] concealing 194 DC, 194 AC, 194 MV errors in I frame
    frame :7
    saving frame   7
    Video decoding
    [h264 @ 0x1d19880] decode_slice_header error

    and ultimatly this

    [H264 Decoder @ 0x7f1320766040] frame :11
    Broken frame packetizing
    [h264 @ 0x1d19880] SPS changed in the middle of the frame
    [h264 @ 0x1d19880] decode_slice_header error
    [h264 @ 0x1d19880] no frame!
    Error while decoding frame 11

    GAME OVER.

    Now I suspect that I have to go back to 1. the encoding part, there is problary a good reason VLC wont play it !

    I encode like this.

    void encode(char *Y,char *U,char *V){
    av_init_packet(&amp;pkt);
    pkt.data = NULL;    // packet data will be allocated by the encoder
    pkt.size = 0;
    fflush(stdout);

    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(c, &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, f);
       av_free_packet(&amp;pkt);
    }
    }

    And the codec is setup like this :

    AVCodecID dasd = AV_CODEC_ID_H264;
    codec = avcodec_find_encoder(dasd);
    c = avcodec_alloc_context3(codec);
    c->bit_rate = 400000;
    c->width = 320;
    c->height = 240;
    c->time_base= (AVRational){1,25};
    c->gop_size = 10;
    c->max_b_frames=1;
    c->pix_fmt = AV_PIX_FMT_YUV420P;
    av_opt_set(c->priv_data, "preset", "slow", 0);
    avcodec_open2(c, codec, NULL);

    Since I am going for lossless i am not dealing with delayed frames(is this a correct assumption ?)
    I may not actually be encoding lossless, it seems like I may have to go with something like

    AVDictionary *param;
    av_dict_set(&amp;param, "qp", "0", 0);

    And then open...

    So I guess me questions is these :

    • What are the correct codec params for lossless encoding (and advice if h264 is a terrible idea in this regard).
    • Do I need to handle delayed frames when going for lossless ?
    • Why is VLC mad at me ?

    Thanks.