FrameRecorder / FFmpegFrameRecorder输出文件中没有声音

时间:2012-10-03 17:45:07

标签: android opencv ffmpeg javacv

这是我使用JavaCV和ffmpeg在android中调整视频大小的代码 -

FFmpegFrameGrabber grabber = new FmpegFrameGrabber("/sdcard/DCIM/100MEDIA/VIDEO0066.mp4"); 
        grabber.start();

        int w = (int)grabber.getImageWidth()/2;
        int h = (int)grabber.getImageHeight()/2;        

        if (w%2 != 0) w=w-1;
        if (h%2 != 0) h=h-1;

        FrameRecorder recorder = new FFmpegFrameRecorder("/sdcard/DCIM/output.mov", w, h ,grabber.getAudioChannels());

        recorder.setVideoCodec(avcodec.CODEC_ID_MPEG4);
        recorder.setPixelFormat(avutil.PIX_FMT_YUV420P);
        recorder.setAudioCodec(avcodec.CODEC_ID_PCM_S16LE); 
        recorder.start(); 

        Frame frame = null;
        while ((frame = grabber.grabFrame()) != null)
        {
            IplImage source = frame.image;
            if (source!=null)
            {
            IplImage destination = cvCreateImage(cvSize(w , h), source.depth(), source.nChannels() );
            cvResize(source, destination);
            frame.image = destination;
            recorder.record(frame);

            }
        }

如果我使用的原始宽度和高度比视频有声,但是当我使用w / 2和h / 2时,输出文件没有声音。 请指教。

0 个答案:

没有答案