Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • How to Use FFMPEG in inside the Delphi [closed]

    2 février 2012, par periyasamy

    Iam beginner in delphi.i create the one sample application i need one help.how to use FFMPEG in inside the delphi?

  • reading video mpegts stream from stdin using libavformat libavcodec

    1er février 2012, par D Starkweather

    I'm trying to read video frames from stdin using ffmpeg's libav* lib collection. Simply passing "pipe:0" or "pipe:" as the filename to avformat_open_input_file() in my program does not do the trick. (e.g. cat /dev/video0 | ./myprogram OR ./myprogram < /dev/video0 ; it also fails using file.avi in place of /dev/video0).

    Peeking into ffmpeg.c, I find the following bit of code using tcsetattr() to set the termios:

    struct termios tty;
    
    if (tcgetattr (0, &tty) == 0) {
    oldtty = tty;
    restore_tty = 1;
    atexit(term_exit);
    
    tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP
                          |INLCR|IGNCR|ICRNL|IXON);
    tty.c_oflag |= OPOST;
    tty.c_lflag &= ~(ECHO|ECHONL|ICANON|IEXTEN);
    tty.c_cflag &= ~(CSIZE|PARENB);
    tty.c_cflag |= CS8;
    tty.c_cc[VMIN] = 1;
    tty.c_cc[VTIME] = 0;
    
    tcsetattr (0, TCSANOW, &tty);
    }
    signal(SIGQUIT, sigterm_handler); /* Quit (POSIX).  */
    }
    
    avformat_network_deinit();
    
    signal(SIGINT , sigterm_handler); /* Interrupt (ANSI).    */
    signal(SIGTERM, sigterm_handler); /* Termination (ANSI).  */
    signal(SIGXCPU, sigterm_handler);
    

    However, when I try this, it appears to have no effect. What settings do I need in the termios struct to continuously read video frames in ?

    Currently, all i am able to do is call av_read_frames a few times (return code 0) before it usually either segfaults or hangs waiting. The buffer usually contains just a blank screen (all black). With any luck, the video buffer will contain the first video frame it comes across, but does not update to the later frames.

    (I'm running this on Debian 6.0) Here's my version of ffmpeg:

    ffmpeg version N-36936-g4cf81d9 Copyright (c) 2000-2012 the FFmpeg developers built on Jan 19 2012 20:51:47 with gcc 4.4.5
    configuration: --enable-shared --enable-gray --enable-hardcoded-tables --enable-runtime-cpudetect --enable-libmp3lame --enable-libopenjpeg --enable-librtmp --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-zlib --enable-gpl libavutil 51. 34.101 / 51. 34.101 libavcodec 53. 57.100 / 53. 57.100 libavformat 53. 30.100 / 53. 30.100 libavdevice 53. 4.100 / 53. 4.100 libavfilter 2. 59.101 / 2. 59.101 libswscale 2. 1.100 / 2. 1.100 libswresample 0. 6.100 / 0. 6.100 libpostproc 52. 0.100 / 52. 0.100 Hyper fast Audio and Video encoder usage: ffmpeg [options] [[infile options] -i infile].

    Thank you very much for any help helpful tips. It is much appreciated.

    D. Grant Starkweather

  • linux vs windows in ffmpeg conversion

    1er février 2012, par user1183169

    I am trying to convert flv files to mp3. Requirement is windows platform.

    so whenever I execute the command in php code it results in failure.

    I have tried to find how to use this command in windows but failed.

    here is the command

    ffmpeg -i /video.flv -vn -acodec copy /video.mp3

    now i know the above command is linux based. I only want to know how to implement it in a windows environement.

    THx in advance

  • 'avcodec_decode_video' of ffmpeg doesn't work

    1er février 2012, par sirupa

    i use vc++ express, and am going to get with ffmpeg..

    but with the 1st program i met a trouble.

    vc++ says 'identifier 'avcodec_decode_video': identifier not found' on commpile process.

    i don't know why....

    next is waht i coded... .

    include "avcodec.h"
    
    include "avformat.h"
    
    include "swscale.h"
    
    int main(int argc, char *argv[])
    
    {
    av_register_all();
    
    AVFormatContext *pFormatCtx;
    
    // Open video file
    
    if(av_open_input_file(&pFormatCtx, argv[1], NULL, 0, NULL)!=0)
    
      return -1; // Couldn't open file
    
    // Retrieve stream information
    
    if(av_find_stream_info(pFormatCtx)<0)
    
        return -1; // Couldn't find stream information
    
    // Dump information about file onto standard error
    
    dump_format(pFormatCtx, 0, argv[1], 0);
    
    
    int i;
    
    AVCodecContext *pCodecCtx;
    
    // Find the first video stream
    
    int videoStream=-1;
    
    for(i=0; inb_streams; i++)
    
        if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO) {
    
        videoStream=i;
    
        break;
    
    }
    
    if(videoStream==-1)
    
        return -1; // Didn't find a video stream
    
    // Get a pointer to the codec context for the video stream
    
    pCodecCtx=pFormatCtx->streams[videoStream]->codec;
    
    AVCodec *pCodec;
    
    
    // Find the decoder for the video stream
    
    pCodec=avcodec_find_decoder(pCodecCtx->codec_id);
    
    if(pCodec==NULL) {
    
        fprintf(stderr, "Unsupported codec!\n");
    
        return -1; // Codec not found
    
    }
    
    // Open codec
    
    if(avcodec_open(pCodecCtx, pCodec)<0)
    
        return -1; // Could not open codec
    
    AVFrame *pFrame;
    
    // Allocate video frame
    
    pFrame=avcodec_alloc_frame();
    
        // Allocate an AVFrame structure
    
    AVFrame* pFrameRGB=avcodec_alloc_frame();
    
    if(pFrameRGB==NULL)
    
      return -1;
    
    uint8_t *buffer;
    
    int numBytes;
    
    // Determine required buffer size and allocate buffer
    
    numBytes=avpicture_get_size(PIX_FMT_RGB24, pCodecCtx->width,pCodecCtx->height);
    
    buffer=(uint8_t *)av_malloc(numBytes*sizeof(uint8_t));
    
    // Assign appropriate parts of buffer to image planes in pFrameRGB
    
    // Note that pFrameRGB is an AVFrame, but AVFrame is a superset
    
    // of AVPicture
    
    avpicture_fill((AVPicture *)pFrameRGB, buffer, PIX_FMT_RGB24,pCodecCtx->width, pCodecCtx->height);
    
    int frameFinished;
    
    AVPacket packet;
    
    i=0;
    
    while(av_read_frame(pFormatCtx, &packet)>=0) {
    
        if(packet.stream_index==videoStream) {
    
    **// here makes compile error**
    
        avcodec_decode_video(pCodecCtx, pFrame, &frameFinished,packet.data, packet.size);
    
        if(frameFinished) {
    
        img_convert((AVPicture *)pFram eRGB, PIX_FMT_RGB24, (AVPicture*)pFrame, pCodecCtx->pix_fmt,pCodecCtx->width, pCodecCtx->height);
    
         }
    av_free_packet(&packet);
    }
    av_free(buffer);
    
    av_free(pFrameRGB);
    
    av_free(pFrame);
    
    avcodec_close(pCodecCtx);
    
    av_close_input_file(pFormatCtx);
    
    
      return 0;
    

    }

  • Alter YUV values of AVFrames in FFMpeg

    1er février 2012, par Kage

    I'm trying to apply an effect to a video by altering the YUV values using FFMpeg programmatically in C.

    Let's say I want to increase the luminescence of each pixel of each frame by 100.

    I tried just altering the first frame of a video stream. I decoded the frame, added 100 to each Y value in the AVFrame->data[0], encoded the frame again and saved it into the video.

    However when I play the video back, it is not only the first frame that has been altered, but the first 30 frames.

    Why are the other frames effected when I only change the AVFrame->data of the first frame?

    I tried again by changing all the Y, U and V values in AVFrame->data to 0 for only the first frame.

    When I play back the video, it starts off completely green like expected, after the first frame the video stays green for 30 frames. I can see the other frames start to come slowly through the green for 30 frames and then suddenly the green disappears and the video plays as normal. Why is it not just the first frame that is green?

    My method is as follows:

    Video Stream

     |
     |     *(Get a frame)*
     |
     v
    

    AVPacket (encoded data)

     |
     |     *(Decode the frame)*
     |
     v
    

    AVFrame (raw data) --------------------------------------------------> AVFrame (raw data)

                      *(Edit AVFrame->data values)*
    
                                                           |
                                                           |     *(encode frame)*
                                                           |
                                                           V
                                                  AVPacket (encoded data)
    
                                                           |
                                                           |     *(save frame)*
                                                           |
                                                           V
                                                      Video Stream
    

    Am I doing something obviously wrong?

    How can I change just one frame without effecting the others?