Recherche avancée

Médias (0)

Mot : - Tags -/diogene

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

Autres articles (49)

  • 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

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

Sur d’autres sites (9677)

  • Bitmap images to WEBM video encoding

    21 novembre 2013, par Ankush

    I am trying to encode bitmap images to webm video,but generated video is not playable
    Here is code I am using,code works fine for H624.
    While encoding console windows shows : [libvpx @ 009b2f60] v1.2.0
    there is no webm string in produced video file. Any clue ? ( I am newbie for FFMPEG API )

    void create_from_bmp()
    {
    CFile file[5];  
    BYTE *szTxt[5];  

    int nWidth = 0;  
    int nHeight= 0;  

    int nDataLen=0;  

    int nLen;  

    CString csFileName;  
    for (int fileI = 1; fileI <= 5; fileI ++)  
    {
     csFileName.Format("e:\\pics\\%d.bmp",fileI);  
     file[fileI - 1].Open(csFileName,CFile::modeRead | CFile::typeBinary);  
     nLen = file[fileI - 1].GetLength();  

     szTxt[fileI -1] = new BYTE[nLen];  
     file[fileI - 1].Read(szTxt[fileI - 1], nLen);  
     file[fileI - 1].Close();  

     //BMP bmi;//BITMAPINFO bmi;  
     //int nHeadLen = sizeof(BMP);  
     BITMAPFILEHEADER bmpFHeader;  
     BITMAPINFOHEADER bmpIHeader;  
     memcpy(&bmpFHeader,szTxt[fileI -1],sizeof(BITMAPFILEHEADER));  

     int nHeadLen = bmpFHeader.bfOffBits - sizeof(BITMAPFILEHEADER);  
     memcpy(&bmpIHeader,szTxt[fileI - 1]+sizeof(BITMAPFILEHEADER),nHeadLen);  

     nWidth = bmpIHeader.biWidth;// 464;// bmi.bmpInfo.bmiHeader.biWidth;// ;  
     nHeight = bmpIHeader.biHeight;//362;// bmi.bmpInfo.bmiHeader.biHeight;// ;  

     szTxt[fileI - 1] += bmpFHeader.bfOffBits;  
     nDataLen = nLen-bmpFHeader.bfOffBits;  
    }  

    av_register_all();  
    avcodec_register_all();  
    AVFrame *m_pRGBFrame =  new AVFrame[1];  //RGB    
    AVFrame *m_pYUVFrame = new AVFrame[1];;  //YUV
    AVCodecContext *c= NULL;  
    AVCodecContext *in_c= NULL;  
    AVCodec *pCodecH264;
    uint8_t * yuv_buff;//  

    pCodecH264 = avcodec_find_encoder(CODEC_ID_VP8);  
    if(!pCodecH264)  
    {  
     fprintf(stderr, "h264 codec not found\n");  
     exit(1);  
    }  

    c= avcodec_alloc_context3(pCodecH264);  
    c->bit_rate = 3000000;// put sample parameters  
    c->width =nWidth;//  
    c->height = nHeight;//  

    // frames per second  
    AVRational rate;  
    rate.num = 1;  
    rate.den = 5;  //5 frames per sec
    c->time_base= rate;//(AVRational){1,25};  
    c->gop_size = 10; // emit one intra frame every ten frames   //emit one iframe per sec
    c->max_b_frames=0;  //
    c->thread_count = 1;  
    c->pix_fmt = PIX_FMT_YUV420P;//PIX_FMT_RGB24;  
    c->codec_id=CODEC_ID_VP8;

    //av_opt_set(c->priv_data, /*"preset"*/"libvpx-1080p.ffpreset", /*"slow"*/NULL, 0);  
    if(avcodec_open2(c,pCodecH264,NULL)<0)  
     printf("Cant open codec");

    int size = c->width * c->height;  

    yuv_buff = (uint8_t *) malloc((size * 3) / 2); // size for YUV 420    

    uint8_t * rgb_buff = new uint8_t[nDataLen];  

    int outbuf_size=400000;  
    uint8_t * outbuf= (uint8_t*)malloc(outbuf_size);  
    int u_size = 0;  
    FILE *f=NULL;  
    char * filename = "e:\\pics\\myData.h264";  
    f = fopen(filename, "wb");  
    if (!f)  
    {  
     printf( "could not open %s\n", filename);  
     exit(1);  
    }  

    //SwsContext  
    SwsContext * scxt = sws_getContext(c->width,c->height,PIX_FMT_BGR24,c->width,c->height,PIX_FMT_YUV420P,SWS_POINT,NULL,NULL,NULL);  

    AVPacket avpkt;  

    //AVFrame *pTFrame=new AVFrame  
    for (int i=0;i<60;++i)  
    {  
     //AVFrame *m_pYUVFrame = new AVFrame[1];  

     int index = (i / 5) % 5;  
     memcpy(rgb_buff,szTxt[index],nDataLen);  

     avpicture_fill((AVPicture*)m_pRGBFrame, (uint8_t*)rgb_buff, PIX_FMT_RGB24, nWidth, nHeight);  

     avpicture_fill((AVPicture*)m_pYUVFrame, (uint8_t*)yuv_buff, PIX_FMT_YUV420P, nWidth, nHeight);  

     m_pRGBFrame->data[0]  += m_pRGBFrame->linesize[0] * (nHeight - 1);  
     m_pRGBFrame->linesize[0] *= -1;                    
     m_pRGBFrame->data[1]  += m_pRGBFrame->linesize[1] * (nHeight / 2 - 1);  
     m_pRGBFrame->linesize[1] *= -1;  
     m_pRGBFrame->data[2]  += m_pRGBFrame->linesize[2] * (nHeight / 2 - 1);  
     m_pRGBFrame->linesize[2] *= -1;  


     sws_scale(scxt,m_pRGBFrame->data,m_pRGBFrame->linesize,0,c->height,m_pYUVFrame->data,m_pYUVFrame->linesize);  

     int got_packet_ptr = 0;  
     av_init_packet(&avpkt);  
     avpkt.data = outbuf;  
     avpkt.size = outbuf_size;  
     u_size = avcodec_encode_video2(c, &avpkt, m_pYUVFrame, &got_packet_ptr);  
     if (u_size == 0)  
     {  
      fwrite(avpkt.data, 1, avpkt.size, f);  
     }  
    }

    fclose(f);  
    delete []m_pRGBFrame;  
    delete []m_pYUVFrame;  
    delete []rgb_buff;  
    free(outbuf);  
    avcodec_close(c);  
    av_free(c);  
    }

    I want to use this code to record screen by encoding screenshots. what fps,gop size or other parameters i can use to reduce size of video.

  • Convert raw yuv to mp4 crashed on android

    19 décembre 2013, par Sunderr

    Here is my steps :

    1. Decode a jpeg file to rgb565 ;(Success) ;

    2. Convert rgb565 to yuv420 ;(Not sure if it works, function "Bitmap2Yuv420")

    3. Convert yuv420 to mp4. (Crash when call avcodec_open2) ;

    And that is the codes :

    void ADKJpegDecoder::Bitmap2Yuv420(const char * outfilename) {
    unsigned char *destination = new unsigned char[m_Width * m_Height
           * m_BytesPerPixel / 2];
    unsigned char* rgb = m_RawImage;
    size_t image_size = m_Width * m_Height;
    size_t upos = image_size;
    size_t vpos = upos + upos / 4;
    size_t i = 0;

    for (size_t line = 0; line < m_Height; ++line) {
       if (!(line % 2)) {
           for (size_t x = 0; x < m_Width; x += 2) {
               char r = rgb[3 * i];
               char g = rgb[3 * i + 1];
               char b = rgb[3 * i + 2];

               destination[i++] = ((66 * r + 129 * g + 25 * b) >> 8) + 16;

               destination[upos++] = ((-38 * r + -74 * g + 112 * b) >> 8)
                       + 128;
               destination[vpos++] = ((112 * r + -94 * g + -18 * b) >> 8)
                       + 128;

               r = rgb[3 * i];
               g = rgb[3 * i + 1];
               b = rgb[3 * i + 2];

               destination[i++] = ((66 * r + 129 * g + 25 * b) >> 8) + 16;
           }
       } else {
           for (size_t x = 0; x < m_Width; x += 1) {
               char r = rgb[3 * i];
               char g = rgb[3 * i + 1];
               char b = rgb[3 * i + 2];

               destination[i++] = ((66 * r + 129 * g + 25 * b) >> 8) + 16;
           }
       }
    }

    ADKVideoEncoder::getInstance()->startEncodeVideo(destination);
    delete[] destination;

    }

    void ADKVideoEncoder::startEncodeVideo(unsigned char* rawDatas) {
    AVFormatContext* oc;
    AVOutputFormat* fmt;
    AVStream* video_st;
    AVCodecContext* c;

    double video_pts;
    uint8_t* video_outbuf;
    AVFrame* picture;
    int size;
    int ret;
    int video_outbuf_size;

    const char* filename = "/sdcard/test.mpg";

    av_register_all();

    fmt = av_guess_format(NULL, filename, NULL);
    oc = avformat_alloc_context();
    oc->oformat = fmt;
    snprintf(oc->filename, sizeof(oc->filename), "%s", filename);

    video_st = NULL;
    if (fmt->video_codec != CODEC_ID_NONE) {
       video_st = av_new_stream(oc, 0);
       c = video_st->codec;
       c->codec_id = fmt->video_codec;
       c->codec_type = AVMEDIA_TYPE_VIDEO;
       c->bit_rate = 400000;
       c->width = 320;
       c->height = 480;
       c->time_base.num = 1;
       c->time_base.den = 1;
       c->gop_size = 12;
       c->pix_fmt = PIX_FMT_YUV420P;
       c->max_b_frames = 0;
       if (!strcmp(oc->oformat->name, "mp4")
               || !strcmp(oc->oformat->name, "mov")
               || !strcmp(oc->oformat->name, "3gp")) {
           c->flags |= CODEC_FLAG_GLOBAL_HEADER;
       }
    }

    av_dump_format(oc, 0, filename, 1);
    if (video_st) {
       AVCodec* codec = avcodec_find_encoder(c->codec_id);
       if (!codec) {
           return;
       }
       AVDictionary *optionsDict = NULL;
       if (avcodec_open2(c, codec, &optionsDict) < 0) {
           return;
       }
       if (!(oc->oformat->flags & AVFMT_RAWPICTURE)) {
           video_outbuf_size = 20000;
           video_outbuf = (uint8_t*) av_malloc(video_outbuf_size);
       }
       picture = avcodec_alloc_frame();
       size = avpicture_get_size(c->pix_fmt, c->width, c->height);
       avpicture_fill((AVPicture*) picture, rawDatas, c->pix_fmt, c->width,
               c->height);
    }

    if (!(fmt->flags & AVFMT_NOFILE)) {
       if (avio_open(&oc->pb, filename, AVIO_FLAG_WRITE) < 0) {
           return;
       }
    }
    avformat_write_header(oc, 0);

    if (video_st) {
       video_pts = (double) (video_st->pts.val * video_st->time_base.num
               / video_st->time_base.den);
    } else {
       video_pts = 0.0;
    }
    if (!video_st/* || video_pts >= 5.0*/) {
       return;
    }
    c = video_st->codec;
    size = c->width * c->height;

    picture->data[0] = rawDatas;
    picture->data[1] = rawDatas + size;
    picture->data[2] = rawDatas + size * 5 / 4;

    if (oc->oformat->flags & AVFMT_RAWPICTURE) {
       AVPacket pkt;
       av_init_packet(&pkt);
       pkt.flags |= AV_PKT_FLAG_KEY;
       pkt.stream_index = video_st->index;
       pkt.data = (uint8_t*) picture;
       pkt.size = sizeof(AVPicture);
       ret = av_write_frame(oc, &pkt);
    } else {
       int out_size = avcodec_encode_video(c, video_outbuf, video_outbuf_size,
               picture);
       if (out_size > 0) {
           AVPacket pkt;
           av_init_packet(&pkt);
           pkt.pts = av_rescale_q(c->coded_frame->pts, c->time_base,
                   video_st->time_base);
           if (c->coded_frame->key_frame) {
               pkt.flags |= AV_PKT_FLAG_KEY;
           }
           pkt.stream_index = video_st->index;
           pkt.data = video_outbuf;
           pkt.size = out_size;
           ret = av_write_frame(oc, &pkt);
       }
    }

    if (video_st) {
       avcodec_close(video_st->codec);
       av_free(picture);
       av_free(video_outbuf);
    }
    av_write_trailer(oc);
    for (int i = 0; i < oc->nb_streams; i++) {
       av_freep(&oc->streams[i]->codec);
       av_freep(&oc->streams[i]);
    }
    if (!(fmt->flags & AVFMT_NOFILE)) {
       avio_close(oc->pb);
    }
    av_free(oc);

    }

    So can anyone find out the problem ? Thanks very much ! ;

  • ffmpeg mysteriously adding start delay [migrated]

    13 janvier 2014, par swizzcheez

    When converting a mp4 to TS, I am observing ffmpeg adding a "start" delay that the input file did not seem to possess. For my input, ffprobe reveals :

    ffprobe version N-57943-g7b76976 Copyright (c) 2007-2013 the FFmpeg developers
     built on Nov  6 2013 14:00:40 with gcc 4.4.5 (Debian 4.4.5-8)
     configuration: --enable-libx264 --enable-gpl
     libavutil      52. 52.100 / 52. 52.100
     libavcodec     55. 41.100 / 55. 41.100
     libavformat    55. 21.100 / 55. 21.100
     libavdevice    55.  5.100 / 55.  5.100
     libavfilter     3. 90.102 /  3. 90.102
     libswscale      2.  5.101 /  2.  5.101
     libswresample   0. 17.104 /  0. 17.104
     libpostproc    52.  3.100 / 52.  3.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'output.mp4-in-7A8FEADA-5EA6-11E3-AD13-4DD2258FBC88.mp4':
     Metadata:
       major_brand     : mp42
       minor_version   : 0
       compatible_brands: mp42mp41
       creation_time   : 2013-11-08 15:15:12
     Duration: 00:00:11.56, start: 0.000000, bitrate: 2994 kb/s
       Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv), 1280x720 [SAR 1:1 DAR 16:9], 2807 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
       Metadata:
         creation_time   : 2013-11-08 15:15:12
         handler_name    : ?Mainconcept Video Media Handler
       Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 189 kb/s (default)
       Metadata:
         creation_time   : 2013-11-08 15:15:12
         handler_name    : #Mainconcept MP4 Sound Media Handler

    But when processed using ffmpeg :

    ffmpeg -i '/tmp/test-no-qp.C2162DFC-6297-11E3-A68D-05E505A3FB93/output.mp4-in-7A8FEADA-5EA6-11E3-AD13-4DD2258FBC88.mp4' -s 1920x1080 -preset ultrafast -f mpegts -c:v libx264 -qp:v 18 `enter code here`

    I get an extra start delay :

    (Snipping the same headers from the input side)
    Input #0, mpegts, from 'output.mp4-out-7A8FEADA-5EA6-11E3-AD13-4DD2258FBC88.mp4':
     Duration: 00:00:11.55, start: 1.400000, bitrate: 1985 kb/s
     Program 1
       Metadata:
         service_name    : Service01
         service_provider: FFmpeg
       Stream #0:0[0x100]: Video: h264 (Constrained Baseline) ([27][0][0][0] / 0x001B), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
       Stream #0:1[0x101](eng): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 128 kb/s

    Duration seems to have been adjusted as well, but I didn't ask for the adjustment. How do I get rid of that ? What did I do that triggered that effect ? Is there something else about my ffmpeg line that looks off ?

    (ffmpeg version is the same as the ffprobe above.)