Recherche avancée

Médias (1)

Mot : - Tags -/ticket

Autres articles (26)

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

  • 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

  • Demande de création d’un canal

    12 mars 2010, par

    En fonction de la configuration de la plateforme, l’utilisateur peu avoir à sa disposition deux méthodes différentes de demande de création de canal. La première est au moment de son inscription, la seconde, après son inscription en remplissant un formulaire de demande.
    Les deux manières demandent les mêmes choses fonctionnent à peu près de la même manière, le futur utilisateur doit remplir une série de champ de formulaire permettant tout d’abord aux administrateurs d’avoir des informations quant à (...)

Sur d’autres sites (8421)

  • current version of ffmpeg3.3.2 encode twice time of my video,the duration last two times long

    20 juin 2017, par jimmy

    I have a video with 00:01:41.46 play time,and transcode it perfect with ffmpeg-2.1.1,but when I upgrade FFmpeg version to 3.3.2 and compile it with the same compile option and same transcode option as 2.1.1 version used, I got a video with 00:03:21.82 long, I played that video to see what was added after 1:41.46, and find that it just repeat the video from the beginning with no audio, I find out no idea to this issue, it seems to be a bug that FFmpeg introducing, anyone help me !

    here is the log that I had transcoded with ffmpeg 3.3.2 :

    ffmpeg -i natural.mp4 -c:v libx264 -c:a copy output.mp4
    ffmpeg version 3.3.2 Copyright (c) 2000-2017 the FFmpeg developers
    built with gcc 4.6 (Ubuntu/Linaro 4.6.4-6ubuntu2)

    configuration: --enable-gpl --enable-nonfree --yasmexe=release/bin/yasm -- prefix=release --cc= --enable-static --disable-shared --disable-debug --extra-cflags=-Irelease/include --extra-ldflags='-Lrelease/lib -lm -ldl' --disable-ffplay --disable-ffprobe --disable-ffserver --disable-doc --enable-postproc --enable-bzlib --enable-zlib --enable-parsers --enable-libx264 --enable-libmp3lame --enable-libfdk-aac --enable-libspeex --enable-pthreads --extra->libs=-lpthread --enable-encoders --enable-decoders --enable-avfilter --enable->muxers --enable-demuxers

    libavutil      55. 58.100 / 55. 58.100
    libavcodec     57. 89.100 / 57. 89.100
    libavformat    57. 71.100 / 57. 71.100
    libavdevice    57.  6.100 / 57.  6.100
    libavfilter     6. 82.100 /  6. 82.100
    libswscale      4.  6.100 /  4.  6.100
    libswresample   2.  7.100 /  2.  7.100
    libpostproc    54.  5.100 / 54.  5.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'natural.mp4':
     Metadata:
     major_brand     : mp42
     minor_version   : 0
     compatible_brands: mp42isom
     creation_time   : 2009-07-11T08:32:34.000000Z
     encoder         : mp4creator 1.6.1d
     Duration: 00:01:41.46, start: 0.000000, bitrate: 9063 kb/s
     Stream #0:0(eng): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 1440x1080 [SAR 4:3 DAR 16:9], 8976 kb/s, 23.98 fps, 23.98 tbr, 90k tbn, 2997 tbc (default)
    Metadata:
       creation_time   : 2009-07-11T08:32:34.000000Z
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
    Metadata:
       creation_time   : 2009-07-11T08:33:09.000000Z
    Stream mapping:
     Stream #0:0 -> #0:0 (mpeg4 (native) -> h264 (libx264))
     Stream #0:1 -> #0:1 (copy)
    Press [q] to stop, [?] for help
    [libx264 @ 0x2d951e0] using SAR=4/3
    [libx264 @ 0x2d951e0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
    [libx264 @ 0x2d951e0] profile High, level 4.0
    [libx264 @ 0x2d951e0] 264 - core 138 r1+3473M a37a143 - H.264/MPEG-4 AVC codec >- Copyleft 2003-2013 - 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=6 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=23 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 'output.mp4':
    Metadata:
     major_brand     : mp42
     minor_version   : 0
     compatible_brands: mp42isom
     encoder         : Lavf57.71.100
    Stream #0:0(eng): Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1440x1080 [SAR 4:3 DAR 16:9], q=-1--1, 23.98 fps, 24k tbn, 23.98 tbc (default)
     Metadata:
       creation_time   : 2009-07-11T08:32:34.000000Z
       encoder         : Lavc57.89.100 libx264
     Side data:
       cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
     Stream #0:1(eng): Audio: aac (LC) ([64][0][0][0] / 0x0040), 44100 Hz, stereo, fltp, 125 kb/s (default)
     Metadata:
       creation_time   : 2009-07-11T08:33:09.000000Z
    frame= 4842 fps= 27 q=-1.0 Lsize=  107608kB time=00:03:21.82
    bitrate=4367.8kbits/s speed=1.11x    
       video:105973kB audio:1556kB subtitle:0kB other streams:0kB global headers:0kB >muxing overhead: 0.074199%
    [libx264 @ 0x2d951e0] frame I:54    Avg QP:19.81  size: 77248
    [libx264 @ 0x2d951e0] frame P:3960  Avg QP:22.01  size: 25371
    [libx264 @ 0x2d951e0] frame B:828   Avg QP:23.01  size:  4680
    [libx264 @ 0x2d951e0] consecutive B-frames: 75.2%  4.6%  4.3% 15.9%
    [libx264 @ 0x2d951e0] mb I  I16..4: 17.0% 79.0%  3.9%
    [libx264 @ 0x2d951e0] mb P  I16..4:  2.1%  7.8%  0.2%  P16..4: 43.9%  9.7% 6.4%  0.0%  0.0%    skip:29.9%
    [libx264 @ 0x2d951e0] mb B  I16..4:  0.2%  1.1%  0.0%  B16..8: 29.2%  1.2%  0.2%  direct: 0.7%  skip:67.3%  L0:49.0% L1:47.7% BI: 3.3%
    [libx264 @ 0x2d951e0] 8x8 transform intra:78.1% inter:81.6%
    [libx264 @ 0x2d951e0] coded y,uvDC,uvAC intra: 52.3% 66.4% 11.9% inter: 20.5% >24.2% 0.8%
    [libx264 @ 0x2d951e0] i16 v,h,dc,p: 32% 22% 28% 18%
    [libx264 @ 0x2d951e0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 19% 19% 43%  3%  3%  3%  5%  2%  4%
    [libx264 @ 0x2d951e0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 24% 12%  4%  8%  7% 11%  4%  5%
    [libx264 @ 0x2d951e0] i8c dc,h,v,p: 50% 23% 23%  4%
    [libx264 @ 0x2d951e0] Weighted P-Frames: Y:1.5% UV:0.3%
    [libx264 @ 0x2d951e0] ref P L0: 71.9% 17.0%  8.5%  2.5%  0.0%
    [libx264 @ 0x2d951e0] ref B L0: 89.7%  9.2%  1.2%
    [libx264 @ 0x2d951e0] ref B L1: 97.5%  2.5%
    [libx264 @ 0x2d951e0] kb/s:4298.67

    Here is the output when use ffmpeg -i natural.mp4 -c copy out.mp4,the output still last double times long :

    ./ffmpeg -i natural.mp4 -c copy out.mp4
    ffmpeg version 3.3.2 Copyright (c) 2000-2017 the FFmpeg developers
    built with gcc 4.6 (Ubuntu/Linaro 4.6.4-6ubuntu2)
     configuration: --enable-gpl --enable-nonfree --yasmexe=release/bin/yasm --prefix=release --cc= --enable-static --disable-shared --disable-debug --extra-cflags=-Irelease/include --extra-ldflags='-Lrelease/lib -lm -ldl' --disable-ffplay --disable-ffprobe --disable-ffserver --disable-doc --enable-postproc --enable-bzlib --enable-zlib --enable-parsers --enable-libx264 --enable-libmp3lame --enable-libfdk-aac --enable-libspeex --enable-pthreads --extra-libs=-lpthread --enable-encoders --enable-decoders --enable-avfilter --enable-muxers --enable-demuxers
     libavutil      55. 58.100 / 55. 58.100
     libavcodec     57. 89.100 / 57. 89.100
     libavformat    57. 71.100 / 57. 71.100
     libavdevice    57.  6.100 / 57.  6.100
     libavfilter     6. 82.100 /  6. 82.100
     libswscale      4.  6.100 /  4.  6.100
     libswresample   2.  7.100 /  2.  7.100
     libpostproc    54.  5.100 / 54.  5.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'natural.mp4':
     Metadata:
       major_brand     : mp42
       minor_version   : 0
       compatible_brands: mp42isom
       creation_time   : 2009-07-11T08:32:34.000000Z
       encoder         : mp4creator 1.6.1d
     Duration: 00:01:41.46, start: 0.000000, bitrate: 9063 kb/s
       Stream #0:0(eng): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 1440x1080 [SAR 4:3 DAR 16:9], 8976 kb/s, 23.98 fps, 23.98 tbr, 90k tbn, 2997 tbc (default)
       Metadata:
         creation_time   : 2009-07-11T08:32:34.000000Z
       Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
       Metadata:
         creation_time   : 2009-07-11T08:33:09.000000Z
    Output #0, mp4, to 'out.mp4':
     Metadata:
       major_brand     : mp42
       minor_version   : 0
       compatible_brands: mp42isom
       encoder         : Lavf57.71.100
       Stream #0:0(eng): Video: mpeg4 (Simple Profile) ( [0][0][0] / 0x0020), yuv420p, 1440x1080 [SAR 4:3 DAR 16:9], q=2-31, 8976 kb/s, 23.98 fps, 23.98 tbr, 90k tbn, 90k tbc (default)
       Metadata:
         creation_time   : 2009-07-11T08:32:34.000000Z
       Stream #0:1(eng): Audio: aac (LC) ([64][0][0][0] / 0x0040), 44100 Hz, stereo, fltp, 125 kb/s (default)
       Metadata:
         creation_time   : 2009-07-11T08:33:09.000000Z
    Stream mapping:
     Stream #0:0 -> #0:0 (copy)
     Stream #0:1 -> #0:1 (copy)
    Press [q] to stop, [?] for help
    frame= 4842 fps=2243 q=-1.0 Lsize=  222944kB time=00:03:21.91
    bitrate=9045.4kbits/s speed=93.5x    
    video:221299kB audio:1556kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.039627%

    Here is the output what ffmpeg-2.1.1 generate,It’s executed correctly :

    ./ffmpeg -i natural.mp4 -c copy output2.mp4
    ffmpeg version 2.1.1 Copyright (c) 2000-2013 the FFmpeg developers
     built on Mar 10 2017 13:56:14 with gcc 4.6 (Ubuntu/Linaro 4.6.4-6ubuntu2)
     configuration: --enable-gpl --enable-nonfree --yasmexe=release/bin/yasm --prefix=release --cc= --enable-static --disable-shared --disable-debug --extra-cflags='-I${ffmpeg_exported_release_dir}/include' --extra-ldflags='-L${ffmpeg_exported_release_dir}/lib -lm -ldl' --disable-ffplay --disable-ffprobe --disable-ffserver --disable-doc --enable-postproc --enable-bzlib --enable-zlib --enable-parsers --enable-libx264 --enable-libmp3lame --enable-libfdk-aac --enable-libspeex --enable-pthreads --extra-libs=-lpthread --enable-encoders --enable-decoders --enable-avfilter --enable-muxers --enable-demuxers
     libavutil      52. 48.101 / 52. 48.101
     libavcodec     55. 39.101 / 55. 39.101
     libavformat    55. 19.104 / 55. 19.104
     libavdevice    55.  5.100 / 55.  5.100
     libavfilter     3. 90.100 /  3. 90.100
     libswscale      2.  5.101 /  2.  5.101
     libswresample   0. 17.104 /  0. 17.104
     libpostproc    52.  3.100 / 52.  3.100
    [mov,mp4,m4a,3gp,3g2,mj2 @ 0x2d2e900] multiple edit list entries, a/v desync might occur, patch welcome
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'natural.mp4':
     Metadata:
       major_brand     : mp42
       minor_version   : 0
       compatible_brands: mp42isom
       creation_time   : 2009-07-11 08:32:34
       encoder         : mp4creator 1.6.1d
     Duration: 00:01:41.46, start: 0.000000, bitrate: 9063 kb/s
       Stream #0:0(eng): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 1440x1080 [SAR 4:3 DAR 16:9], 8976 kb/s, 23.98 fps, 23.98 tbr, 90k tbn, 2997 tbc (default)
       Metadata:
         creation_time   : 2009-07-11 08:32:34
       Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
       Metadata:
         creation_time   : 2009-07-11 08:33:09
    Output #0, mp4, to 'output2.mp4':
     Metadata:
       major_brand     : mp42
       minor_version   : 0
       compatible_brands: mp42isom
       encoder         : Lavf55.19.104
       Stream #0:0(eng): Video: mpeg4 ( [0][0][0] / 0x0020), yuv420p, 1440x1080 [SAR 4:3 DAR 16:9], q=2-31, 8976 kb/s, 23.98 fps, 90k tbn, 90k tbc (default)
       Metadata:
         creation_time   : 2009-07-11 08:32:34
       Stream #0:1(eng): Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, stereo, 125 kb/s (default)
       Metadata:
         creation_time   : 2009-07-11 08:33:09
    Stream mapping:
     Stream #0:0 -> #0:0 (copy)
     Stream #0:1 -> #0:1 (copy)
    Press [q] to stop, [?] for help
    frame= 2421 fps=0.0 q=-1.0 Lsize=  112273kB time=00:01:41.49 bitrate=9062.0kbits/s    
    video:110650kB audio:1556kB subtitle:0 global headers:0kB muxing overhead 0.060302%

    Here is the video link

  • Black screen when playing a video with ffmpeg and SDL on iOS

    1er avril 2012, par patrick

    I'm attempting to create a video player on iOS using ffmpeg and SDL. I'm decoding the video stream and attempting to convert the pixel data into a SDL_Surface and then convert that over to an SDL_Texture and render it on screen. However, all I'm getting is a black screen. I know the video file is good and can be viewed fine from VLC. Any idea what I'm missing here ?

    Initialization code :

       // initialize SDL (Simple DirectMedia Layer) to playback the content
       if( SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER) )
       {
           DDLogError(@"Unable to initialize SDL");
           return NO;
       }

       // create window and renderer
       window = SDL_CreateWindow(NULL, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT,
                                 SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS |
                                 SDL_WINDOW_SHOWN);
       if ( window == 0 )
       {
           DDLogError(@"Unable to initialize SDL Window");
       }

       renderer = SDL_CreateRenderer(window, -1, 0);
       if ( !renderer )
       {
           DDLogError(@"Unable to initialize SDL Renderer");
       }

       // Initialize the FFMpeg and register codecs and their respected file formats
       av_register_all();

    Playback code :
    AVFormatContext *formatContext = NULL ;

    DDLogInfo(@"Opening media file at location:%@", filePath);

    const char *filename = [filePath cStringUsingEncoding:NSUTF8StringEncoding];
    // Open media file
    if( avformat_open_input(&formatContext, filename, NULL, NULL) != 0 )
    {
       DDLogWarn(@"Unable to open media file. [File:%@]", filePath);

       NSString *failureReason = NSLocalizedString(@"Unable to open file.", @"Media playback failed, unable to open file.");

       if ( error != NULL )
       {
           *error = [NSError errorWithDomain:MediaPlayerErrorDomain
                                        code:UNABLE_TO_OPEN
                                    userInfo:[NSDictionary dictionaryWithObject:failureReason
                                                                         forKey:NSLocalizedFailureReasonErrorKey]];
       }

       return NO; // Couldn't open file
    }

    // Retrieve stream information
    if( avformat_find_stream_info(formatContext, NULL) <= 0 )
    {
       DDLogWarn(@"Unable to locate stream information for file. [File:%@]", filePath);

       NSString *failureReason = NSLocalizedString(@"Unable to find audio/video stream information.", @"Media playback failed, unable to find stream information.");

       if ( error != NULL )
       {
           *error = [NSError errorWithDomain:MediaPlayerErrorDomain
                                        code:UNABLE_TO_FIND_STREAM
                                    userInfo:[NSDictionary dictionaryWithObject:failureReason
                                                                         forKey:NSLocalizedFailureReasonErrorKey]];
       }

       return NO;  // Missing stream information
    }

    // Find the first video or audio stream
    int videoStream = -1;
    int audioStream = -1;

    DDLogInfo(@"Locating stream information for media file");

    for( int index=0; index<(formatContext->nb_streams); index++)
    {
       if( formatContext->streams[index]->codec->codec_type==AVMEDIA_TYPE_VIDEO )
       {
           DDLogInfo(@"Found video stream");
           videoStream = index;
           break;
       }
       else if( mediaType == AUDIO_FILE &&
               (formatContext->streams[index]->codec->codec_type==AVMEDIA_TYPE_AUDIO) )
       {
           DDLogInfo(@"Found audio stream");
           audioStream = index;
           break;
       }
    }

    if( videoStream == -1 && (audioStream == -1) )
    {
       DDLogWarn(@"Unable to find video or audio stream for file");

       NSString *failureReason = NSLocalizedString(@"Unable to locate audio/video stream.", @"Media playback failed, unable to locate media stream.");

       if ( error != NULL )
       {
           *error = [NSError errorWithDomain:MediaPlayerErrorDomain
                                        code:UNABLE_TO_FIND_STREAM
                                    userInfo:[NSDictionary dictionaryWithObject:failureReason
                                                                         forKey:NSLocalizedFailureReasonErrorKey]];
       }

       return NO; // Didn't find a video or audio stream
    }

    // Get a pointer to the codec context for the video/audio stream
    AVCodecContext *codecContext;

    DDLogInfo(@"Attempting to locate the codec for the media file");

    if ( videoStream > -1 )
    {
       codecContext = formatContext->streams[videoStream]->codec;

    }
    else
    {
       codecContext = formatContext->streams[audioStream]->codec;
    }

    // Now that we have information about the codec that the file is using,
    // we need to actually open the codec to decode the content

    DDLogInfo(@"Attempting to open the codec to playback the media file");

    AVCodec *codec;

    // Find the decoder for the video stream
    codec = avcodec_find_decoder(codecContext->codec_id);
    if( codec == NULL )
    {
       DDLogWarn(@"Unsupported codec! Cannot playback meda file [File:%@]", filePath);

       NSString *failureReason = NSLocalizedString(@"Unsupported file format. Cannot playback media.", @"Media playback failed, unsupported codec.");
       if ( error != NULL )
       {
           *error = [NSError errorWithDomain:MediaPlayerErrorDomain
                                        code:UNSUPPORTED_CODEC
                                    userInfo:[NSDictionary dictionaryWithObject:failureReason
                                                                         forKey:NSLocalizedFailureReasonErrorKey]];
       }

       return NO; // Codec not found
    }

    // Open codec
    if( avcodec_open2(codecContext, codec, NULL) < 0 )
    {
       DDLogWarn(@"Unable to open codec! Cannot playback meda file [File:%@]", filePath);

       NSString *failureReason = NSLocalizedString(@"Unable to open media codec. Cannot playback media.", @"Media playback failed, cannot open codec.");
       if ( error != NULL )
       {
           *error = [NSError errorWithDomain:MediaPlayerErrorDomain
                                        code:UNABLE_TO_LOAD_CODEC
                                    userInfo:[NSDictionary dictionaryWithObject:failureReason
                                                                         forKey:NSLocalizedFailureReasonErrorKey]];
       }

       return NO; // Could not open codec
    }

    // Allocate player frame
    AVFrame *playerFrame=avcodec_alloc_frame();

    // Allocate an AVFrame structure
    AVFrame *RGBframe=avcodec_alloc_frame();
    if( RGBframe==NULL )
    {
       // could not create a frame to convert our video frame
       // to a 16-bit RGB565 frame.

       DDLogWarn(@"Unable to convert video frame. Cannot playback meda file [File:%@]", filePath);

       NSString *failureReason = NSLocalizedString(@"Problems interpreting video frame information.", @"Media playback failed, cannot convert frame.");
       if ( error != NULL )
       {
           *error = [NSError errorWithDomain:MediaPlayerErrorDomain
                                        code:UNABLE_TO_LOAD_FRAME
                                    userInfo:[NSDictionary dictionaryWithObject:failureReason
                                                                         forKey:NSLocalizedFailureReasonErrorKey]];
       }

       return NO; // Could not open codec
    }

    int frameFinished = 0;
    AVPacket packet;

    // Figure out the destination width/height based on the screen size
    int destHeight = codecContext->height;
    int destWidth  = codecContext->width;
    if ( destHeight > SCREEN_HEIGHT || (destWidth > SCREEN_WIDTH) )
    {
       if ( destWidth > SCREEN_WIDTH )
       {
           float percentDiff = ( destWidth - SCREEN_WIDTH ) / (float)destWidth;
           destWidth  = destWidth  - (int)(destWidth * percentDiff );
           destHeight = destHeight - (int)(destHeight * percentDiff );
       }

       if ( destHeight > SCREEN_HEIGHT )
       {
           float percentDiff = (destHeight - SCREEN_HEIGHT ) / (float)destHeight;
           destWidth  = destWidth  - (int)(destWidth * percentDiff );
           destHeight = destHeight - (int)(destHeight * percentDiff );
       }
    }

    SwsContext *swsContext = sws_getContext(codecContext->width, codecContext->height, codecContext->pix_fmt, destWidth, destHeight, PIX_FMT_RGB565, SWS_BICUBIC, NULL, NULL, NULL);

    while( av_read_frame(formatContext, &packet) >= 0 )
    {
       // Is this a packet from the video stream?
       if( packet.stream_index == videoStream )
       {
           // Decode video frame
           avcodec_decode_video2(codecContext, playerFrame, &frameFinished, &packet);

           // Did we get a video frame?
           if( frameFinished != 0 )
           {
               // Convert the content over to RGB565 (16-bit RGB) to playback with SDL

               uint8_t *dst[3];
               int dstStride[3];

               // Set the destination stride
               for (int plane = 0; plane < 3; plane++)
               {
                   dstStride[plane] = codecContext->width*2;
                   dst[plane]= (uint8_t*) malloc(dstStride[plane]*destHeight);
               }

               sws_scale(swsContext, playerFrame->data,
                         playerFrame->linesize, 0,
                         destHeight,
                         dst, dstStride);

               // Create the SDL surface frame that we are going to use to draw our video

               // 16-bit RGB so 2 bytes per pixel (pitch = width*(bytes per pixel))
               int pitch = destWidth*2;
               SDL_Surface *frameSurface = SDL_CreateRGBSurfaceFrom(dst[0], destWidth, destHeight, 16, pitch, 0, 0, 0, 0);

               // Clear the old frame first
               SDL_RenderClear(renderer);

               // Move the frame over to a texture and render it on screen
               SDL_Texture *texture = SDL_CreateTextureFromSurface(renderer, frameSurface);
               SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);

               // Draw the new frame on the screen
               SDL_RenderPresent(renderer);

               SDL_DestroyTexture(texture);
               SDL_FreeSurface(frameSurface);
           }
  • Converting series of images with ffmpeg results in black video [migrated]

    27 avril 2013, par Marco Gagliardi

    I've just downloaded ffmpeg since it seems to perfectly match my needs (make a video from a set of pictures). I'm currently playing around with some examples just to get started and there's something weird happening that I can't explain.
    I'm trying this command (provided in the official documentation) :

    ffmpeg -f image2 -pattern_type glob -i 'foo-*.jpeg' -r 12 -s WxH foo.avi

    on a data set of 10 jpg pictures (of course I changed the pattern with '*.jpg'). The video seems to be encoded correctly but it's simply too fast to be sure about that (anyway it stops on the last frame that corresponds to the last picture). In order to get a longer video i thought to low the frame rate from 12 to 1 (one sec each picture) or 0.5 (2 sec each one) and so on.. no way ! with low rate values even if the video is played the pictures are simply not displayed. The player (VLC in my case) just shows a blank/empty video for a few seconds.

    Am I making something wrong or have I misunderstood the -r parameter ? Is it something related to codecs involved ? Finally.. How can i get each picture displayed for 1 or 2 seconds ?

    Here's the output :

    MacBook-Pro$ ffmpeg -f image2 -pattern_type glob -i '*.jpg' -r 1 -s 200x300 foo.avi
    ffmpeg version N-52517-g1e4f75d Copyright (c) 2000-2013 the FFmpeg developers
     built on Apr 27 2013 19:41:11 with llvm-gcc 4.2.1 (LLVM build 2336.11.00)
     configuration: --disable-yasm
     libavutil      52. 27.101 / 52. 27.101
     libavcodec     55.  6.100 / 55.  6.100
     libavformat    55.  3.100 / 55.  3.100
     libavdevice    55.  0.100 / 55.  0.100
     libavfilter     3. 61.100 /  3. 61.100
     libswscale      2.  2.100 /  2.  2.100
     libswresample   0. 17.102 /  0. 17.102
    Input #0, image2, from '*.jpg':
     Duration: 00:00:00.40, start: 0.000000, bitrate: N/A
       Stream #0:0: Video: mjpeg, yuvj422p, 2560x1920 [SAR 1:1 DAR 4:3], 25 fps, 25 tbr, 25 tbn, 25 tbc
    File 'foo.avi' already exists. Overwrite ? [y/N] y
    Output #0, avi, to 'foo.avi':
     Metadata:
       ISFT            : Lavf55.3.100
       Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 200x300 [SAR 2:1 DAR 4:3], q=2-31, 200 kb/s, 1 tbn, 1 tbc
    Stream mapping:
     Stream #0:0 -> #0:0 (mjpeg -> mpeg4)
    Press [q] to stop, [?] for help
    frame=    2 fps=0.0 q=2.0 Lsize=      43kB time=00:00:02.00 bitrate= 177.1kbits/s dup=0 drop=8    
    video:38kB audio:0kB subtitle:0 global headers:0kB muxing overhead 15.099197%
    MacBook-Pro$