Recherche avancée

Médias (1)

Mot : - Tags -/sintel

Autres articles (46)

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

  • 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

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

Sur d’autres sites (7092)

  • ffmpeg not setting GOP size for x264

    5 juillet 2012, par Chris Robinson

    Can someone please explain to me why the following settings :

    ffmpeg -i test.avi -vcodec libx264 -g 2 -keyint_min 1 -sc_threshold 100000000 -bf 1 test.mp4

    produces the following output :

    ffmpeg version N-41668-g564bb24 Copyright (c) 2000-2012 the FFmpeg developers
    built on Jun 17 2012 20:18:05 with gcc 4.6.3
    configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-runtime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libass --enable-libcelt --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libopenjpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libutvideo --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --ena  libavutil      51. 58.100 / 51. 58.100
     libavcodec     54. 25.100 / 54. 25.100
     libavformat    54.  6.101 / 54.  6.101
     libavdevice    54.  0.100 / 54.  0.100
     libavfilter     2. 81.100 /  2. 81.100
     libswscale      2.  1.100 /  2.  1.100
     libswresample   0. 15.100 /  0. 15.100
     libpostproc    52.  0.100 / 52.  0.100
    Input #0, avi, from 'test.avi':
     Metadata:
       encoder         : Lavf54.6.101
     Duration: 00:00:01.70, start: 0.000000, bitrate: 4258 kb/s
    Stream #0:0: Video: mpeg4 (Simple Profile) (DIVX / 0x58564944), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 29.97 fps, 29.97 tbr, 29.97 tbn, 30k tbc
    Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, s16, 128 kb/s
    [buffer @ 0000000004115600] w:1280 h:720 pixfmt:yuv420p tb:1001/30000 fr:30000/1001 sar:1/1 sws_param:flags=2
    [ffmpeg_buffersink @ 00000000041157a0] No opaque field provided
    [libx264 @ 000000000411f120] using SAR=1/1
    [libx264 @ 000000000411f120] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2
    [libx264 @ 000000000411f120] profile High, level 3.1
    [libx264 @ 000000000411f120] 264 - core 125 r2200 999b753 - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=36 lookahead_threads=6 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keOutput #0, mp4, to 'test.mp4':
     Metadata:
       encoder         : Lavf54.6.101
       Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 30k tbn, 29.97 tbc
       Stream #0:1: Audio: aac ([64][0][0][0] / 0x0040), 48000 Hz, stereo, s16, 128 kb/s
    Stream mapping:
     Stream #0:0 -> #0:0 (mpeg4 -> libx264)
     Stream #0:1 -> #0:1 (mp3 -> libvo_aacenc)
    Press [q] to stop, [?] for help
    [libvo_aacenc @ 0000000001ebe240] Que input is backward in time
    Last message repeated 8 times
    frame=   35 fps=0.0 q=-1.0 Lsize=     466kB time=00:00:01.10 bitrate=3466.6kbits/s dup=1 drop=0    

    video:436kB audio:28kB global headers:0kB muxing overhead 0.558509%
    [libx264 @ 000000000411f120] frame I:1     Avg QP:24.93  size: 92398
    [libx264 @ 000000000411f120] frame P:28    Avg QP:26.82  size: 12010
    [libx264 @ 000000000411f120] frame B:6     Avg QP:30.37  size:  2764
    [libx264 @ 000000000411f120] consecutive B-frames: 74.3%  5.7%  8.6% 11.4%
    [libx264 @ 000000000411f120] mb I  I16..4: 41.5% 40.1% 18.4%
    [libx264 @ 000000000411f120] mb P  I16..4:  3.9%  1.4%  0.6%  P16..4: 14.3%  4.7%  3.2%  0.0%  0.0%    skip:72.0%
    [libx264 @ 000000000411f120] mb B  I16..4:  1.1%  0.4%  0.1%  B16..8: 14.2%  2.8%  0.6%  direct: 1.1%  skip:79.8%  L0:49.8% L1:39.5% BI:10.8%
    [libx264 @ 000000000411f120] 8x8 transform intra:29.9% inter:76.4%
    [libx264 @ 000000000411f120] coded y,uvDC,uvAC intra: 31.1% 34.4% 18.7% inter: 10.2% 6.3% 3.0%
    [libx264 @ 000000000411f120] i16 v,h,dc,p: 62% 34%  3%  0%
    [libx264 @ 000000000411f120] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 18% 23% 38%  4%  4%  3%  3%  2%  5%
    [libx264 @ 000000000411f120] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 40% 35% 16%  1%  2%  2%  1%  1%  1%
    [libx264 @ 000000000411f120] i8c dc,h,v,p: 52% 20% 24%  3%
    [libx264 @ 000000000411f120] Weighted P-Frames: Y:0.0% UV:0.0%
    [libx264 @ 000000000411f120] ref P L0: 70.5% 10.1% 12.1%  7.3%
    [libx264 @ 000000000411f120] ref B L0: 81.1% 16.9%  2.0%
    [libx264 @ 000000000411f120] ref B L1: 89.7% 10.3%
    [libx264 @ 000000000411f120] kb/s:3050.18

    Why am I not getting an I-Frame every second frame ? Is there something else I can set to do enforce this ? If not, can you suggest how to do this using the mpeg4 codec. It's vital that I can extract what type of frame has been encoded during the encoding process and that I can set a specific GOP structure.

  • FFMPEG : cannot play MPEG4 video encoded from images. Duration and bitrate undefined

    17 juin 2013, par KaiK

    I've been trying to set a H264 video stream created from images, into an MPEG4 container. I've been able to get the video stream from images successfully. But when muxing it in the container, I must do something wrong because no player is able to reproduce it, despite ffplay - that plays the video until the end and after that, the image gets frozen until the eternity -.

    The ffplay cannot identify Duration neither bitrate, so I supose it might be an issue related with dts and pts, but I've searched about how to solve it with no success.

    Here's the ffplay output :

    ~$ ffplay testContainer.mp4
    ffplay version git-2012-01-31-c673671 Copyright (c) 2003-2012 the FFmpeg developers
     built on Feb  7 2012 20:32:12 with gcc 4.4.3
     configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-        libfaac --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-x11grab --enable-libvpx --enable-libmp3lame --enable-debug=3
     libavutil      51. 36.100 / 51. 36.100
     libavcodec     54.  0.102 / 54.  0.102
     libavformat    54.  0.100 / 54.  0.100
     libavdevice    53.  4.100 / 53.  4.100
     libavfilter     2. 60.100 /  2. 60.100
     libswscale      2.  1.100 /  2.  1.100
     libswresample   0.  6.100 /  0.  6.100
     libpostproc    52.  0.100 / 52.  0.100
    [h264 @ 0xa4849c0] max_analyze_duration 5000000 reached at 5000000
    [h264 @ 0xa4849c0] Estimating duration from bitrate, this may be inaccurate
    Input #0, h264, from 'testContainer.mp4':
     Duration: N/A, bitrate: N/A
       Stream #0:0: Video: h264 (High), yuv420p, 512x512, 25 fps, 25 tbr, 1200k tbn, 50 tbc
          2.74 A-V:  0.000 fd=   0 aq=    0KB vq=  160KB sq=    0B f=0/0   0/0

    Structure

    My code is C++ styled, so I've a class that handles all the encoding, and then a main that initilize it, passes some images in a bucle, and finally notify the end of the process as following :

    int main (int argc, const char * argv[])
    {

    MyVideoEncoder* videoEncoder = new MyVideoEncoder(512, 512, 512, 512, "output/testContainer.mp4", 25, 20);
    if(!videoEncoder->initWithCodec(MyVideoEncoder::H264))
    {
       std::cout << "something really bad happened. Exit!!" << std::endl;
       exit(-1);
    }

    /* encode 1 second of video */
    for(int i=0;i<228;i++) {

       std::stringstream filepath;
       filepath << "input2/image" << i << ".jpg";

       videoEncoder->encodeFrameFromJPG(const_cast(filepath.str().c_str()));

    }

    videoEncoder->endEncoding();

    }

    Hints

    I've seen a lot of examples about decoding of a video and encoding into another, but no working example of muxing a video from the scratch, so I'm not sure how to proceed with the pts and dts packet values. That's the reason why I suspect the issue must be in the following method :

    bool MyVideoEncoder::encodeImageAsFrame(){
       bool res = false;


       pTempFrame->pts = frameCount * frameRate * 90; //90Hz by the standard for PTS-values
       frameCount++;

       /* encode the image */
       out_size = avcodec_encode_video(pVideoStream->codec, outbuf, outbuf_size, pTempFrame);


       if (out_size > 0) {
           AVPacket pkt;
           av_init_packet(&pkt);
           pkt.pts = pkt.dts = 0;

           if (pVideoStream->codec->coded_frame->pts != AV_NOPTS_VALUE) {
               pkt.pts = av_rescale_q(pVideoStream->codec->coded_frame->pts,
                       pVideoStream->codec->time_base, pVideoStream->time_base);
               pkt.dts = pTempFrame->pts;

           }
           if (pVideoStream->codec->coded_frame->key_frame) {
               pkt.flags |= AV_PKT_FLAG_KEY;
           }
           pkt.stream_index = pVideoStream->index;
           pkt.data = outbuf;
           pkt.size = out_size;

           res = (av_interleaved_write_frame(pFormatContext, &pkt) == 0);
       }


       return res;
    }

    Any help or insight would be appreciated. Thanks in advance !!

    P.S. The rest of the code, where config is done, is the following :

    // MyVideoEncoder.cpp

    #include "MyVideoEncoder.h"
    #include "Image.hpp"
    #include <cstring>
    #include <sstream>
    #include

    #define MAX_AUDIO_PACKET_SIZE (128 * 1024)



    MyVideoEncoder::MyVideoEncoder(int inwidth, int inheight,
           int outwidth, int outheight, char* fileOutput, int framerate,
           int compFactor) {
       inWidth = inwidth;
       inHeight = inheight;
       outWidth = outwidth;
       outHeight = outheight;
       pathToMovie = fileOutput;
       frameRate = framerate;
       compressionFactor = compFactor;
       frameCount = 0;

    }

    MyVideoEncoder::~MyVideoEncoder() {

    }

    bool MyVideoEncoder::initWithCodec(
           MyVideoEncoder::encoderType type) {
       if (!initializeEncoder(type))
           return false;

       if (!configureFrames())
           return false;

       return true;

    }

    bool MyVideoEncoder::encodeFrameFromJPG(char* filepath) {

       setJPEGImage(filepath);
       return encodeImageAsFrame();
    }



    bool MyVideoEncoder::encodeDelayedFrames(){
       bool res = false;

       while(out_size > 0)
       {
           pTempFrame->pts = frameCount * frameRate * 90; //90Hz by the standard for PTS-values
           frameCount++;

           out_size = avcodec_encode_video(pVideoStream->codec, outbuf, outbuf_size, NULL);

           if (out_size > 0)
           {
               AVPacket pkt;
               av_init_packet(&amp;pkt);
               pkt.pts = pkt.dts = 0;

               if (pVideoStream->codec->coded_frame->pts != AV_NOPTS_VALUE) {
                   pkt.pts = av_rescale_q(pVideoStream->codec->coded_frame->pts,
                           pVideoStream->codec->time_base, pVideoStream->time_base);
                   pkt.dts = pTempFrame->pts;
               }
               if (pVideoStream->codec->coded_frame->key_frame) {
                   pkt.flags |= AV_PKT_FLAG_KEY;
               }
               pkt.stream_index = pVideoStream->index;
               pkt.data = outbuf;
               pkt.size = out_size;


               res = (av_interleaved_write_frame(pFormatContext, &amp;pkt) == 0);
           }

       }

       return res;
    }






    void MyVideoEncoder::endEncoding() {
       encodeDelayedFrames();
       closeEncoder();
    }

    bool MyVideoEncoder::setJPEGImage(char* imgFilename) {
       Image* rgbImage = new Image();
       rgbImage->read_jpeg_image(imgFilename);

       bool ret = setImageFromRGBArray(rgbImage->get_data());

       delete rgbImage;

       return ret;
    }

    bool MyVideoEncoder::setImageFromRGBArray(unsigned char* data) {

       memcpy(pFrameRGB->data[0], data, 3 * inWidth * inHeight);

       int ret = sws_scale(img_convert_ctx, pFrameRGB->data, pFrameRGB->linesize,
               0, inHeight, pTempFrame->data, pTempFrame->linesize);

       pFrameRGB->pts++;
       if (ret)
           return true;
       else
           return false;
    }

    bool MyVideoEncoder::initializeEncoder(encoderType type) {

       av_register_all();

       pTempFrame = avcodec_alloc_frame();
       pTempFrame->pts = 0;
       pOutFormat = NULL;
       pFormatContext = NULL;
       pVideoStream = NULL;
       pAudioStream = NULL;
       bool res = false;

       // Create format
       switch (type) {
           case MyVideoEncoder::H264:
               pOutFormat = av_guess_format("h264", NULL, NULL);
               break;
           case MyVideoEncoder::MPEG1:
               pOutFormat = av_guess_format("mpeg", NULL, NULL);
               break;
           default:
               pOutFormat = av_guess_format(NULL, pathToMovie.c_str(), NULL);
               break;
       }

       if (!pOutFormat) {
           pOutFormat = av_guess_format(NULL, pathToMovie.c_str(), NULL);
           if (!pOutFormat) {
               std::cout &lt;&lt; "output format not found" &lt;&lt; std::endl;
               return false;
           }
       }


       // allocate context
       pFormatContext = avformat_alloc_context();
       if(!pFormatContext)
       {
           std::cout &lt;&lt; "cannot alloc format context" &lt;&lt; std::endl;
           return false;
       }

       pFormatContext->oformat = pOutFormat;

       memcpy(pFormatContext->filename, pathToMovie.c_str(), min( (const int) pathToMovie.length(), (const int)sizeof(pFormatContext->filename)));


       //Add video and audio streams
       pVideoStream = AddVideoStream(pFormatContext,
               pOutFormat->video_codec);

       // Set the output parameters
       av_dump_format(pFormatContext, 0, pathToMovie.c_str(), 1);

       // Open Video stream
       if (pVideoStream) {
           res = openVideo(pFormatContext, pVideoStream);
       }


       if (res &amp;&amp; !(pOutFormat->flags &amp; AVFMT_NOFILE)) {
           if (avio_open(&amp;pFormatContext->pb, pathToMovie.c_str(), AVIO_FLAG_WRITE) &lt; 0) {
               res = false;
               std::cout &lt;&lt; "Cannot open output file" &lt;&lt; std::endl;
           }
       }

       if (res) {
           avformat_write_header(pFormatContext,NULL);
       }
       else{
           freeMemory();
           std::cout &lt;&lt; "Cannot init encoder" &lt;&lt; std::endl;
       }


       return res;

    }



    AVStream *MyVideoEncoder::AddVideoStream(AVFormatContext *pContext, CodecID codec_id)
    {
     AVCodecContext *pCodecCxt = NULL;
     AVStream *st    = NULL;

     st = avformat_new_stream(pContext, NULL);
     if (!st)
     {
         std::cout &lt;&lt; "Cannot add new video stream" &lt;&lt; std::endl;
         return NULL;
     }
     st->id = 0;

     pCodecCxt = st->codec;
     pCodecCxt->codec_id = (CodecID)codec_id;
     pCodecCxt->codec_type = AVMEDIA_TYPE_VIDEO;
     pCodecCxt->frame_number = 0;


     // Put sample parameters.
     pCodecCxt->bit_rate = outWidth * outHeight * 3 * frameRate/ compressionFactor;

     pCodecCxt->width  = outWidth;
     pCodecCxt->height = outHeight;

     /* frames per second */
     pCodecCxt->time_base= (AVRational){1,frameRate};

     /* pixel format must be YUV */
     pCodecCxt->pix_fmt = PIX_FMT_YUV420P;


     if (pCodecCxt->codec_id == CODEC_ID_H264)
     {
         av_opt_set(pCodecCxt->priv_data, "preset", "slow", 0);
         av_opt_set(pCodecCxt->priv_data, "vprofile", "baseline", 0);
         pCodecCxt->max_b_frames = 16;
     }
     if (pCodecCxt->codec_id == CODEC_ID_MPEG1VIDEO)
     {
         pCodecCxt->mb_decision = 1;
     }

     if(pContext->oformat->flags &amp; AVFMT_GLOBALHEADER)
     {
         pCodecCxt->flags |= CODEC_FLAG_GLOBAL_HEADER;
     }

     pCodecCxt->coder_type = 1;  // coder = 1
     pCodecCxt->flags|=CODEC_FLAG_LOOP_FILTER;   // flags=+loop
     pCodecCxt->me_range = 16;   // me_range=16
     pCodecCxt->gop_size = 50;  // g=250
     pCodecCxt->keyint_min = 25; // keyint_min=25


     return st;
    }


    bool MyVideoEncoder::openVideo(AVFormatContext *oc, AVStream *pStream)
    {
       AVCodec *pCodec;
       AVCodecContext *pContext;

       pContext = pStream->codec;

       // Find the video encoder.
       pCodec = avcodec_find_encoder(pContext->codec_id);
       if (!pCodec)
       {
           std::cout &lt;&lt; "Cannot found video codec" &lt;&lt; std::endl;
           return false;
       }

       // Open the codec.
       if (avcodec_open2(pContext, pCodec, NULL) &lt; 0)
       {
           std::cout &lt;&lt; "Cannot open video codec" &lt;&lt; std::endl;
           return false;
       }


       return true;
    }



    bool MyVideoEncoder::configureFrames() {

       /* alloc image and output buffer */
       outbuf_size = outWidth*outHeight*3;
       outbuf = (uint8_t*) malloc(outbuf_size);

       av_image_alloc(pTempFrame->data, pTempFrame->linesize, pVideoStream->codec->width,
               pVideoStream->codec->height, pVideoStream->codec->pix_fmt, 1);

       //Alloc RGB temp frame
       pFrameRGB = avcodec_alloc_frame();
       if (pFrameRGB == NULL)
           return false;
       avpicture_alloc((AVPicture *) pFrameRGB, PIX_FMT_RGB24, inWidth, inHeight);

       pFrameRGB->pts = 0;

       //Set SWS context to convert from RGB images to YUV images
       if (img_convert_ctx == NULL) {
           img_convert_ctx = sws_getContext(inWidth, inHeight, PIX_FMT_RGB24,
                   outWidth, outHeight, pVideoStream->codec->pix_fmt, /*SWS_BICUBIC*/
                   SWS_FAST_BILINEAR, NULL, NULL, NULL);
           if (img_convert_ctx == NULL) {
               fprintf(stderr, "Cannot initialize the conversion context!\n");
               return false;
           }
       }

       return true;

    }

    void MyVideoEncoder::closeEncoder() {
       av_write_frame(pFormatContext, NULL);
       av_write_trailer(pFormatContext);
       freeMemory();
    }


    void MyVideoEncoder::freeMemory()
    {
     bool res = true;

     if (pFormatContext)
     {
       // close video stream
       if (pVideoStream)
       {
         closeVideo(pFormatContext, pVideoStream);
       }

       // Free the streams.
       for(size_t i = 0; i &lt; pFormatContext->nb_streams; i++)
       {
         av_freep(&amp;pFormatContext->streams[i]->codec);
         av_freep(&amp;pFormatContext->streams[i]);
       }

       if (!(pFormatContext->flags &amp; AVFMT_NOFILE) &amp;&amp; pFormatContext->pb)
       {
         avio_close(pFormatContext->pb);
       }

       // Free the stream.
       av_free(pFormatContext);
       pFormatContext = NULL;
     }
    }

    void MyVideoEncoder::closeVideo(AVFormatContext *pContext, AVStream *pStream)
    {
     avcodec_close(pStream->codec);
     if (pTempFrame)
     {
       if (pTempFrame->data)
       {
         av_free(pTempFrame->data[0]);
         pTempFrame->data[0] = NULL;
       }
       av_free(pTempFrame);
       pTempFrame = NULL;
     }

     if (pFrameRGB)
     {
       if (pFrameRGB->data)
       {
         av_free(pFrameRGB->data[0]);
         pFrameRGB->data[0] = NULL;
       }
       av_free(pFrameRGB);
       pFrameRGB = NULL;
     }

    }
    </sstream></cstring>
  • Revision ac22bb6fde : Merge changes I7ff2fa72,I7907230d into experimental * changes : Remove BLOCKD

    26 avril 2013, par John Koleszar

    Merge changes I7ff2fa72,I7907230d into experimental

    * changes :
    Remove BLOCKD structure
    Remove destination pointers from BLOCKD