3

I am trying to merge audio and video file. The length of audio and video file are same but after complete merging process in output video file audio playing only for 3-4 second while audio and video file length was 14 seconds. Please help me why audio not playing completely in the output file.

String OutputPath = path + outputVideo;

        try {
            FrameGrabber grabber1 = new FFmpegFrameGrabber(videoFile);
            FrameGrabber grabber2 = new FFmpegFrameGrabber(audioFile);
            grabber1.start();

            grabber2.start();
            FrameRecorder recorder = new FFmpegFrameRecorder(OutputPath,
                    grabber1.getImageWidth(), grabber1.getImageHeight(),2);
            recorder.setFormat(grabber1.getFormat());
            recorder.setVideoQuality(1);
            recorder.setFrameRate(grabber1.getFrameRate());
            recorder.setSampleRate(grabber2.getSampleRate());
            recorder.start();
            Frame frame1, frame2;
            while ((frame1 = grabber1.grabFrame()) != null &&
                    (frame2 = grabber2.grabFrame()) != null) {
                recorder.record(frame1);
                recorder.record(frame2);
            }
            recorder.stop();
            grabber1.stop();
            grabber2.stop();

        } catch (FrameGrabber.Exception e) {
            e.printStackTrace();
        } catch (FrameRecorder.Exception e) {
            e.printStackTrace();
        }
akhilesh0707
  • 6,709
  • 5
  • 44
  • 51
Hitesh Gehlot
  • 1,307
  • 1
  • 15
  • 30
  • Check this if it helps https://github.com/bytedeco/javacv/issues/50 – AbhayBohra Aug 04 '17 at 08:21
  • Are you using some sort of wrapper for the ffmpeg cli tool? If yes then you should show the ffmpeg command being used and the complete console output/log from that command. – llogan Aug 04 '17 at 16:53

0 Answers0