bytedeco / javacv

Java interface to OpenCV, FFmpeg, and more
Other
7.57k stars 1.58k forks source link

FFmpegFrameRecorder-recordSamples-NullPointerException for transcodeVideo MP4 to mov #1755

Open JinLike opened 2 years ago

JinLike commented 2 years ago
private static final String filename2 = "H:\\inout.mp4";
   private static final String filename3 = "H:\\output.mov"; 
 public static void main(String[] args) {
FFmpegFrameGrabber grabber = new FFmpegFrameGrabber(filename2);
        grabber.start();
        FFmpegFrameRecorder recorder = new FFmpegFrameRecorder(filename3, 1920,
               1080, grabber.getAudioChannels());
           recorder.setVideoCodecName("mpeg2");
        recorder.setAudioCodecName("aac");
        recorder.setFormat(format);
        recorder.setAudioChannels(2);
          recorder.start(grabber.getFormatContext());
         Frame captured_frame = null;
        ////////
       while ((captured_frame = grabber.grab())!=null) {
           recorder.setTimestamp(grabber.getTimestamp());
           recorder.record(captured_frame);
    }
        recorder.stop();
        recorder.release();
       // avcodec.AV_CODEC_ID_H264
        grabber.stop();
        grabber.release();
        recorder.close();
        grabber.close();
}

FFmpegFrameGrabber 1124 line:int outputChannels = samples_out.length > 1 ? 1 : audio_c.channels(); samples_out is null

saudet commented 2 years ago

FYI, this is more easily accomplished using the ffmpeg program: http://bytedeco.org/javacpp-presets/ffmpeg/apidocs/org/bytedeco/ffmpeg/ffmpeg.html

JinLike commented 2 years ago

FYI, this is more easily accomplished using the ffmpeg program: http://bytedeco.org/javacpp-presets/ffmpeg/apidocs/org/bytedeco/ffmpeg/ffmpeg.html

thank you but I I don't want to use the command

JinLike commented 2 years ago

FYI, this is more easily accomplished using the ffmpeg program: http://bytedeco.org/javacpp-presets/ffmpeg/apidocs/org/bytedeco/ffmpeg/ffmpeg.html

thank you but I I don't want to use the command