Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • Android MediaRecorder setCaptureRate() and video playback speed

    7 novembre 2013, par spitzanator

    I've got a MediaRecorder recording video, and I'm very confused by the effect of setCaptureRate().

    Specifically, I prepare my MediaRecorder as follows:

    mMediaRecorder = new MediaRecorder();
    mCamera.stopPreview();
    mCamera.unlock();
    mMediaRecorder.setCamera(mCamera);
    mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
    mMediaRecorder.setProfile(CamcorderProfile.QUALITY_TIME_LAPSE_480P);
    mMediaRecorder.setCaptureRate(30f);
    mMediaRecorder.setOrientationHint(270);
    mMediaRecorder.setOutputFile(...);
    mMediaRecorder.setPreviewDisplay(...);
    mMediaRecorder.prepare();
    

    I record for five seconds (with a CountDownTimer, but that's irrelevant), and this is the file that gets generated:

    $ ffmpeg -i ~/CaptureRate30fps.mp4 
    ...
    Seems stream 0 codec frame rate differs from container frame rate: 180000.00 (180000/1) -> 30.00 (30/1)
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/mspitz/CaptureRate30fps.mp4':
      Metadata:
        major_brand     : isom
        minor_version   : 0
        compatible_brands: isom3gp4
        creation_time   : 2013-06-04 00:52:00
      Duration: 00:00:02.59, start: 0.000000, bitrate: 5238 kb/s
        Stream #0.0(eng): Video: h264 (Baseline), yuv420p, 720x480, 5235 kb/s, PAR 65536:65536 DAR 3:2, 30 fps, 30 tbr, 90k tbn, 180k tbc
        Metadata:
          creation_time   : 2013-06-04 00:52:00
    

    Note that the Duration is just about 3 seconds. The video also plays much faster, as if it were 5 seconds of video crammed into 3.

    Now, if I record by preparing my mediaRecorder exactly as above, but subtracting the setCaptureRate(30f) line, I get a file like this:

    $ ffmpeg -i ~/NoSetCaptureRate.mp4 
    ...
    Seems stream 0 codec frame rate differs from container frame rate: 180000.00 (180000/1) -> 90000.00 (180000/2)
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/mspitz/NoSetCaptureRate.mp4':
      Metadata:
        major_brand     : isom
        minor_version   : 0
        compatible_brands: isom3gp4
        creation_time   : 2013-06-04 00:50:41
      Duration: 00:00:04.87, start: 0.000000, bitrate: 2803 kb/s
        Stream #0.0(eng): Video: h264 (Baseline), yuv420p, 720x480, 2801 kb/s, PAR 65536:65536 DAR 3:2, 16.01 fps, 90k tbr, 90k tbn, 180k tbc
        Metadata:
          creation_time   : 2013-06-04 00:50:41
    

    Note that the Duration is as expected, about 5 seconds. The video also plays at a normal speed.

    I'm using setCaptureRate(30f) because 30 frames per second is the value of my CamcorderProfile's videoFrameRate. On my Galaxy Nexus S2 (4.2.1), omitting setCaptureRate() is fine, but when I tested on a Galaxy Nexus S3 (4.1.1), omitting setCaptureRate() results in the ever-helpful "start failed -22" error when I called mMediaRecorder.start().

    So, what am I missing? I thought that the capture rate and the video frame rate were independent, but it's clear that they're not. Is there a way to determine programmatically what I need to set the capture rate at in order to determine that my video plays back at 1x speed?

  • c++ ffmpeg decode into raw audio which cannot be read afterwards

    7 novembre 2013, par noobed

    Since I don't want to flood with code here I'll reference a link: https://gist.github.com/anonymous/7344267

    Whoever understands ffmpeg documentation (I find it kinda insufficient) could be so kind to take a look at my convert.cpp?

    Q: Any easier way to take audio stream decode it somehow and encode it into mp3?

    After getting the raw audio in myOutputTest.mp3 I'm trying to put together some code using the audio_encode_example (here : http://ffmpeg.org/doxygen/trunk/doc_2examples_2decoding_encoding_8c-example.html)

    The way I see it I should open audio/video file using: avformat_open_input which throws me "Invalid data found when processing input"

    Q: Should I approach audio encoding differently? (But then where do I get all the frame and packet information if not from myOutputTest.mp3?)

  • COMPILATION ISSUES : FFMPEG CODE ON VS2012

    7 novembre 2013, par user2964667

    I have downloaded FFMPEG source code(c code) by the following link

    http://ffmpeg.zeranoe.com/builds/

    After that,I have completed the configuration part then i was generated and linked the library files *[avcodec-54.lib,avdevice-54.lib,avfilter-3.lib,avformat-54.lib,avutil-52.lib,swresample-0.lib,swscale-2.lib ]*on Microsoft Visual Studio C++ by creating a new project by including all .c and header files.

    Referred Links:
    http://www.ffmpeg.org/platform.html#Microsoft-Visual-C_002b_002b-or-Intel-C_002b_002b-Compiler-for-Windows

    When I was compiling on Visual studio 2010... I am getting more than 300 errors under all the files libavcodec,libavdevice,libavfilter,libavformat,libavresample,libavutil,libpostproc,libswresample,libswscale like

    ASM ERRORS:

    error C2400: inline assembler syntax error in 'opcode'; found 'data type'
    error C2065: '__asm__' : undeclared identifier
    error C2143: syntax error : missing ';' before 'volatile'
    

    SYNTAX ERRORS:

    error C2143: syntax error : missing '}' before '.'
    error C2143: syntax error : missing ';' before '.'
    error C2059: syntax error : '.'
    error C2143: syntax error : missing ';' before '}'
    error C2059: syntax error : '}'
    error C2143: syntax error : missing ';' before '{'
    error C2447: '{' : missing function header (old-style formal list?)
    error C2059: syntax error : ','
    error C2143: syntax error : missing ';' before '{'
    error C2447: '{' : missing function header (old-style formal list?)
    

    Please anyone let me know how to compile a ffmpeg c code on vs2010 successfully.

  • Android ffmpeg0.8 is not compiling with android ndk5 with cygwin compiler

    7 novembre 2013, par itsrajesh4uguys

    I am using the following tutorial for ffmpeg compilation .

    http://www.roman10.net/how-to-build-ffmpeg-for-android/

    I am followed all the instructions which they have provided. have changed the path in build_android.sh ,
    i am using android ndk5 and cygwing latest compiler. But i am facing following issue. .so file is not gets created .

    Krajesh@Rajesh /cygdrive/D/RAJESH-ANDROID/Rajesh-workspace/FFMPEG_2
    $ /cygdrive/d/Android_NDK/android-ndk-r5/ndk-build
    Prebuilt       : libffmpeg.so <= jni/ffmpeg-0.8/android/armv7-a/
    Install        : libffmpeg.so => libs/armeabi-v7a/libffmpeg.so
    install: cannot open `/cygdrive/D/RAJESH-ANDROID/Rajesh-workspace/FFMPEG_2/obj/local/armeabi-v7a/libffmpeg.so' for reading: Permission denied
    /cygdrive/d/Android_NDK/android-ndk-r5/build/core/build-binary.mk:305: recipe for target `/cygdrive/D/RAJESH-ANDROID/Rajesh-workspace/FFMPEG_2/libs/armeabi-v7a/libffmpeg.so' failed
    make: *** [/cygdrive/D/RAJESH-ANDROID/Rajesh-workspace/FFMPEG_2/libs/armeabi-v7a/libffmpeg.so] Error 1
    

    Can any one please explain why i am getting that permission denied issue and how to overcome that . i am using windows 7 pc.

    Thanks. Rajesh K

  • Receiving "End of file" while streaming RTSP on iOS

    7 novembre 2013, par Tushar Koul

    I'm using ffmpeg library to stream RTSP from an IP camera in the local network. The streaming is working fine with the code.

    The only problem is that the stream seems to stop after some time. On further debugging I found out that I'm receiving an "End of file" and thats why the loop is breaking.

    while(!playerShouldStop)// && (av_read_frame(pFormatCtx, &pkt1)>=0))
        {
                int ret = av_read_frame(pFormatCtx, &pkt1);
                NSLog(@"av read frame returned = %s",av_err2str(ret));
                if(ret >= 0)
                {
                    // process video
                }
                else 
                   break;
        }
    

    Logs says

    av read frame returned = End of file

    I downloaded Wireshark to check what RTSP packets I'm getting but no help there.

    enter image description here

    First of all is it normal to receive EOF in a live stream (which is not supposed to end).

    Secondly, calling av_read_frame() again and again is not helping either, but when I restart the entire method ( right from avformat_open_input ) then it works. Just that the streaming isn't smooth and comes to a pause every now and then.