royise
royise

Reputation: 41

ffmpeg No such filter: 'palettegen' in linux

1.

my system 
uname -a
Linux localhost.localdomain 2.6.32-220.el6.x86_64 #1 SMP Tue Dec 6 19:48:22 GMT 2011 x86_64 x86_64 x86_64 GNU/Linux

2.ffmpeg is download from http://johnvansickle.com/ffmpeg/

3.I had download the ffmpeg-release-64bit-static.tar.xz ,unpackage this file, and run : ./ffmpeg then ffmpeg has installed. I check it by using : ffmpeg -version
no problems.

I run those command in my system is no problem:

cd /home/web/tomcat-6.0.29/zhouletest/ffmpeg-3.1.1-64bit-static 

./ffmpeg -y -ss 10 -t 3 -i /home/web/tomcat-6.0.29/zhouletest/videos/6.mp4 -vf fps=10,scale=177:-1:flags=lanczos,palettegen /home/web/tomcat-6.0.29/zhouletest/gif_images/palettegens/6.png 

./ffmpeg -y -ss 10 -t 3 -i /home/web/tomcat-6.0.29/zhouletest/videos/6.mp4 -i /home/web/tomcat-6.0.29/zhouletest/gif_images/palettegens/6.png -filter_complex "fps=10,scale=177:-1:flags=lanczos[x];[x][1:v]paletteuse" /home/web/tomcat-6.0.29/zhouletest/gif_images/6.gif

but when I invoke this command in java, errors happend, why?

String cmd1 = "/home/web/tomcat-6.0.29/zhouletest/ffmpeg -y -ss 10 -t 3 -i /home/web/tomcat-6.0.29/zhouletest/videos/6.mp4 -vf fps=10,scale=177:-1:flags=lanczos,palettegen /home/web/tomcat-6.0.29/zhouletest/gif_images/palettegens/6.png";
String cmd2 = "/home/web/tomcat-6.0.29/zhouletest/ffmpeg-3.1.1-64bit-static/ffmpeg -y -ss 10 -t 3 -i /home/web/tomcat-6.0.29/zhouletest/videos/6.mp4 -i /home/web/tomcat-6.0.29/zhouletest/gif_images/palettegens/6.png -filter_complex \"fps=10,scale=177:-1:flags=lanczos[x];[x][1:v]paletteuse\" /home/web/tomcat-6.0.29/zhouletest/gif_images/6.gif";

String result1 = executeCommand(cmd1);
String result2 = executeCommand(cmd2);

