FFmpegFrameRecorder

来源:互联网 发布:自学广告设计软件 编辑:程序博客网 时间:2024/06/08 05:30
   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();    }}
原创粉丝点击