Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • Android ffmpeg video cut

    20 octobre 2016, par Raupp

    I´m trying to edit some videos in my Android app using FFmpeg, but I´m facing some problems when I tried to take just a part of the video.

    I´m using this ffmpeg compilation/lib https://github.com/WritingMinds/ffmpeg-android-java

    I tried to use this command to trim/cut the video

    "-y -i input.mp4 -ss 00:00:01.00 -t 00:00:15.000 -c copy output.mp4"
    

    But with some videos I´m getting a black screen or the video just freezes. The sound works fine in all my tests.

    With this command

    "-y -i input.mp4 -ss 00:00:01.000 -t 00:00:15.000 -async 1 output.mp4"
    

    Everything works fine in all my tests (video/sound) but takes too much time to generate the output file, this 15s file takes more than 2 minutes to be generated.

    I tried other variations of these commands, but I always get problems with the video stream (with black screen or freezing) or takes too much time to generate the output (the user can only select 15s of the videos to send to my server)

    Thanks by the help!

    EDIT:

    this is the part of the code that is trimming the video

    String[] cmd = new String[]{"-y","-i",input,"-ss","00:00:05.000","-vcodec","copy",
                "-acodec","copy","-t","00:00:15.00","-strict","-2",output };
    
        final FFmpeg ffmpeg = FFmpeg.getInstance(this);
        try {
            ffmpeg.execute(cmd, new FFmpegExecuteResponseHandler() {
                @Override
                public void onSuccess(String message) {
                    Log.i("VideoEditActivity", "Success " + message);
                    is_video_generated_ = true;
                }
    
                @Override
                public void onProgress(String message) {
                    Log.i("VideoEditActivity", "Progress updated " + message);
                }
    
                @Override
                public void onFailure(String message) {
                    Log.e("VideoEditActivity", "ERROR! " + message);
                }
    
                @Override
                public void onStart() {
                    progress_dialog_.setMessage(getString(R.string.str_video_generating));
                    progress_dialog_.show();
                }
    
                @Override
                public void onFinish() {
                    Log.i("VideoEditActivity", "Finished");
                    progress_dialog_.hide();
    
                    Intent intent = new Intent(getApplicationContext(), VideoPlayActivity.class);
                    intent.putExtra("media", edited_video_path_);
                    startActivity(intent);
                }
            });
        } catch (FFmpegCommandAlreadyRunningException e) {
            e.printStackTrace();
        }
    

    This is the original file: [https://drive.google.com/file/d/0BzqJL_nNetbRYmxvcTljanJwR00/view?usp=sharing][1]

    And this the output: 0BzqJL_nNetbReENjRGMtVXQ5VHM/view?usp=sharing (stack overflow does not allow me to add more than 2 links)

  • UPnP Video Streaming with Node.js and FFMPEG - How can I relay the live stream from FFMPEG to Device ?

    20 octobre 2016, par Hadi77
    1. I tried relaying the stream from FFMPEG to a WebSocket connection but how can this happen in HTTP?
    2. As it is not a full-duplex connection, I have to use a buffer somehow. So how can I use a buffer for getting stream to the TV (my UPnP Target device)?

    I'm encoding the stream to H.264, and it is a Live Stream.

  • FFMPEG - Store FFPROBE's duration output as a variable

    19 octobre 2016, par Neo Herakles

    I wanted to use a video's duration in the "enable='between(t,0,0)" field to make sure that I overlay an image at 1/3 of the video's duration every time.

    According to FFMPEG's info on their site, I need to use this

    ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 input.mp4
    

    it does return a value but I can't seem to be able to set it to a usable variable, I already tried by using

    set duration=ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 input.mp4
    

    And then referencing it via %duration%, but no luck.

    Is there a way to do this, am I doing something wrong?

    Thank you for your help.

  • FFmpeg CRF control using x264 vs libvpx-vp9

    19 octobre 2016, par igon

    I have some experience using ffmpeg with x264 and I wanted to do a comparison with libvpx-vp9. I tested a simple single pass encoding of a raw video, varying the crf settings and presets both with x264 and libvpx-vp9. I am new to libvpx and I followed this and this carefully but I might have still specified wrong combination of parameters since the results I get do not make much sense to me.

    For x264 I did:

    ffmpeg -i test_video.y4m -c:v libx264 -threads 1 -crf  -preset  -y output.mkv 
    

    and obtained the following results:

    codec  , settings                        , time        , PSNR      ,bitrate
    libx264,['-crf', '20', '-preset', 'fast'],13.1897280216, 42.938337 ,15728
    libx264,['-crf', '20', '-preset', 'medium'],16.80494689, 42.879753 ,15287
    libx264,['-crf', '20', '-preset', 'slow'],25.1142120361, 42.919206 ,15400
    libx264,['-crf', '30', '-preset', 'fast'],8.79047083855, 37.975141 ,4106
    libx264,['-crf', '30', '-preset', 'medium'],9.936599016, 37.713778 ,3749
    libx264,['-crf', '30', '-preset', 'slow'],13.0959510803, 37.569511 ,3555
    

    This makes sense to me, given a crf value you get a value of PSNR and changing the preset can decrease the bitrate but increase the time to encode.

    For libvpx-vp9 I did:

    ffmpeg -i test_video.y4m -c:v libvpx-vp9 -threads 1 -crf  -cpu-used  -y output.mkv 
    

    First of all I thought from tutorials online that the -cpu-used option is equivalent to -preset in x264. Is that correct? If so what is the difference with -quality? Furthermore since the range goes from -8 to 8 I assumed that negative values where the fast options while positive values the slowest. Results I get are very confusing though:

    codec     , settings                      , time        , PSNR     ,bitrate
    libvpx-vp9,['-crf', '20', '-cpu-used', '-2'],19.6644911766,32.54317,571
    libvpx-vp9,['-crf', '20', '-cpu-used', '0'],176.670887947,32.69899,564
    libvpx-vp9,['-crf', '20', '-cpu-used', '2'],20.0206270218,32.54317,571
    libvpx-vp9,['-crf', '30', '-cpu-used', '-2'],19.7931578159,32.54317,571
    libvpx-vp9,['-crf', '30', '-cpu-used', '0'],176.587754965,32.69899,564
    libvpx-vp9,['-crf', '30', '-cpu-used', '2'],19.8394429684,32.54317,571
    

    Bitrate is very low and PSNR seems unaffected by the crf setting (and very low compared to x264). The -cpu-used setting has very minimal impact and also seems that -2 and 2 are the same option.. What am I missing? I expected libvpx to take more time to encode (which is definitely true) but at the same time higher quality transcodes. What parameters should I use to have a fair comparison with x264?

    Edit: Thanks to @mulvya and this doc I figured that to work in crf mode with libvpx I have to add -b:v 0. I re-ran my tests and I get:

        codec     , settings                                 , time        , PSNR     ,bitrate
    libvpx-vp9,['-crf', '20', '-b:v', '0', '-cpu-used', '-2'],57.6835780144,45.111158,17908
    libvpx-vp9,['-crf', '20', '-b:v', '0', '-cpu-used', '0'] ,401.360313892,45.285367,17431
    libvpx-vp9,['-crf', '20', '-b:v', '0', '-cpu-used', '2'] ,57.4941239357,45.111158,17908
    libvpx-vp9,['-crf', '30', '-b:v', '0', '-cpu-used', '-2'],49.175855875,42.588178,11085
    libvpx-vp9,['-crf', '30', '-b:v', '0', '-cpu-used', '0'] ,347.158324957,42.782194,10935
    libvpx-vp9,['-crf', '30', '-b:v', '0', '-cpu-used', '2'] ,49.1892938614,42.588178,11085
    

    PSNR and bitrate went up significantly by adding -b:v 0

  • Quantization property in CUVID

    19 octobre 2016, par mkreddy

    Please correct me if my understanding was wrong regarding qscale in ffmpeg.

    In ffmpeg H264 decoder has qscale_table which hold the values of qp for each macro block.

    Is there any such table/matrix in CUVID to know the qscale values? If not, please suggest me how can I construct one such matrix for each macro block.

    Thanks in advance.