bytedeco / javacv

Java interface to OpenCV, FFmpeg, and more
Other
7.6k stars 1.59k forks source link

No such filter: 'subtitles' #1905

Open GetAHut opened 2 years ago

GetAHut commented 2 years ago

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

    }
saudet commented 2 years ago

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

GetAHut commented 2 years ago

thanks , i try.

keepgoingxjw commented 1 year ago

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

E-Artist commented 1 year ago

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 commented 1 year ago

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

wysstartgo commented 2 months ago

I encountered the same problem. The output is as follows Error: [AVFilterGraph @ 0x7fdb08f1f3c0] No such filter: 'subtitles'

Error: [AVFilterGraph @ 0x7fdb08f1f3c0] Error processing filtergraph: Filter not found

Info: [aac @ 0x7fdb3a08dbc0] Qavg: nan

Exception in thread "main" org.bytedeco.javacv.FFmpegFrameFilter$Exception: avfilter_graph_parse_ptr() error -1279870712 (For more details, make sure FFmpegLogCallback.set() has been called.) at org.bytedeco.javacv.FFmpegFrameFilter.startVideoUnsafe(FFmpegFrameFilter.java:408) at org.bytedeco.javacv.FFmpegFrameFilter.startUnsafe(FFmpegFrameFilter.java:308) at org.bytedeco.javacv.FFmpegFrameFilter.start(FFmpegFrameFilter.java:283)

wysstartgo commented 2 months ago

@saudet Is there any solutions?