Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • 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));
    }
    ?> 
    
  • Rotated video with ffmpeg doesn't play in flowplayer in IE9

    17 octobre 2013, par yoshi

    I have a script that rotates videos 90 degrees and then the videos are displayed on a web page using flowplayer (HTML5 version, not Flash). After the video is rotated once it does not play in IE9 but plays without any other problems in Chrome and Firefox. The error message is: Video file not found.

    I've looked in IE9's developer tools console, in the network tab and the browser streams the whole video.

    The following is the ffmpeg command I use to rotate and convert the video:

    ffmpeg -i input.mov -y -r 30 -b 4M -vf 'transpose=1,scale=800:trunc(ow/a/2)*2' -ar 48000 -vcodec libx264 -profile baseline -preset slow -level 2.2 output.mp4

    This is the input file which I used: https://dl.dropboxusercontent.com/u/37994/local%20capture.mov

    This is the output video: https://dl.dropboxusercontent.com/u/37994/local%20capture%20rotated.mp4

    The input video from above is a screen capture made using QuickTime on Mac OS.

    This also happened for this video: http://mirrorblender.top-ix.org/peach/bigbuckbunny_movies/big_buck_bunny_480p_h264.mov And also this one: https://dl.dropboxusercontent.com/u/37994/clipcanvas_14348_offline.mp4

    This didn't happen for the sample .mov from here: http://support.apple.com/kb/ht1425

    If I run the command twice, meaning I rotate the video 90 degrees and then I rotate the output using the same command once more, the problem disappears, but I need to be able to rotate only 90 degrees.

    This problem doesn't happen if I put IE9 in IE7 or IE8 compatibility mode.

    I was thinking that maybe the problem was how the server serves the video but there's no problem with other videos.

    I looked at the metadata with ffmpeg but didn't see anything significant.

    I already have AddType video/mp4 .mp4 in .htaccess.

    I can't seem to pin down what's causing this problem.

    Edit:

    Request in IE9 IE9 request

    Response in IE9 IE9 response

  • Using FFMPEG to losslessly convert YUV to another format for editing in Adobe Premier

    17 octobre 2013, par Wolfman's Brother

    I have a raw YUV video file that I want to do some basic editing to in Adobe CS6 Premiere, but it won't recognize the file. I thought to use ffmpeg to convert it to something Premiere would take in, but I want this to be lossless because afterwards I will need it in YUV format again. I thought of avi, mov, and prores but I can't seem to figure out the proper command line to ffmpeg and how to ensure it is lossless.

    Thanks for your help.