Recherche avancée

Médias (0)

Mot : - Tags -/content

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

Autres articles (65)

  • Participer à sa traduction

    10 avril 2011

    Vous pouvez nous aider à améliorer les locutions utilisées dans le logiciel ou à traduire celui-ci dans n’importe qu’elle nouvelle langue permettant sa diffusion à de nouvelles communautés linguistiques.
    Pour ce faire, on utilise l’interface de traduction de SPIP où l’ensemble des modules de langue de MediaSPIP sont à disposition. ll vous suffit de vous inscrire sur la liste de discussion des traducteurs pour demander plus d’informations.
    Actuellement MediaSPIP n’est disponible qu’en français et (...)

  • 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

  • Les statuts des instances de mutualisation

    13 mars 2010, par

    Pour des raisons de compatibilité générale du plugin de gestion de mutualisations avec les fonctions originales de SPIP, les statuts des instances sont les mêmes que pour tout autre objets (articles...), seuls leurs noms dans l’interface change quelque peu.
    Les différents statuts possibles sont : prepa (demandé) qui correspond à une instance demandée par un utilisateur. Si le site a déjà été créé par le passé, il est passé en mode désactivé. publie (validé) qui correspond à une instance validée par un (...)

Sur d’autres sites (10637)

  • Problems accessing codecs with ggplot and gganimate

    19 décembre 2016, par noLongerRandom

    Using gganimate. Can’t figure out how to properly access functionality of ffmpeg, specifically I want to change the codec I’m using in the video file I’m outputting.

    # load packages
    library(ggplot)
    library(animation)
    library(gganimate)

    # Here's my data.frame
    myDf <- data.frame(
       year = c(1962, 1963, 1964, 1965, 1966, 1967, 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014),
       bottom50 = c(0.195, 0.191, 0.187, 0.192, 0.196, 0.205, 0.207, 0.210, 0.209, 0.204, 0.203, 0.204, 0.205, 0.203, 0.202, 0.200, 0.200, 0.201, 0.199, 0.195, 0.190, 0.183, 0.179, 0.179, 0.177, 0.172, 0.169, 0.169, 0.168, 0.166, 0.158, 0.159, 0.158, 0.154, 0.151, 0.148, 0.149, 0.148, 0.146, 0.149, 0.148, 0.145, 0.142, 0.138, 0.135, 0.137, 0.137, 0.136, 0.130, 0.127, 0.123, 0.127, 0.125), top1 = c(0.126, 0.127, 0.129, 0.128, 0.126, 0.123, 0.122, 0.115, 0.110, 0.111, 0.111, 0.109, 0.106, 0.105, 0.105, 0.107, 0.108, 0.111, 0.107, 0.110, 0.112, 0.115, 0.125, 0.125, 0.122, 0.133, 0.149, 0.145, 0.145, 0.139, 0.150, 0.146, 0.147, 0.153, 0.160, 0.166, 0.169, 0.177, 0.183, 0.173, 0.171, 0.172, 0.183, 0.194, 0.201, 0.199, 0.195, 0.185, 0.198, 0.196, 0.208, 0.196, 0.202)
    )

    #Basic plot
    p <- ggplot(myDf, aes(x = year, y = bottom50, frame = year)) +
       geom_line(color = "dodgerblue") +
       geom_line(aes(y = top1), color = "darkred")

    The non-animated version gets me what I want :

    enter image description here

    And I get an animation version output to video with :

    gganimate(p, interval = .1, title_frame = FALSE, "income.mp4")

    That’s fine, but I want to change some the output parameters, specifically : alter the dimensions, the frame rate, and use a different codec.

    # change some of the options
    ani.options(ani.height = 1080, ani.width = 1920,
               interval = 0.04166667, other.opts = "-vcodec qtrle -f mov")
    # re-animate
    gganimate(p, title_frame = FALSE, "income.mov")

    That gives me the following error :

    Error in animation_saver(saver, filename) :
     Don't know how to save animation of type mov

    I’m using ’.mov’ as my file extension because I’m trying to change to the Animation codec (so it’s no longer a .mp4 wrapper). I’ve got ffmpeg installed, so this is probably a syntax issue. But the documentation isn’t very clear here ; gganimate doesn’t have any documentation on changing codecs (or outputting any video besides an mp4), and the animation package is light on specifics as well.

  • rapid TS fragment ffmpeg decoding - memory leak

    9 août 2017, par NadavRub

    Environment :

    • Ubuntu 16.04 (x64)
    • C++
    • ffmpeg

    Use-case

    • Multiple MPEG-TS fragments are rapidly decoded ( numerous every sec )
    • The format of the TS fragments is dynamic and can’t be known ahead of time
    • The first A/V frames of each fragment are needed to be extracted

    Problem statement

    • The code bellow successfully decodes A/V, BUT, has a huge memory leak ( MBytes/sec )
    • According to the docs seems all memory is freed as it should ( does it... ? )

    Why do I get this huge mem leak, what am I missing in the following code snap ?

       struct MEDIA_TYPE {
           ffmpeg::AVMediaType eType;
           union {
               struct {
                   ffmpeg::AVPixelFormat   colorspace;
                   int                     width, height;
                   float                   fFPS;
               } video;
               struct : WAVEFORMATEX {
                   short sSampleFormat;
               } audio;
           } format;
       };

       struct FRAME {
           enum { MAX_PALNES = 3 + 1 };
           int         iStrmId;
           int64_t     pts;    // Duration in 90Khz clock resolution

           uint8_t**   ppData; // Null terminated
           int32_t*    pStride;// Zero terminated
       };

       HRESULT ProcessTS(IN Operation op, IN uint8_t* pTS, IN uint32_t uiBytes, bool(*cb)(IN const MEDIA_TYPE& mt, IN FRAME& frame, IN PVOID pCtx), IN PVOID pCbCtx)
       {
           uiBytes -= uiBytes % 188;// align to 188 packet size

           struct CONTEXT {
               uint8_t* pTS;
               uint32_t uiBytes;
               int32_t  iPos;
           } ctx = { pTS, uiBytes, 0 };

           LOGTRACE(TSDecoder, "ProcessTS(%d, 0x%.8x, %d, 0x%.8x, 0x%.8x), this=0x%.8x\r\n", (int)op, pTS, uiBytes, cb, pCbCtx, this);

           ffmpeg::AVFormatContext* pFmtCtx = 0;
           if (0 == (pFmtCtx = ffmpeg::avformat_alloc_context()))
               return E_OUTOFMEMORY;

           ffmpeg::AVIOContext* pIoCtx = ffmpeg::avio_alloc_context(pTS, uiBytes, 0, &ctx
                                                               , [](void *opaque, uint8_t *buf, int buf_size)->int {
                                                                       auto pCtx = (CONTEXT*)opaque;
                                                                       int size = pCtx->uiBytes;
                                                                       if (pCtx->uiBytes - pCtx->iPos < buf_size)
                                                                           size = pCtx->uiBytes - pCtx->iPos;
                                                                       if (size > 0) {
                                                                           memcpy(buf, pCtx->pTS + pCtx->iPos, size);
                                                                           pCtx->iPos += size;
                                                                       }
                                                                       return size;
                                                                   }
                                                               , 0
                                                               , [](void* opaque, int64_t offset, int whence)->int64_t {
                                                                   auto pCtx = (CONTEXT*)opaque;
                                                                   switch (whence)
                                                                       {
                                                                       case SEEK_SET:
                                                                       pCtx->iPos = offset;
                                                                       break;
                                                                   case SEEK_CUR:
                                                                       pCtx->iPos += offset;
                                                                       break;
                                                                   case SEEK_END:
                                                                       pCtx->iPos = pCtx->uiBytes - offset;
                                                                       break;
                                                                   case AVSEEK_SIZE:
                                                                       return pCtx->uiBytes;
                                                                   }
                                                                   return pCtx->iPos;
                                                               });

       pFmtCtx->pb = pIoCtx;

       int iRet = ffmpeg::avformat_open_input(&pFmtCtx, "fakevideo.ts", m_pInputFmt, 0);
       if (ERROR_SUCCESS != iRet) {
           assert(false);
           pFmtCtx = 0;// a user-supplied AVFormatContext will be freed on failure.
           return E_FAIL;
       }

       struct DecodeContext {
           ffmpeg::AVStream*   pStream;
           ffmpeg::AVCodec*    pDecoder;
           int                 iFramesProcessed;
       };

       HRESULT hr                  = S_OK;
       int     iStreamsProcessed   = 0;

       bool    bVideoFound         = false;
       int64_t ptsLast             = 0;
       int64_t dtsLast             = 0;

       auto pContext = (DecodeContext*)alloca(sizeof(DecodeContext) * pFmtCtx->nb_streams);
       for (unsigned int i = 0; i < pFmtCtx->nb_streams; i++) {
           assert(pFmtCtx->streams[i]->index == i);
           pContext[i].pStream         = pFmtCtx->streams[i];
           pContext[i].pDecoder        = ffmpeg::avcodec_find_decoder(pFmtCtx->streams[i]->codec->codec_id);
           pContext[i].iFramesProcessed= 0;
           if (0 == pContext[i].pDecoder)
               continue;
           if ((iRet = ffmpeg::avcodec_open2(pFmtCtx->streams[i]->codec, pContext[i].pDecoder, NULL)) < 0) {
               _ASSERT(FALSE);
               hr = E_FAIL;
               goto ErrExit;
           }
       }

       while (S_OK == hr) {
           ffmpeg::AVFrame* pFrame = 0;
           ffmpeg::AVPacket pkt;
           ffmpeg::av_init_packet(&pkt);
           if (ERROR_SUCCESS != (iRet = ffmpeg::av_read_frame(pFmtCtx, &pkt))) {
               hr = E_FAIL;
               break;
           }
           if ((0 == dtsLast) && (0 != pkt.dts))
               dtsLast = pkt.dts;
           if ((0 == ptsLast) && (0 != pkt.pts))
               ptsLast = pkt.pts;
           DecodeContext& ctx = pContext[pkt.stream_index];
           if (Operation::DECODE_FIRST_FRAME_OF_EACH_STREAM == op) {
               if (iStreamsProcessed == pFmtCtx->nb_streams) {
                   hr = S_FALSE;
                   goto Next;
               }
               if (ctx.iFramesProcessed > 0)
                   goto Next;
               iStreamsProcessed++;
           }
           if (0 == ctx.pDecoder)
               goto Next;

           if (0 == (pFrame = ffmpeg::av_frame_alloc())) {
               hr = E_OUTOFMEMORY;
               goto Next;
           }

           LOGTRACE(TSDecoder, "ProcessTS(%d, 0x%.8x, %d, 0x%.8x, 0x%.8x), this=0x%.8x, decode, S:%d, T:%d\r\n", (int)op, pTS, uiBytes, cb, pCbCtx, this, pkt.stream_index, ctx.pStream->codec->codec_type);
           int         bGotFrame   = false;
           int         iBytesUsed  =   0;
           MEDIA_TYPE  mt;
           memset(&mt, 0, sizeof(mt));
           mt.eType = ctx.pStream->codec->codec_type;
           switch (mt.eType) {
           case ffmpeg::AVMediaType::AVMEDIA_TYPE_AUDIO:
               ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
               if((iRet = ffmpeg::avcodec_decode_audio4(ctx.pStream->codec, pFrame, &bGotFrame, &pkt)) < 0) {
                   hr = E_FAIL;
                   goto Next;
               }
               _ASSERT(pkt.size == iRet);
               // FFMPEG AAC decoder oddity, first call to 'avcodec_decode_audio4' results mute audio where the second result the expected audio
               bGotFrame = false;
               if ((iRet = ffmpeg::avcodec_decode_audio4(ctx.pStream->codec, pFrame, &bGotFrame, &pkt)) < 0) {
                   hr = E_FAIL;
                   goto Next;
               }
               _ASSERT(pkt.size == iRet);
               ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
               if (false == bGotFrame)
                   goto Next;

               iBytesUsed                      = ctx.pStream->codec->frame_size;
               mt.format.audio.nChannels       = ctx.pStream->codec->channels;
               mt.format.audio.nSamplesPerSec  = ctx.pStream->codec->sample_rate;
               mt.format.audio.wBitsPerSample  = ffmpeg::av_get_bytes_per_sample(ctx.pStream->codec->sample_fmt) * 8;
               mt.format.audio.nBlockAlign     = mt.format.audio.nChannels * mt.format.audio.wBitsPerSample / 8;
               mt.format.audio.sSampleFormat   = (short)pFrame->format;
               break;
           case ffmpeg::AVMediaType::AVMEDIA_TYPE_VIDEO:
               if ((iRet = ffmpeg::avcodec_decode_video2(ctx.pStream->codec, pFrame, &bGotFrame, &pkt)) < 0) {
                   hr = E_FAIL;
                   break;
               }
               if (false == bGotFrame)
                   goto Next;

               assert(ffmpeg::AVPixelFormat::AV_PIX_FMT_YUV420P == ctx.pStream->codec->pix_fmt);// Thats is the only color space currently supported
               iBytesUsed                      = (ctx.pStream->codec->width * ctx.pStream->codec->height * 3) / 2;
               mt.format.video.width           = ctx.pStream->codec->width;
               mt.format.video.height          = ctx.pStream->codec->height;
               mt.format.video.colorspace      = ctx.pStream->codec->pix_fmt;
               mt.format.video.fFPS            = (float)ctx.pStream->codec->framerate.num / ctx.pStream->codec->framerate.den;
               bVideoFound                     = true;
               break;
           default:
               goto Next;
           }

           ctx.iFramesProcessed++;

           {
               FRAME f = { ctx.pStream->index, ((0 == ptsLast) ? dtsLast : ptsLast), (uint8_t**)pFrame->data, (int32_t*)pFrame->linesize };
               if ((iRet > 0) && (false == cb(mt, f, pCbCtx)))
                   hr = S_FALSE;// Breaks the loop
           }
       Next:
           ffmpeg::av_free_packet(&pkt);
           if (0 != pFrame) {
               //ffmpeg::av_frame_unref(pFrame);
               ffmpeg::av_frame_free(&pFrame);
               pFrame = 0;
           }
       }

    ErrExit:
       for (unsigned int i = 0; i < pFmtCtx->nb_streams; i++)
           ffmpeg::avcodec_close(pFmtCtx->streams[i]->codec);

       pIoCtx->buffer = 0;// We have allocated the buffer, no need for ffmpeg to free it 4 us
       pFmtCtx->pb = 0;
       ffmpeg::av_free(pIoCtx);
       ffmpeg::avformat_close_input(&pFmtCtx);
       ffmpeg::avformat_free_context(pFmtCtx);
       return hr;
    }
  • Resize and overlay image on video in android efficiently

    29 décembre 2016, par Bhushan Ladhe

    I want to resize image and video(2160 x 3840) to a same resolution(540 × 960) and then overlay image on video for whole time. This whole process is similar to capturing video and adding caption to it like snap-chat and saving it.

    Since i am successful in doing so using FFMPEG library but it consumes considerable amount of time in processing.

    I have searched the internet for other faster operations but no luck. I will post commands that i am using.

    //1st command (video size from 59MB to 4MB, about time 110secs)
    -i sdcard/VID_20161228_174315.mp4 -vf scale=540:960 sdcard/output540.mp4
    //2nd command (image file , size done, time : a sec hence ignored)
    -i sdcard/capture.jpg -vf scale=540:960 sdcard/capture540.png
    //3rd command (time 80sec)
    -i sdcard/output540.mp4 -i sdcard/capture540.png -filter_complex overlay=0:0 -r 30 sdcard/output_overlay.mp4

    So here using -preset and copying same audio from source did not work as expected.

    Questions :

    1) Should i use specific codec ?

    2) How to achieve Minimum time for processing ?

    3) Will applying multiple threads help ? If yes then how ? I want this process to work in background even if app is closed.

    4) All other options that can combine to make an efficient solution ?

    Log for 3rd command :

    SUCCESS with output : ffmpeg version n3.0.1 Copyright (c) 2000-2016 the FFmpeg developers
                                                                         built with gcc 4.8 (GCC)
                                                                         configuration: --target-os=linux --cross-prefix=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/bin/arm-linux-androideabi- --arch=arm --cpu=cortex-a8 --enable-runtime-cpudetect --sysroot=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/sysroot --enable-pic --enable-libx264 --enable-libass --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-fontconfig --enable-pthreads --disable-debug --disable-ffserver --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-ffprobe --enable-gpl --enable-yasm --disable-doc --disable-shared --enable-static --pkg-config=/home/vagrant/SourceCode/ffmpeg-android/ffmpeg-pkg-config --prefix=/home/vagrant/SourceCode/ffmpeg-android/build/armeabi-v7a --extra-cflags='-I/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all' --extra-ldflags='-L/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/lib -Wl,-z,relro -Wl,-z,now -pie' --extra-libs='-lpng -lexpat -lm' --extra-cxxflags=
                                                                         libavutil      55. 17.103 / 55. 17.103
                                                                         libavcodec     57. 24.102 / 57. 24.102
                                                                         libavformat    57. 25.100 / 57. 25.100
                                                                         libavdevice    57.  0.101 / 57.  0.101
                                                                         libavfilter     6. 31.100 /  6. 31.100
                                                                         libswscale      4.  0.100 /  4.  0.100
                                                                         libswresample   2.  0.101 /  2.  0.101
                                                                         libpostproc    54.  0.100 / 54.  0.100
                                                                       Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'sdcard/output540.mp4':
                                                                         Metadata:
                                                                           major_brand     : isom
                                                                           minor_version   : 512
                                                                           compatible_brands: isomiso2avc1mp41
                                                                           encoder         : Lavf57.25.100
                                                                         Duration: 00:00:10.09, start: 0.021333, bitrate: 2055 kb/s
                                                                           Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 540x960 [SAR 1:1 DAR 9:16], 1930 kb/s, 16.75 fps, 16.75 tbr, 17152 tbn, 33.50 tbc (default)
                                                                           Metadata:
                                                                             handler_name    : VideoHandler
                                                                           Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 119 kb/s (default)
                                                                           Metadata:
                                                                             handler_name    : SoundHandler
                                                                       Input #1, png_pipe, from 'sdcard/output_540.png':
                                                                         Duration: N/A, bitrate: N/A
                                                                           Stream #1:0: Video: png, rgba(pc), 540x960, 25 tbr, 25 tbn, 25 tbc
                                                                       [libx264 @ 0xaca425f0] using SAR=1/1
                                                                       [libx264 @ 0xaca425f0] using cpu capabilities: none!
                                                                       [libx264 @ 0xaca425f0] profile High, level 3.1
                                                                       [libx264 @ 0xaca425f0] 264 - core 148 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - 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=9 lookahead_threads=1 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 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
                                                                       Output #0, mp4, to 'sdcard/output_overlay_forlog.mp4':
                                                                         Metadata:
                                                                           major_brand     : isom
                                                                           minor_version   : 512
                                                                           compatible_brands: isomiso2avc1mp41
                                                                           encoder         : Lavf57.25.100
                                                                           Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 540x960 [SAR 1:1 DAR 9:16], q=-1--1, 30 fps, 15360 tbn, 30 tbc (default)
                                                                           Metadata:
                                                                             encoder         : Lavc57.24.102 libx264
                                                                           Side data:
                                                                             unknown side data type 10 (24 bytes)
                                                                           Stream #0:1(eng): Audio: aac (LC) ([64][0][0][0] / 0x0040), 48000 Hz, stereo, fltp, 128 kb/s (default)
                                                                           Metadata:
                                                                             handler_name    : SoundHandler
                                                                             encoder         : Lavc57.24.102 aac
                                                                       Stream mapping:
                                                                         Stream #0:0 (h264) -> overlay:main (graph 0)
                                                                         Stream #1:0 (png) -> overlay:overlay (graph 0)
                                                                         overlay (graph 0) -> Stream #0:0 (libx264)
                                                                         Stream #0:1 -> #0:1 (aac (native) -> aac (native))
                                                                       Press [q] to stop, [?] for help
                                                                       frame=   19 fps=0.0 q=0.0 size=       0kB time=00:00:00.88 bit
    12-29 02:20:37.914 19213-19213/in.techzilla.happenning_client D/Ffmpeg: Finished command : ffmpeg [Ljava.lang.String;@1a223d4

    here one more txt file for full output

    https://drive.google.com/file/d/0B60iSiCrzaVkUXFpYVFpdGdKN2M/view?usp=drivesdk