Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • FFMPEG reports different (wrong) video resolution compared to how it actually plays

    30 mars 2015, par Emiliano

    Quick question, i have a movie, which was cut and rendered with Sony Vegas from its original format to a .wmv file. Here comes the tricky part, movie when played, either with VLC or WMP, has a resolution of 656x480 ... BUT when i run a ffmpeg -i on it, it says it has a resolution of 600x480 ....

    I took the time of actually capturing a frame and croping it with photoshop and its 656 and not 600 like ffmpeg its reporting, why would this could be happening? How could i fix the headers resolution? Would that have any impact on video re-rendering? As i said, VLC and WMP seems not to care about the incorrect headers and are playing it right, BUT, jwplayer seems to be using the header information, which i don't blame him, its correct to do that, but why the video headers could be wrong?

    ffmpeg -i trailer.wmv
    
    Input #0, asf, from 'trailer.wmv':
    Duration: 00:01:04.93, start: 3.000000, bitrate: 2144 kb/s
    Stream #0.0: Audio: wmav2, 44100 Hz, mono, 32 kb/s
    Stream #0.1: Video: wmv3, yuv420p, 600x480 [PAR 59:54 DAR 295:216], 2065 kb/
    s, 25.00 tb(r)

    And yeah, the PAR/DAR parameters are also wrong, but honestly, i don't understand that technical shit, usually watch video and make sure it look good, any feedback would be appreciated :P

    Is there a way to change the container information with ffmpeg so applications that actually do use the container information don't render video incorrectly?

  • FFMPEG GOP Extraction

    29 mars 2015, par user3601375

    I have an MPEG -4 video and I would like to extract a one GOP (Group of pictures ) at a time to BMPs (using FFMPEG and c++ (code block) ) rather than the whole video in one go, since now all my code writing is stuck there I use to sketch everything in my mind then program and I can't imagine how to do this, I searched the net for something like that but of no use.. any command line or any library used to do that (I have no full experience on FFMPEG I have read the documentation but that thing was not there). I will appreciate any kind help and thanks for reading y post.

    Regards,

  • Php FFMPEG request timout

    28 mars 2015, par Dev

    I am using Laravel 4.2.

    I am working on a project of uploading video. The uploaded video should be played in most devices that I am using php-ffmpeg package from the git-hub.

    The requirement is the transcoding should be done in background. I am using WAMP 2.5.

    What am I doing is, after upload I am firing an asynchronous ajax request that transcode the video and after successful completion it should insert a record into database containing video name, path etc.

    The problem is if I upload a large size video, then I am facing error Maximum execution time of 120 seconds exceeded.

    I know the possible solution is setting max_timelimit in php.ini but I don't think it is a feasible solution because if there will be larger video, the same error will occurred again.

    Is there any technique that I can bypass this transcoding process in background?

    My code is as below :

    try{
                $video_id = Input::get('video_id');
                $video_path = Input::get('video_path');
    
                $path = '/video/'.date('Y').'/'.date('m');
                $path .= '/';
                $explode_filename  = explode("/",$video_path);
                $save_filename = $explode_filename[sizeof($explode_filename)-1];
    
                $ffmpeg = FFMpeg\FFMpeg::create(array('timeout'=>0));
                $video = $ffmpeg->open($video_path);
    
                $format = new CustomVideo();
                $format->setKiloBitrate(1000)
                        ->setAudioChannels(2)
                        ->setAudioKiloBitrate(256);
    
                $video->save($format, public_path().$path.$save_filename); 
                //saving video
    
                Video::where('id', '=', $video_id)->update(array('is_transcoded' => 1,'video_url'=>url($path.$save_filename)));
            }
            catch (Exception $ex){
               return Response::json (["Message"=>$ex->getMessage(), "code"=>$ex->getCode(), "trace"=>$ex->getTrace()]);
            }
    
  • Is there an efficient way to retrieve frames from a video in Android ?

    28 mars 2015, par Naveed

    I have an app which requires me to retrieve frames from a video and do some processing with them. However it seems like that the frame retrieval is very slow to the point where it is unacceptable. Sometimes it is taking upto 2.5 second to retrieve a single frame. I am using the MediaMetadataRetriever as most stackoverflow questions suggested. However the performance is very bad. Here is what I have:

       private List retrieveFrames() {
    
            MediaMetadataRetriever fmmr = new MediaMetadataRetriever();
            fmmr.setDataSource("/path/to/some/video.mp4");
            String strLength = fmmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);
            long milliSecs = Long.parseLong(strLength);
            long microSecLength = milliSecs * 1000;
    
            Log.d("TAG", "length: " + microSecLength);
            long one_sec = 1000000; // one sec in micro seconds
    
            ArrayList frames = new ArrayList<>();
            int j = 0;
            for (int i = 0; i < microSecLength; i += (one_sec / 5)) {
                long time = System.currentTimeMillis();
                Bitmap frame = fmmr.getFrameAtTime(i, MediaMetadataRetriever.OPTION_CLOSEST);
                j++;
                Log.d("TAG", "Frame number: " + j + " Time taken: " + (System.currentTimeMillis() - time));
                // commented out because each frame would be written to disk instead of holding them in memory
                //  frames.add(frame);
            }
            fmmr.release();
            return frames;
        }
    

    The above will logs:

    03-26 21:49:29.781  13213-13239/com.example.naveed.myapplication D/TAG﹕ length: 4949000
    03-26 21:49:30.187  13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 1 Time taken: 406
    03-26 21:49:30.779  13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 2 Time taken: 592
    03-26 21:49:31.578  13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 3 Time taken: 799
    03-26 21:49:32.632  13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 4 Time taken: 1054
    03-26 21:49:33.895  13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 5 Time taken: 1262
    03-26 21:49:35.382  13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 6 Time taken: 1486
    03-26 21:49:37.128  13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 7 Time taken: 1746
    03-26 21:49:39.077  13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 8 Time taken: 1948
    03-26 21:49:41.287  13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 9 Time taken: 2210
    03-26 21:49:43.717  13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 10 Time taken: 2429
    03-26 21:49:44.093  13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 11 Time taken: 376
    03-26 21:49:44.707  13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 12 Time taken: 614
    03-26 21:49:45.539  13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 13 Time taken: 831
    03-26 21:49:46.597  13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 14 Time taken: 1057
    03-26 21:49:47.875  13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 15 Time taken: 1278
    03-26 21:49:49.384  13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 16 Time taken: 1508
    03-26 21:49:51.112  13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 17 Time taken: 1728
    03-26 21:49:53.096  13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 18 Time taken: 1983
    03-26 21:49:55.315  13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 19 Time taken: 2218
    03-26 21:49:57.711  13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 20 Time taken: 2396
    03-26 21:49:58.065  13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 21 Time taken: 354
    03-26 21:49:58.640  13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 22 Time taken: 574
    03-26 21:49:59.369  13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 23 Time taken: 728
    03-26 21:50:00.112  13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 24 Time taken: 742
    03-26 21:50:00.834  13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 25 Time taken: 721
    

    As you can see from above, it is taking about 18 - 25 sec to retrieve 25 frames from a 4 sec long video.

    I have also tried this which uses FFmpeg underneath to do the same. I am not sure how well this library is implemented but it only improves the over all performance by a couple of seconds meaning it takes about 15-20 sec to do the same.

    So my question is: is there a way to do it quicker? My friend has an iOS app where he does something similar but it only takes couple of seconds and he is grabbing even more frames however he is not sure how to do it on android.

    Is there anything on android that would speed up the process. Am I approaching this wrong?

    The end goal is to stitch those frames together into a gif.

  • Add watermark text on mkv video using ffmpeg windows version [on hold]

    27 mars 2015, par sajjad hosseini

    I want to add a watermark text to a mkv video using ffmpeg windows version . I want the watermark to be like a subtitle that starts on minute 2 and lasts for 30 seconds and says : copyright to mysite.com . I tried mkvmerge to add a subtitle but it can be easily deleted by others , so now i'm relying on ffmpeg to do this for me . Can anyone help me with the process ? I want the watermark to be actually on the video and can't be deleted using mkvmerge .