bytedeco / javacv

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

video issue when generating mpeg-dash stream #2147

Open ashraf-revo opened 11 months ago

ashraf-revo commented 11 months ago

iam trying to generating mpeg-dash stream using ffmpeg and javacv the issue with javacv its not spliting the video like the audio so it just generating one segment for the video contain all information and multiple segment for the audio like usual

see this image Screenshot from 2023-12-14 11-20-16

for ffmpeg iam using (working fine)

ffmpeg -i input.mp4  -use_timeline 1 -use_template 1  -adaptation_sets "id=0,streams=v id=1,streams=a" -seg_duration 10 -f dash input.mpd

for javacv iam using (havving issue)

        FFmpegFrameGrabber grabber = new FFmpegFrameGrabber("input.mp4");
        grabber.start();
        FFmpegFrameRecorder recorder = new FFmpegFrameRecorder("input.mpd", grabber.getImageWidth(), grabber.getImageHeight(), grabber.getAudioChannels());
        recorder.setOption("use_timeline", "1");
        recorder.setOption("use_template", "1");
        recorder.setOption("adaptation_sets", "id=0,streams=v id=1,streams=a");
        recorder.setOption("seg_duration", "10");
        recorder.setFormat("dash");
        recorder.start();
        Frame frame;
        while ((frame = grabber.grab()) != null) {
            recorder.record(frame);
        }
        grabber.stop();
        grabber.close();
        recorder.flush();
        recorder.close();
saudet commented 11 months ago

We can easily accomplish this with the ffmpeg program: http://bytedeco.org/javacpp-presets/ffmpeg/apidocs/org/bytedeco/ffmpeg/ffmpeg.html

ashraf-revo commented 11 months ago

@saudet thanks for you fast replay actually this code is part of streaming server to generate (hls,dash), i just build it to show the error that can not accept direct file , it only use FFmpegFrameGrabber with java InputStream

saudet commented 11 months ago

It doesn't sound like something that's currently supported, but contributions are welcome!

ashraf-revo commented 11 months ago

@saudet actually i don't have deep understand of the javacv but i can do if you highlighted some class that might contain the bug or the missing feature i can do