javacv icon indicating copy to clipboard operation
javacv copied to clipboard

video issue when generating mpeg-dash stream

Open ashraf-revo opened this issue 8 months ago • 4 comments

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

ashraf-revo avatar Dec 14 '23 09:12 ashraf-revo

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

saudet avatar Dec 14 '23 09:12 saudet

@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

ashraf-revo avatar Dec 14 '23 09:12 ashraf-revo

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

saudet avatar Dec 14 '23 10:12 saudet

@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

ashraf-revo avatar Dec 14 '23 13:12 ashraf-revo