Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • Video editing : faded speedup/slowdown with free software

    25 octobre 2013, par Valio

    I would like to do "faded" speedups or slowdowns within videos. To illustrate what I mean here's a short clip of what I call "faded slowdown"

    So in a scene running at normal speed, there is a timeframe where the video slows down (or speeds up) and then runs again at normal speed. However the speed does not drop from 1 to e.g. 0.2 in a millisecond, but there's a smooth transition inbetween (I'm not certain if linear or not).

    I guess my video edtiting/cutting terminology is entirely flawed; don't hesitate to correct it.

    1. Is anyone aware of a free software (*) video editor that offers such functionality?
    2. Has anyone tried to implement it themself? I guess it's not really that hard by using a script that generates necessary calls for ffmpeg or the like.

    over at least one second. the have one scene that runs at normal speed and at some point has a short slowdown or speedup. Basically we have one scene that gets I have not done any experiments yet, but If my terminology is confusing an exa

    (* as in free speech)

  • Move metadata from end of video to start of video ?

    25 octobre 2013, par Ahmed Nawaz

    I am recording video using javacv(ffmpeg and open cv) then cutting and merging with mp4parser. Then converting from H263 to H264 using Javacv. After doing these all things getting my required video with a little problem that metadata is on the end of file due to ffmpeg and I can't play video progressively. I am able to move data on pc using qt-faststart after that my video is fine. However I want to move data from end to start in my android application is it possibal to move data using mp4parser or some other library in android??

    I have tried followings.

    recorder.setVideoOption("-movflags", "faststart"); 
    recorder.setVideoOption("movflags", "faststart"); 
    recorder.setVideoOption("movflags", "+faststart"); 
    
  • How to publish selfmade stream with ffmpeg and c++ to rtmp server ?

    25 octobre 2013, par Alexandr R

    Have a nice day to you, people!

    I am writing an application for Windows that will capture the screen and send the stream to Wowza server by rtmp (for broadcasting). My application use ffmpeg and Qt. I capture the screen with WinApi, convert a buffer to YUV444(because it's simplest) and encode frame as described at the file decoding_encoding.c (from FFmpeg examples):

    ///////////////////////////
    //Encoder initialization
    ///////////////////////////
    avcodec_register_all();
    codec=avcodec_find_encoder(AV_CODEC_ID_H264);
    c = avcodec_alloc_context3(codec);
    c->width=scr_width;
    c->height=scr_height;
    c->bit_rate = 400000;
    int base_num=1;
    int base_den=1;//for one frame per second
    c->time_base= (AVRational){base_num,base_den};
    c->gop_size = 10;
    c->max_b_frames=1;
    c->pix_fmt = AV_PIX_FMT_YUV444P;
    av_opt_set(c->priv_data, "preset", "slow", 0);
    
    frame = avcodec_alloc_frame();
    frame->format = c->pix_fmt;
    frame->width  = c->width;
    frame->height = c->height;
    
    for(int counter=0;counter<10;counter++)
    {
    ///////////////////////////
    //Capturing Screen
    ///////////////////////////
        GetCapScr(shotbuf,scr_width,scr_height);//result: shotbuf is filled by screendata from HBITMAP
    ///////////////////////////
    //Convert buffer to YUV444 (standard formula)
    //It's handmade function because of problems with prepare buffer to swscale from HBITMAP
    ///////////////////////////
        RGBtoYUV(shotbuf,frame->linesize,frame->data,scr_width,scr_height);//result in frame->data
    ///////////////////////////
    //Encode Screenshot
    ///////////////////////////
        av_init_packet(&pkt);
        pkt.data = NULL;    // packet data will be allocated by the encoder
        pkt.size = 0;
        frame->pts = counter;
        avcodec_encode_video2(c, &pkt, frame, &got_output);
        if (got_output) 
        {
            //I think that  sending packet by rtmp  must be here!
            av_free_packet(&pkt);             
    
        }
    
    }
    // Get the delayed frames
    for (int got_output = 1,i=0; got_output; i++)
    {
        ret = avcodec_encode_video2(c, &pkt, NULL, &got_output);
        if (ret < 0)
            {
                fprintf(stderr, "Error encoding frame\n");
                exit(1);
            }
            if (got_output)
            {
            //I think that  sending packet by rtmp  must be here!
            av_free_packet(&pkt);      
            }
    }
    
    ///////////////////////////
    //Deinitialize encoder
    ///////////////////////////
    avcodec_close(c);
    av_free(c);
    av_freep(&frame->data[0]);
    avcodec_free_frame(&frame);
    

    I need to send video stream generated by this code to RTMP server. In other words, I need c++/c analog for this command:

    ffmpeg -re -i "sample.h264" -f flv rtmp://sample.url.com/screen/test_stream
    

    It's useful, but I don't want to save stream to file, I want to use ffmpeg libraries for realtime encoding screen capture and sending encoded frames to RTMP server inside my own application. Please give me a little example how to initialize AVFormatContext properly and to send my encoded video AVPackets to server.

    Thanks.

  • Can't get ffmpeg to flip video 180 degrees from PHP exec call. Works from SSH

    25 octobre 2013, par Brandon Runyon

    When I run ./ffmpeg -i path/video.mp4 -vf "vflip,hflip" -metadata:s:v:0 rotate=0 newvideo.mp4 from the terminal it works well, but when I put this same system call into a PHP exec(); function it fails.

    example: $path = "videos/"; $video = "test_rotated.mp4"; //this script runs and works $rotation = exec('./mediainfo --Inform="Video;%Rotation%" '.$path.$video);

    if ((int)$rotation == 180) {
    $test = exec("./ffmpeg -i ".$path.$video." -vf \"vflip,hflip\" videos/test_rotatedback.mp4 2>&1");
    exec('./mediainfo --Inform="Video;%Rotation%" '.$path.'test_'.$video);
    echo "
    ".$test."
    "; }

    The result is that the var $test prints out "Video encoding failed" and I'm not sure why because it's pretty much the same exact syntax, it's just running from PHP but it fails.

  • Ruby on Rails : FFMPEG fails after upgrade Mountain Lion to Mavericks

    25 octobre 2013, par CristianOrellanaBak

    yesterday I upgrade my OS fom Mountain Lion to Mavericks and all goes well until recently.

    We are developing a Ruby on Rails v3.2.13 application for manage videos (only MP4), which worked fine until yesterday with Mountain Lion. Today (with Mavericks) I try to upload a video but get the following error in the console:

    Running transcoding...
    ffmpeg -y -i /Users/ME/Documents/workspace/rails/rails3-devise/public/uploads/tmp/1382653048-574-3293/thumb_con02_apv_revisado_1280x720.mp4 -ss 0 -s 180x110 -vframes 1 -f image2 -aspect 1.6363636363636365 /Users/Me/Documents/workspace/rails/rails3-devise/public/uploads/tmp/1382653048-574-3293/thumb_con02_apv_revisado_1280x720.png
    
    Transcoding of /Users/Me/Documents/workspace/rails/rails3-devise/public/uploads/tmp/1382653048-574-3293/thumb_con02_apv_revisado_1280x720.mp4 to /Users/Me/Documents/workspace/railspublic/uploads/tmp/1382653048-574-3293/thumb_con02_apv_revisado_1280x720.png succeeded
    
    Running transcoding...
    ffmpeg -y -i /Users/Me/Documents/workspace/rails/public/uploads/tmp/1382653048-574-3293/thumb_con02_apv_revisado_1280x720.mp4 -ss 0 -s 180x110 -vframes 1 -f image2 -aspect 1.6363636363636365 /Users/Me/Documents/workspace/rails/rails3-devise/public/uploads/tmp/1382653048-574-3293/thumb_con02_apv_revisado_1280x720.png
    
    Failed encoding...
    ffmpeg -y -i /Users/Me/Documents/workspace/rails/tmp/1382653048-574-3293/thumb_con02_apv_revisado_1280x720.mp4 -ss 0 -s 180x110 -vframes 1 -f image2 -aspect 1.6363636363636365 /Users/Me/Documents/workspace/rails/uploads/tmp/1382653048-574-3293/thumb_con02_apv_revisado_1280x720.png
    
    ffmpeg version 1.2.1 Copyright (c) 2000-2013 the FFmpeg developers
      built on Sep 28 2013 20:09:07 with Apple LLVM version 4.2 (clang-425.0.24) (based on LLVM 3.2svn)
      configuration: --prefix=/usr/local/Cellar/ffmpeg/1.2.1 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --enable-vda --cc=cc --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid --enable-libfreetype --enable-libtheora --enable-libvorbis --enable-libvpx --enable-librtmp --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-aacenc --enable-libass --enable-ffplay --enable-libspeex --enable-libschroedinger --enable-libfdk-aac --enable-libopus --enable-frei0r --enable-libopenjpeg --extra-cflags='-I/usr/local/Cellar/openjpeg/1.5.1/include/openjpeg-1.5 '
      libavutil      52. 18.100 / 52. 18.100
      libavcodec     54. 92.100 / 54. 92.100
      libavformat    54. 63.104 / 54. 63.104
      libavdevice    54.  3.103 / 54.  3.103
      libavfilter     3. 42.103 /  3. 42.103
      libswscale      2.  2.100 /  2.  2.100
      libswresample   0. 17.102 /  0. 17.102
      libpostproc    52.  2.100 / 52.  2.100
    [mp3 @ 0x7fd493820c00] Format mp3 detected only with low score of 1, misdetection possible!
    [mp3 @ 0x7fd49380a000] Header missing
        Last message repeated 1 times
    [mp3 @ 0x7fd493820c00] decoding for stream 0 failed
    [mp3 @ 0x7fd493820c00] Could not find codec parameters for stream 0 (Audio: mp2, 0 channels, s16p): unspecified frame size
    Consider increasing the value for the 'analyzeduration' and 'probesize' options
    [mp3 @ 0x7fd493820c00] Estimating duration from bitrate, this may be inaccurate
    /Users/Me/Documents/workspace/rails/tmp/1382653048-574-3293/thumb_con02_apv_revisado_1280x720.mp4: could not find codec parameters
    
    Errors: no output file created.
    

    I reinstall the dependencies of ffmpeg, but the problem persists.

    Any ideas or suggestions to solve the problem? Thank you very much!

    EDIT NOTE: I notice this when run brew upgrade :

    ==> Upgrading ffmpeg
    ==> Installing ffmpeg dependency: libass
    Error: libass dependency fontconfig was built with the following
    C++ standard library: libstdc++ (from clang)
    
    This is incompatible with the standard library being used
    to build libass: libc++ (from clang)
    
    Please reinstall fontconfig using a compatible compiler.
    hint: Check https://github.com/mxcl/homebrew/wiki/C++-Standard-Libraries