Newest 'ffmpeg' Questions - Stack Overflow

http://stackoverflow.com/questions/tagged/ffmpeg

Les articles publiés sur le site

  • FFMPEG : Explain parameters of any codecs fuction pointers

    3 décembre 2013, par Zax

    I'm going through the article, How to integrate a codec in FFMPEG multimedia framework. According to it, every codec needs to have 3 basic functions to be defined and these functions are assigned to function pointers of the structure AVCodec.

    The 3 function pointers specified in the above article are:

    .init -> takes care of allocations and other initializations
    
    .close -> freeing the allocated memory and de-initializations
    
    .decode -> frame by frame decoding.
    

    For the function pointer .decode, the funtion assigned is:

    static int cook_decode_frame(AVCodecContext *avctx,
                void *data, int *data_size,
                uint8_t *buf, int buf_size) {
    ...
    

    The details of these parameters are specified in the above article. However, in the latest code, when the same function is taken as an example, its declaration is as shown below:

    static int cook_decode_frame(AVCodecContext *avctx, void *data,
                                 int *got_frame_ptr, AVPacket *avpkt)
    

    I need to perform some mapping operations on the memory. So, i request if anyone could kindly explain the above parameters in the function declarations. Also, which parameter has the input buffer for decoding the frame? And after decoding a frame, to which parameter is the decoded frame mapped?

    Thanks in advance.

    -Regards.

  • FFmpeg convert time to frame

    3 décembre 2013, par William Seemann

    Does anyone know how to convert a timestamp into a frame? For example, if I wanted the frame number at 2 seconds in a video with a framerate of 30/fps it would be the 60th frame. Here is the code I have so far. However, I don't think it's correct since seek_time has a value of 90 (for a 1 sec target) using a video with a framerate of 23.98:

    int timeUs = 1000000; // 1 sec
    AVPacket packet;
    AVPacket *pkt = NULL;
    int64_t desired_frame_number = -1;
    
    State *state = *ps;
    
    Options opt = option;
    
    int stream_index = state->video_stream;
    int64_t seek_time = av_rescale_q(timeUs, AV_TIME_BASE_Q, state->pFormatCtx->streams[stream_index]->time_base);
    int64_t seek_stream_duration = state->pFormatCtx->streams[stream_index]->duration;
    
    int flags = 0;
    int ret = -1;
    
    // Convert time into frame number
    seek_time /= 1000;
    printf("seek time: %" PRId64 "\n", seek_time);
    
  • using ffmpeg command line with python's subprocess module [on hold]

    3 décembre 2013, par user1485853

    I have few wav files that I can use either of the following command line mentioned here to concatenate

    ffmpeg -f concat -i <(for f in ./*.wav; do echo "file '$f'"; done) -c copy output.wav
    ffmpeg -f concat -i <(printf "file '%s'\n" ./*.wav) -c copy output.wav
    ffmpeg -f concat -i <(find . -name '*.wav' -printf "file '%p'\n") -c copy output.wav
    

    anyone know how to convert either of them to work with python's subprocess module, it would be better if your solution is platform independent .

    the <(...) notation does is create a temporary file to contain the result, and inserts that file name on the command line. so is there any way to create a temporary file by Python here ?

  • MPMoviePlayerController and Multiple Audio Streams in a MP4

    3 décembre 2013, par Armin M

    I have an MP4 video with three audio streams for different languages, but when I choose between languages during the playback, the audio stream doesn't switch. What am I missing?

    Here's how I'm playing the video:

    MPMoviePlayerViewController *player = [[MPMoviePlayerViewController alloc] initWithContentURL:videoURL];
    [self presentMoviePlayerViewControllerAnimated:player];
    
  • ffmpeg & png watermark issue

    2 décembre 2013, par mindcast

    I tried to create a watermark (using a png image) on a video like this:

    ffmpeg -i test.wmv -b:a 300k -ar 22050 -t 10 -f flv -s 352x288 -vf "movie = watermark_logo352.png [watermark]; [in][watermark] overlay =0:0 [out]" out.flv
    

    but I get the error:

    ffmpeg version 0.10.4 Copyright (c) 2000-2012 the FFmpeg developers
    built on Jun 14 2012 13:14:31 with gcc 4.4.5   configuration:
    --prefix=/home/username --enable-cross-compile --enable-shared --arch=amd64 --target-os=linux --disable-yasm --enable-decoder=png --enable-encoder=png   
            libavutil      51. 35.100 / 51. 35.100   
            libavcodec     53. 61.100 / 53. 61.100   
            libavformat    53. 32.100 / 53. 32.100   
            libavdevice    53.  4.100 / 53.  4.100   
            libavfilter     2. 61.100 /  2. 61.100   
            libswscale      2.  1.100 /  2.  1.100   
            libswresample   0.  6.100 /  0.  6.100 
            Input #0, asf, from 'test.wmv':   
            Metadata:
                >     WMFSDKVersion   : 9.00.00.2980
                >     WMFSDKNeeded    : 0.0.0.0000
                >     IsVBR           : 1
                >     VBR Peak        : 351
                >     Buffer Average  : 728   Duration: 00:00:05.59, start: 0.000000, bitrate: 574 kb/s
                >     Stream #0:0(jpn): Audio: wmav2 (a[1][0][0] / 0x0161), 22050 Hz, 2 channels, s16, 32 kb/s
                >     Stream #0:1(jpn): Video: wmv1 (WMV1 / 0x31564D57), yuv420p, 352x288, 520 kb/s, SAR 8:9 DAR 88:81, 29.97 tbr, 1k tbn, 1k tbc File
                > 'out2.flv' already exists. Overwrite ? [y/N] y w:352 h:288
                > pixfmt:yuv420p tb:1/1000000 sar:8/9 sws_param: 
        [image2 @ 0x551f880] decoding for stream 0 failed 
        [image2 @ 0x551f880] Could not find codec parameters (Video: png) 
        [movie @ 0x551f440] Failed to find stream info
        [movie @ 0x551f440] Failed to find any codec 
        Error initializing filter 'movie' with args 'watermark_logo352.png' 
        Error opening filters!
    

    When I use a jpg, it works like a charm.

    I'm use ffmpeg v 0.10.4 on Debian 6 Squeeze. Any help would be much appreciated.

    EDIT

    The problem is simpler than i thought. If i use ffmpeg -i with any png image i get a similar error:

      libavutil      51. 35.100 / 51. 35.100
      libavcodec     53. 61.100 / 53. 61.100
      libavformat    53. 32.100 / 53. 32.100
      libavdevice    53.  4.100 / 53.  4.100
      libavfilter     2. 61.100 /  2. 61.100
      libswscale      2.  1.100 /  2.  1.100
      libswresample   0.  6.100 /  0.  6.100
      libpostproc    52.  0.100 / 52.  0.100
    [image2 @ 0xc8b73a0] decoding for stream 0 failed
    [image2 @ 0xc8b73a0] Could not find codec parameters (Video: png)
    watermark.png: could not find codec parameters