Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • is ffmpeg memory-leakful ?

    18 octobre 2013, par user718146

    I have compiled ffmpeg for Android and tried to use it in my app. I did test a bit , but it seemed memory-leakful.

    This is my code:

    void fftest()
    {   
        char *url = "/mnt/sdcard/h264.dat";
        prot_read_avc_buff_init();
    
    AVFormatContext *fmt_ctx = NULL;
    int ret = avformat_open_input(&fmt_ctx, url, 0, NULL);
    if (ret < 0) {
            LOG(LOG_ERROR, __FUNCTION__, "avformat_open_input for url %s failed (%s)", url, strerror(ret) );
    
            return ;
        }
    
        LOGI("avformat_open_input OK ");
    
        if(fmt_ctx) avformat_close_input(&fmt_ctx);
    }
    

    Each time after calling this code, the allocated native heap memory of this Process increased. So, do you guys have any idea about fixing this leak. Or, is there substitute of ffmpeg.

    Thanks for replies!

  • How to compile ffmpeg statically for android

    17 octobre 2013, par Gonzalo Solera

    I´m new on native code, ndk and all of this. I have been searching for a good tutorial but I don´t understand them so much. How can I compile FFmpeg statically for android? I need to encode h264 too. I don´t know how to use the NDK (I have it downloaded on a windows and on a linux os but I think it´s better to use it on linux). Please, I would need detailed answers... Thanks!!

  • Decoding H.264 stream from dvr

    17 octobre 2013, par Andrew S

    I have a security DVR that uses h264 streams. I have been trying to get this to work with zoneminder. I have successfully logged into the dvr and recieved some form of data streams. The data stream is dumped to a fifo/pipe, and then zoneminder uses ffmpeg to read this in.

    Note: i know very very little about h.264 streams. just enough to be stupid.

    The video only updates about every 15 seconds in ZM. I can dump the stream to a file with ffmpeg or avconv (avconv -i /tmp/mypipe cam.mp4) but it is still not right. However, the file created by avconv is WAY WAY better than the one created by ffmpeg.

    I've included a link to the wireshark dump (I did change the PW and login info, etc...). From the data, It appears that the dvr is adding a header to the h264 data streams. I understand that the h264 stream starts with a (0x00 00 01 67) or (0x00 00 01 61). Here is an example of the header plus start of stream:

    0x33, 0x30, 0x64, 0x63, 0x48, 0x32, 0x36, 0x34, 
    0x3f, 0x55, 0x00, 0x00, 0x08, 0x00, 0x20, 0x00, 
    0xa2, 0x7a, 0xea, 0xdc, 0xcf, 0x08, 0x00, 0x00, 
    0x0d, 0x0a, 0x11, 0x07, 0x13, 0x20, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0xe0, 0x14, 
    0xdb, 0x05, 0x87, 0xc4, 0x00, 0x00, 0x00, 0x01, 
    0x68, 0xce, 0x30, 0xa4, 0x80, 0x00, 0x00, 0x00, 
    0x01, 0x06, 0xe5, 0x01, 0x51, 0x80, 0x00, 0x00, 
    0x00, 0x01, 0x65, 0xb8, 0x00, 0x01, 0xa8, 0xac,
    

    I can see that there are a few frame indicators in this message. The DVR's header appears to be 32 bytes long in this case, and in some other messages in the dump, it appears to be 24 bytes long. I am striping the header off before I dump the stream to the pipe. (I have verified the output doesn't include the dvr's headers in any way.

    What I would like help with is determining what I should be sending to the pipe. should I start with the first h.264 key? Is there something out of order? I'm very surprised that ffmpeg is only getting 15 second updates, but avconv is much better (lots of dropped frames, and playback is "sped up".

    using ffmpeg to read the pipe produces a file that shows it's codec as: H264 - MPEG-4 AVC (part 10) (avc1) with a Decoded format: Planar 4:2:0 YUV using vlc.

    Appreciate any help you can provide!

    Wireshark h264 dump

    edit: on Ubuntu 13.04 ffmpeg version: 6:0.8.6-1ubuntu2 avconv 0.8.6-6:0.8.6-1ubuntu2

  • Creating a file from Native c code android

    17 octobre 2013, par Azhagiri

    I am trying to demux a video in android application using FFMPEG library. Everything is working fine. But when i try to create a file from the c code to write the different streams in file fopen returns NULL. I can't proceed after that. My code is

    int ret , got_frame;
    av_register_all();
    LOGE("Registered formats");
    err = av_open_input_file(&pFormatCtx, "file:/mnt/sdcard/input.mp4", NULL, 0, NULL);
    LOGE("Called open file");
    if(err!=0) {
        LOGE("Couldn't open file");
        return;
    }
    LOGE("Opened file");
    
    if(av_find_stream_info(pFormatCtx)<0) {
        LOGE("Unable to get stream info");
        return;
    }
    
    videoStream = -1;
    audioStream = -1;
    for (i=0; inb_streams; i++) {
        if(pFormatCtx->streams[i]->codec->codec_type==CODEC_TYPE_VIDEO) {
            videoStream = i;
            if(audioStream != -1)
            break;
        }
    
        if(pFormatCtx->streams[i]->codec->codec_type==CODEC_TYPE_AUDIO) {
                    audioStream = i;
                    if(videoStream != -1)
                    break;
                }
    
    }
    if(videoStream==-1) {
        LOGE("Unable to find video stream");
        return;
    }
    if(audioStream==-1) {
          LOGE("Unable to find audio stream");
          return;
      }
    
    LOGI("Video stream is [%d] Audio stream [%d]", videoStream,audioStream);
    
    pCodecCtx=pFormatCtx->streams[videoStream]->codec;
    
    pCodecCtxAudio=pFormatCtx->streams[audioStream]->codec;
    
    LOGI("Video size is [%d x %d]", pCodecCtx->width, pCodecCtx->height);
    
    videoOut = fopen("file:/mnt/sdcard/videoout.mp4","wb");
    if (videoOut == NULL) {
        LOGE("Unable to open output video");
        return;
       } 
    

    What is the problem with my code. I enabled permissions for the application to write in external storage. Also the path i specified is also correct. Help me.

  • PHP : Create image from video using ffmpeg

    17 octobre 2013, par user2715503

    i put php_ffmpeg.dll in php/ext(xampp) and added extension in php.ini.

    Also putswscale-0.dll, pthreadGC2.dll, avutil-50.dll,avformat-52.dll, avdevice-52.dll, avcodec-52.dll in SysWOW64 folder for windows 8 64.

    I created folder in drive c:/ffmpeg in put ffmpeg package.

    now when I check phpinfo I see that ffmpeg worked but ffmpeg command doesn't not work. how to fix this?

    Here is my code:

    <?php
    $infile = 'C:\xampp\htdocs\mem\12.mp4';
    $outfile = 'C:\xampp\htdocs\mem\1.jpg';
    exec("C:\ffmpeg\bin\ffmpeg.exe -i " . escapeshellarg($infile) . " -an -ss 00:00:03 -an -r 1 -vframes 1 -y " . escapeshellarg($outfile) . " 2>&1", $output, $returnValue);
    if (!file_exists($outfile)) {
         die("Could not generate thumbnail. ffmpeg output: \n\n" . implode("\n", $output));
    }
    ?>