bytedeco/javacv

No such filter: 'subtitles'

Open

#1,905 opened on Oct 11, 2022

View on GitHub
 (7 comments) (0 reactions) (0 assignees)Java (1,583 forks)batch import
enhancementhelp wanted

Repository metrics

Stars
 (6,985 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

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);
        }

    }

Contributor guide