javacv icon indicating copy to clipboard operation
javacv copied to clipboard

No such filter: 'subtitles'

Open GetAHut opened this issue 1 year ago • 5 comments

hello excuse me now, I need to merge the subtitle srt file with the video, using the 'subtitles' filter, but I am prompted with this error - No such filter: 'subtitles'; javacv version is 1.5.7; I wonder if the '--enable-libass' configuration is not on? how i do it? this my code:

public static void merge() {
        String subtitlesPath = "D:\\origin-translation-1234.srt";
        String vFilter = String.format("subtitles='%s'", subtitlesPath);
        String output = "D:\\output123.mp4";

        FFmpegFrameGrabber grabber = new FFmpegFrameGrabber("D:\\11111.mp4");
        FFmpegFrameFilter filter = null;
        FFmpegFrameRecorder recorder = null;
        Frame frame = null;
        try {
            grabber.start();

            filter = new FFmpegFrameFilter(vFilter, grabber.getImageWidth(), grabber.getImageHeight());
            filter.setAudioChannels(grabber.getAudioChannels());
            filter.start();

            recorder = new FFmpegFrameRecorder(output, grabber.getAudioChannels());
            recorder.setFormat("mp4");
            recorder.setAudioCodec(grabber.getAudioCodec());
            recorder.setTimestamp(grabber.getTimestamp());
            recorder.start();

            int index = 0;
            while ((frame = grabber.grab()) != null){
                if (frame.samples != null){
                    recorder.record(frame);
                }
                System.out.println("zhen : " + index);
                index++;
            }

            recorder.stop();
            recorder.release();
            filter.stop();
            grabber.stop();

        } catch (FFmpegFrameGrabber.Exception e) {
            throw new RuntimeException(e);
        } catch (FFmpegFrameFilter.Exception e) {
            throw new RuntimeException(e);
        } catch (FFmpegFrameRecorder.Exception e) {
            throw new RuntimeException(e);
        }

    }

GetAHut avatar Oct 11 '22 02:10 GetAHut

For that, we need to update the cppbuild.sh build script here: https://github.com/bytedeco/javacpp-presets/blob/master/ffmpeg/cppbuild.sh Build instructions for this are here: https://github.com/bytedeco/javacpp-presets#build-instructions And when you're done, please open a pull request here: https://github.com/bytedeco/javacpp-presets/pulls Let me know if you encounter any problems with any of this, I'll be here to help! Thanks

saudet avatar Oct 11 '22 03:10 saudet

thanks , i try.

GetAHut avatar Oct 11 '22 07:10 GetAHut

@GetAHut 这个问题你解决了吗?

keepgoingxjw avatar Jun 08 '23 08:06 keepgoingxjw

I encountered the same problem. The output is as follows

[AVFilterGraph @ 000002f4530e3ac0] No such filter: 'subtitles' Error reinitializing filters! Failed to inject frame into filter network: Invalid argument Error while processing the decoded data for stream #0:0

my cmd like this xxx...\org\bytedeco\ffmpeg\windows-x86_64-gpl\ffmpeg.exe -i input.mp4 -vf subtitles=start.ass -preset slow -crf 18 -y output.mp4

configuration lack --enable-libass,but i can't solve it

E-Artist avatar Jun 15 '23 08:06 E-Artist

It seems like i need update cppbuild.sh and build javacpp-presets.This seems to be difficult for me, are there any other solutions? thanks. @saudet @GetAHut

E-Artist avatar Jun 15 '23 11:06 E-Artist