FFmpegFrameRecorder

闾丘淇
2023-12-01
file=new File(sdcard+"ok.mp4");
    if (!file.exists()){
        try {
            file.createNewFile();
        }catch (IOException e){

      }
       }
        try{
      //      File file1=new File(sdcard+"1.mp4");
       //     file1.createNewFile();
        //    recorder= new FFmpegFrameRecorder(
         //   sdcard+"ok.mp4", 1080,
          //  720);
            recorder=new FFmpegFrameRecorder(file,2100,2100,0);
        //    File file11=new File(sdcard+"11.mp4");
       //     file11.createNewFile();
           // testBitmap.recycle();
        }

        catch (Exception e){
         //   Toast.makeText(getApplicationContext(), "recorder", Toast.LENGTH_LONG).show();
        }
    recorder.setFormat("mp4");
    recorder.setFrameRate(20);// 褰曞儚甯х巼
    recorder.setPixelFormat(avutil.AV_PIX_FMT_YUV420P);
  //  recorder.setSampleRate(20);
//recorder.setVideoCodec(avcodec.AV_CODEC_ID_H264);
  //  recorder.setVideoQuality(0);
//    recorder.setVideoOption("preset", "veryfast");
    try{
   //     File file2=new File(sdcard+"12.mp4");
    //    file2.createNewFile();
        recorder.start();
    }catch (Exception e){
    //    Toast.makeText(getApplicationContext(), "start", Toast.LENGTH_LONG).show();
    }
    for (int index=0;index < 5;index++) {


        try{
          //  recorder.
            image = cvLoadImage(arrayList.get(index));

            testBitmap = VideoCapture.getImageByPath(arrayList.get(index));
            image.alphaChannel(100);
            for (int i=0;i<50;i++){
               recorder.setImageWidth(100*(index+1));
                recorder.setImageHeight(100*(index+1));

                //  recorder
            recorder.record(image);

            }
            image.release();
        }catch (Exception e){
        //    Toast.makeText(getApplicationContext(), "record", Toast.LENGTH_LONG).show();
        }
testBitmap.recycle();
        index++;
    }
    try{
    recorder.stop();
    }
    catch (Exception e){
   //     Toast.makeText(getApplicationContext(), "stop", Toast.LENGTH_LONG).show();
    }
}

相关阅读

相关文章

相关问答