private static String executeCommand(String command) {
    StringBuffer output = new StringBuffer();
    Process p;
    try {
        p = Runtime.getRuntime().exec(command);
        p.waitFor();
        BufferedReader reader = new BufferedReader(new InputStreamReader(p.getErrorStream()));

        String line = "";
        while ((line = reader.readLine())!= null) {
            output.append(line + "\n");
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
    return output.toString();
}

errors:

result1:
result2:ffmpeg version 3.1.1-static http://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.4.0 (Debian 5.4.0-4) 20160609
configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --enable-libmp3lame --enable-libx264 --enable-libx265 --enable-libwebp --enable-libspeex --enable-libvorbis --enable-libvpx --enable-libfreetype --enable-fontconfig --enable-libxvid --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvo-amrwbenc --enable-gray --enable-libopenjpeg --enable-libopus --enable-libass --enable-gnutls --enable-libvidstab --enable-libsoxr --enable-frei0r --enable-libfribidi --disable-indev=sndio --disable-outdev=sndio --enable-librtmp --enable-libmfx --enable-libzimg --cc=gcc
libavutil 55. 28.100 / 55. 28.100
libavcodec 57. 48.101 / 57. 48.101
libavformat 57. 41.100 / 57. 41.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter
6. 47.100 / 6. 47.100
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 1.100 / 2. 1.100
libpostproc
54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/web/tomcat-6.0.29/zhouletest/videos/6.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.40.101
Duration: 00:04:36.64, start: -3.338000, bitrate: 1089 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 480x360, 997 kb/s, 15 fps, 15 tbr, 16k tbn, 30 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (Main) (mp4a / 0x6134706D), 22050 Hz, stereo, fltp, 88 kb/s (default)
Metadata:
handler_name : SoundHandler
Input #1, png_pipe, from '/home/web/tomcat-6.0.29/zhouletest/gif_images/palettegens/6.png':
Duration: N/A, bitrate: N/A
Stream #1:0: Video: png, rgba(pc), 16x16 [SAR 1:1 DAR 1:1], 25 tbr, 25 tbn, 25 tbc
[AVFilterGraph @ 0x45c5260] No such filter: '"fps'
Error initializing complex filters.
Invalid argument

Upvotes: 4

Views: 4588

Answers (4)

dcsan
dcsan

Reputation: 12315

I got this cos of copying a cmd had put curly quotes into the command somehow. evil!

Upvotes: 1

Dhiraj Gupta
Dhiraj Gupta

Reputation: 10504

This can sometimes happen when you're using a separate language or system to generate your ffmpeg command line call, and if you have a recent-ish ffmpeg (that's greater than 3.0) then palettegen should be compiled into it, by default.

In my case, after a whole day of experimenting with the command line, it turned out that I needed to escape the , in my CLI call that I was generating, with a \ before it. Due to this, ffmpeg was unable to read the arguments properly, and ended up thinking that I was asking to use 'fps' as a filter, or similar.

Upvotes: 0

royise
royise

Reputation: 41

In the end, I wrote a shell: gifcreate.sh, I use java to call it, it's works well.

this is myshell

#/bin/bash

_srcFile=$1     #video file path
_descFile=$2    #output GIF file
_width=$3       #widht of output GIF file
_start=$4       #skip the first $_start seconds of the $_srcFile
_time=$5        #create a $_time second output
_cover=$6       #overwrite the palette and gif if exist, y is yes,n is not
_fps=$7         #Frame rate,can control GIF definition,
_palettegenFile=$8  #palette file path

cd /home/web/tomcat-6.0.29/zhouletest/ffmpeg-3.1.1-64bit-static
./ffmpeg -$6 -t $_time -i $_srcFile -vf fps=$_fps,scale=$_width:-1:flags=lanczos,palettegen $_palettegenFile
./ffmpeg -$6 -t $_time -i $_srcFile -i $_palettegenFile -filter_complex "fps=$_fps,scale=$_width:-1:flags=lanczos[x];[x][1:v]paletteuse" $_descFile

this is my calling method in shell

/home/web/tomcat-6.0.29/zhouletest/gifcreate.sh /home/web/tomcat-6.0.29/zhouletest/videos/6.mp4 /home/web/tomcat-6.0.29/zhouletest/gif_images/1469694815605_8898.gif 177 0 3 y 5 /home/web/tomcat-6.0.29/zhouletest/gif_images/palettegens/1469694815605_8898.png

this is my calling method in java

String cmd1 = "/home/web/tomcat-6.0.29/zhouletest/gifcreate.sh "+srcFile+" "+descFile+" "+width+" "+start+" "+time+" "+(cover?"y":"n")+" "+fps+" "+palettegenFile;

Runtime r1 = Runtime.getRuntime();
    final Process process1 = r1.exec(cmd1);
    Thread thread1 = new Thread(new Runnable() {
        public void run() {
            try {
                process1.waitFor();
            } catch (Exception e) {
                log.error("createScaleGifFromVideo thread error:", e);
            }
        }
    });
    thread1.start();
    thread1.join(5000);//wait for the child thread up to 5 second
    if(thread1.isAlive()){
        process1.destroy();
        log.error("createScaleGifFromVideo: gif create is not ended, because it's cost more then 5s.");
    }

Reference

https://superuser.com/questions/556029/how-do-i-convert-a-video-to-gif-using-ffmpeg-with-reasonable-quality?answertab=votes#tab-top

Upvotes: 0

Gyan
Gyan

Reputation: 93329

Nothing to do with your FFmpeg binary, this is almost certainly related to escaping characters in the shell environment that the commands run in.

Examine the error message:

No such filter: '"fps' 

FFmpeg thinks the filter being called is "fps.

Try removing the quotes around filter_complex i.e.

-filter_complex fps=10,scale=177:-1:flags=lanczos[x];[x][1:v]paletteuse

Or if that doesn't work, enclose it in single quotes.

-filter_complex 'fps=10,scale=177:-1:flags=lanczos[x];[x][1:v]paletteuse'

Upvotes: 3

Related Questions