Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • Fade out video/audio with FFMPEG

    6 mai 2017, par AleCaputo13

    i'm trying to simply fade out both video and audio of an input.mp4. The video lasts 00:29:59 (1799 sec) and i want to fade out the last sec. I'm using this command (it should just fadeout the video):

    ffmpeg -i input.mp4 -vf fade=t=out:st=1798:d=1 output.mp4

    but it always give me the same error:

    Too many packets buffered for output stream 0:1.
    [aac @ 0000000002605b60] Qavg: 2430.591
    [aac @ 0000000002605b60] 2 frames left in the queue on closing
    

    What am I doing wrong?

    EDIT: The file i was trying to edit was corrupted, with other files the filter works well :)

  • Convert compressed swf to mp4

    6 mai 2017, par skmvasu

    I'm looking for a batch script to convert swf to mp4, lossless. I tried using both ffmpeg and handbrake, but apparently swf is compressed and I can't convert them this way.

    ffmpeg -i input -c:v libx264 -preset ultrafast -qp 0 output.mkv
    
    HandBrakeCLI -i source -o destination
    

    I know I acn use a tool like xilisoft, but I've more than 3000 videos and would need to run this automatically. Is there a script/ algorithm that can help me automate this process?

  • ffmpeg convert vp9 video to mp4

    6 mai 2017, par Sulli

    I am using this command

    ffmpeg -i $youtubeUrl -strict -2 -c copy output.mp4
    

    (with $youtubeUrl generated by youtube-dl) to download this youtube video : https://www.youtube.com/watch?v=wnCJhq-JOck

    I can't play the downloaded video though on Ubuntu or Windows (for a problem of vp09 codec) and I have to convert the video to webm and then back to mp4 to be able to play it:

    ffmpeg -i output.mp4 -vcodec libvpx-vp9 -strict experimental output_2.webm
    ffmpeg -i output_2.webm -strict 2 output_3.mp4
    

    This happens only with some youtube videos, not all of them.

    Is there a way to download all youtube videos in a readable format with only one command line, without having to convert to webm?

  • Why are Cb and Cr planes displaced differently from lum by the displace complex filter in ffmpeg ?

    6 mai 2017, par Neb

    I have a video encoded with the yuv420p pixel format and I want to displace its pixels. I'm using ffmpeg and its new displace filter. The filter takes as inputs (the video to be displaced and) two displacement maps respectively for X and Y axis. I decided to create the displacement maps directly into ffmpeg using the nullsrc video source filter and the geq filter to specify the value of the three planes: lum, Cb, Cr. The script is the following:

    ffmpeg INPUT.mp4 -f lavfi -i nullsrc=size=${WIDTH}x${HEIGHT}:d=0.1,geq='lum=128+30*sin(2*PI*X/400):Cb=128+30*sin(2*PI*X/400):Cr='128+30*sin(2*PI*X/400)' -f lavfi -i nullsrc=size=${WIDTH}x${HEIGHT}:d=0.1,geq='lum=128+30*sin(2*PI*X/400):Cb=128+30*sin(2*PI*X/400):Cr=128+30*sin(2*PI*X/400)' -lavfi '[0][1][2]displace' OUTPUT.mp4
    

    I used the example provided in the documentation of ffmpeg, since the expression used in geq is irrelevant for the purposes of the problem.

    At the and of the computation, I get the pixels of the input video not properly displaced, meaning that I can clearly see a sort of ghost carrying-color-information video under a displaced but b/w one. After some tests, I noticed that the displacemnt map created had only the luma plane displaced correctly while the chrominance planes were displaced, but differently from luma, which is the origin of the planes disalignment in the intput video as you can see in the following extract frames:

    Planes separated

    I also noticed that the video describing the Cb and Cr planes of the displacement maps have half resolution of the luma plane.

    My question is: how can i setup correctly the Cr and Cb planes in the geq definition so that they are exactly identical to the luma plane?

    It would be also great if someone could explain me why ffmpeg gives me an output so much different for luma and Cb, Cr planes even if the function provided is the same.

    If, it can help, i'm using ffmpeg 3.3-static build.

    Thanks for your time.

  • Can't merge mp4 files with FFmpeg on android

    6 mai 2017, par Brian

    I'm using https://github.com/hiteshsondhi88/ffmpeg-android-java in an app that needs to combine multiple mp4 files into one.

    Here is a command

    ffmpeg -i concat:"/data/data/com.testapp.app/cache:temp/lds82df9skov65i15k3ct16cik.mp4|/data/data/com.testapp.app/cache:temp/qm5s0utmb8c1gbhch6us2tnilo.mp4" -codec copy /data/data/com.testapp.app/cache:temp/4egqalludvs03tnfleu5dgb6iv.mp4
    

    java method to append files, movie files is an array holding files i want to combine

    public void appendFiles() {
    
        showProgressDialog();
    
        movieFile = getRandomFile();
    
        StringBuilder b = new StringBuilder();
    
        try {
    
            for (int i = 0; i < movieFiles.size(); i++) {
    
                File f = movieFiles.get(i);
    
                if (!f.exists()) {
                    continue;
                }
    
                if(i != 0){
                    b.append("|");
                }
    
                b.append(f.getPath());
    
    
            }
    
            final String command = "-i concat:\""+b.toString() + "\" -codec copy " + movieFile.getPath();
    
    
    
            try {
                ffmpeg.execute(command, new ExecuteBinaryResponseHandler() {
                    @Override
                    public void onFailure(String s) {
                        app.log("FAILED with output : " + s);
                    }
    
                    @Override
                    public void onSuccess(String s) {
                        app.log("SUCCESS with output : " + s);
    
                        createThumbnail();
    
                        stopProgressDialog();
    
                        startReview();
                    }
    
                    @Override
                    public void onProgress(String s) {
                        app.log("Started command : ffmpeg " + command);
    
                    }
    
                    @Override
                    public void onStart() {
    
                        app.log("Started command : ffmpeg " + command);
    
                    }
    
                    @Override
                    public void onFinish() {
                        app.log("Finished command : ffmpeg " + command);
    
                    }
                });
            }
            catch (FFmpegCommandAlreadyRunningException e) {
                e.printStackTrace();
            }
    
    
        }
    
        catch (Exception e) {
            e.printStackTrace();
        }
    
    }
    

    and getRandomFile()

        public File getRandomFile() {
            if (captureDir != null) {
                if (captureDir.exists()) {
    
                    SecureRandom random = new SecureRandom();
                    File file = new File(captureDir, new BigInteger(130, random).toString(32) + ".mp4");
                    return file;
                }
            }
            return null;
        }
    

    but I keep seeing the error no such file or directory

    concat:"/data/data/com.testapp.app/cache:temp/lds82df9skov65i15k3ct16cik.mp4|/data/data/com.testapp.app/cache:temp/qm5s0utmb8c1gbhch6us2tnilo.mp4": No such file or directory

    any ideas?