Recherche avancée

Médias (29)

Mot : - Tags -/Musique

Autres articles (94)

  • MediaSPIP version 0.1 Beta

    16 avril 2011, par

    MediaSPIP 0.1 beta est la première version de MediaSPIP décrétée comme "utilisable".
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Pour avoir une installation fonctionnelle, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
    Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)

  • MediaSPIP 0.1 Beta version

    25 avril 2011, par

    MediaSPIP 0.1 beta is the first version of MediaSPIP proclaimed as "usable".
    The zip file provided here only contains the sources of MediaSPIP in its standalone version.
    To get a working installation, you must manually install all-software dependencies on the server.
    If you want to use this archive for an installation in "farm mode", you will also need to proceed to other manual (...)

  • Amélioration de la version de base

    13 septembre 2013

    Jolie sélection multiple
    Le plugin Chosen permet d’améliorer l’ergonomie des champs de sélection multiple. Voir les deux images suivantes pour comparer.
    Il suffit pour cela d’activer le plugin Chosen (Configuration générale du site > Gestion des plugins), puis de configurer le plugin (Les squelettes > Chosen) en activant l’utilisation de Chosen dans le site public et en spécifiant les éléments de formulaires à améliorer, par exemple select[multiple] pour les listes à sélection multiple (...)

Sur d’autres sites (15682)

  • Files created with a direct stream copy using FFmpeg's libavformat API play back too fast at 3600 fps

    2 octobre 2013, par Chris Ballinger

    I am working on a libavformat API wrapper that converts MP4 files with H.264 and AAC to MPEG-TS segments suitable for streaming. I am just doing a simple stream copy without re-encoding, but the files I produce play the video back at 3600 fps instead of 24 fps.

    Here are some outputs from ffprobe https://gist.github.com/chrisballinger/6733678, the broken file is below :

    r_frame_rate=1/1
    avg_frame_rate=0/0
    time_base=1/90000
    start_pts=0
    start_time=0.000000
    duration_ts=2999
    duration=0.033322

    The same input file manually sent through ffmpeg has proper timestamp information :

    r_frame_rate=24/1
    avg_frame_rate=0/0
    time_base=1/90000
    start_pts=126000
    start_time=1.400000
    duration_ts=449850
    duration=4.998333

    I believe the problem lies somewhere in my setup of libavformat here : https://github.com/OpenWatch/FFmpegWrapper/blob/master/FFmpegWrapper/FFmpegWrapper.m#L349 where I repurposed a bunch of code from ffmpeg.c that was required for the direct stream copy.

    Since 3600 seems like a "magic number" (60*60), it could be as simple as me not setting the time scale properly, but I can't figure out where my code diverges from ffmpeg/avconv itself.

    Similar question here, but I don't think they got as far as I did : Muxing a H.264 Annex B & AAC stream using libavformat with vcopy/acopy

  • Extremely high bit rate when encoding video with libavcodec

    10 janvier 2014, par niculare

    I am trying to capture the camera output and make a video using libavcodec. As an example on how to accomplish this i have used ffmpeg muxing example.

    The problem is that a 4 seconds video has a size of 15mb and a bitrate of 30000 kb/s, although I have set the bitrate on AVCodecContext to 400000 (I consider this value is in bits / sec, not kb/s).

    I have also tried to record the video using ffmpeg from command line and it has a bitrate of 700 kb/s.

    Does anybody have an idea why the bitrate is not preserved and thus the resulting file is very large ? The code I have used to initialize the codec context is below :

    initialization part :

    avformat_alloc_output_context2(&m_formatContext, NULL, NULL, filename);
    outputFormat = m_formatContext->oformat;

    codec = avcodec_find_encoder(outputFormat->video_codec);

    m_videoStream = avformat_new_stream(m_formatContext, codec);

    m_videoStream->id = m_formatContext->nb_streams - 1;

    codecContext = m_videoStream->codec;

    codecContext->codec_id = outputFormat->video_codec;

    codecContext->width = m_videoResolution.width();
    codecContext->height = m_videoResolution.height();

    int m_bitRate = 400000;
    codecContext->bit_rate = m_bitRate;
    codecContext->rc_min_rate = m_bitRate;
    codecContext->rc_max_rate = m_bitRate;
    codecContext->bit_rate_tolerance = 0;

    codecContext->time_base.den = 20;
    codecContext->time_base.num = 1;

    codecContext->pix_fmt = AV_PIX_FMT_YUV422P;

    if (m_formatContext->oformat->flags & AVFMT_GLOBALHEADER)
       codecContext->flags |= CODEC_FLAG_GLOBAL_HEADER;
    /* open it */
    ret = avcodec_open2(codecContext, codec, NULL);

    avFrame = avcodec_alloc_frame();

    ret = avpicture_alloc(&avPicture, codecContext->pix_fmt, codecContext->width, codecContext->height);

    *((AVPicture *)avFrame) = avPicture;

    av_dump_format(m_formatContext, 0, filename, 1);

    if (!(outputFormat->flags & AVFMT_NOFILE)) {
       ret = avio_open(&m_formatContext->pb, filename, AVIO_FLAG_WRITE);
    }

    ret = avformat_write_header(m_formatContext, NULL);

    if (avFrame)
       avFrame->pts = 0;
  • 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.