FFmpegFrameRecorder recorder = new FFmpegFrameRecorder("/sdcard/test.mp4",256,256); try { recorder.setVideoCodec(avcodec.AV_CODEC_ID_MPEG4); recorder.setFormat("mp4"); recorder.setFrameRate(30); recorder.setPixelFormat(avutil.PIX_FMT_YUV420P10); recorder.setVideoBitrate(1200); recorder.startUnsafe(); for (int i=0;i< 5;i++) { view.setDrawingCacheEnabled(true); Bitmap bitmap = Bitmap.createBitmap(v1.getDrawingCache()); view.setDrawingCacheEnabled(false); recorder.record(bitmap); } recorder.stop(); } catch (Exception e){ e.printStackTrace(); }
opencv_core.IplImage img = cvLoadImage("/sdcard/folder/img1.jpg"); FFmpegFrameRecorder recorder = new FFmpegFrameRecorder("/sdcard/folder/test.mpeg",200,150); try { recorder.setCodecID( CODEC_ID_MPEG1VIDEO); recorder.setFrameRate(30); recorder.setPixelFormat( PIX_FMT_YUV420P); recorder.start(); for (int i=0;i<100;i++) { recorder.record(image[x]); } recorder.stop(); } catch (Exception e){ e.printStackTrace(); }
public void stopRecord() { // This should stop the audio thread from running runAudioThread = false; if (recorder != null && recording) { recording = false; Log.v(LOG_TAG,"Finishing recording, calling stop and release on recorder"); try { recorder.stop(); recorder.release(); } catch (FFmpegFrameRecorder.Exception e) { e.printStackTrace(); } recorder = null; } }
public void record(Frame frame, int pixelFormat) throws Exception { if (frame == null || (frame.image == null && frame.samples == null)) { recordImage(0, 0, 0, 0, 0, pixelFormat, (Buffer[])null); } else { if (frame.image != null) { frame.keyFrame = recordImage(frame.imageWidth, frame.imageHeight, frame.imageDepth, frame.imageChannels, frame.imageStride, pixelFormat, frame.image); } if (frame.samples != null) { frame.keyFrame = recordSamples(frame.sampleRate, frame.audioChannels, frame.samples); } } }
recorder = new FFmpegFrameRecorder(ffmpeg_link, imageWidth, imageHeight, 1); Log.v(LOG_TAG, "FFmpegFrameRecorder: " + ffmpeg_link + " imageWidth: " + imageWidth + " imageHeight " + imageHeight); recorder.setFormat("flv"); Log.v(LOG_TAG, "recorder.setFormat(\"flv\")"); recorder.setSampleRate(sampleAudioRateInHz); Log.v(LOG_TAG, "recorder.setSampleRate(sampleAudioRateInHz)"); recorder.setFrameRate(frameRate); Log.v(LOG_TAG, "recorder.setFrameRate(frameRate)"); recorder.start(); startTime = System.currentTimeMillis(); recording = true; Log.v(LOG_TAG,"Finishing recording, calling stop and release on recorder"); try { recorder.stop(); recorder.release(); } catch (FFmpegFrameRecorder.Exception e) { e.printStackTrace(); recorder.record(ShortBuffer.wrap(audioData, 0, bufferReadResult)); } catch (FFmpegFrameRecorder.Exception e) { Log.v(LOG_TAG,e.getMessage()); recorder.setTimestamp(videoTimestamp);
ArrayList<String> paths = (ArrayList<String>) getListOfFiles( path, "jpg"); FFmpegFrameRecorder recorder = new FFmpegFrameRecorder(path + "/" + "test.mp4", 400, 400); videoPath = path + "/" + "test.mp4"; try { recorder.setVideoCodec(avcodec.AV_CODEC_ID_MPEG4); recorder.setFormat("mp4"); recorder.setFrameRate(frameRate); recorder.setVideoBitrate(30); startTime = System.currentTimeMillis(); recorder.start(); for (int i = 0; i <paths.size(); i++) { IplImage image = cvLoadImage(path + "/" + paths.get(i)); long t = 3000 * (System.currentTimeMillis() - startTime); if (t > recorder.getTimestamp()) { recorder.setTimestamp(t); recorder.record(image); System.out.println("Total Time:- " + recorder.getTimestamp()); recorder.stop(); } catch (Exception e) { e.printStackTrace();
FFmpegFrameRecorder recorder; Frame frame = new Frame(); recorder = new FFmpegFrameRecorder(newFilePath, 250, 250); recorder.setFrameRate(20); recorder.setFormat("mp4"); recorder.setAudioChannels(2); recorder.setPreset("veryfast"); try { long startTime = System.currentTimeMillis(); Log.d("Tempo", "" + startTime); frameGrabber.start(); recorder.start(); while (true) { try { break; recorder.record(frame); } catch (Exception e) { Log.e("converter", e.getMessage()); recorder.stop(); recorder.release(); long stopTime = System.currentTimeMillis(); System.out.println(""+stopTime);
fileName = file.getAbsolutePath().replace(".mp4", "_edited.mp4"); recorder = new FFmpegFrameRecorder(fileName, frameGrabber.getImageWidth(), frameGrabber.getImageHeight(),frameGrabber.getAudioChannels()); recorder.setVideoCodec(avcodec.AV_CODEC_ID_H264); recorder.setFormat("mp4"); recorder.setFrameRate(frameGrabber.getFrameRate()); recorder.setSampleFormat(frameGrabber.getSampleFormat()); recorder.setSampleRate(frameGrabber.getSampleRate()); recorder.start(); while (true) { try { recorder.setTimestamp(frameGrabber.getTimestamp()); recorder.record(captured_frame); recorder.stop(); recorder.release(); frameGrabber.stop(); } catch (Exception e) {
recorder.setVideoCodec(avcodec.AV_CODEC_ID_MPEG4); recorder.setFormat("3gp"); recorder.setFrameRate(frameRate); recorder.setSampleRate(grabber2.getSampleRate()); recorder.setVideoBitrate(30); startTime = System.currentTimeMillis(); recorder.start(); recorder.record(frame1); recorder.record(frame2); recorder.stop(); System.out.println("Total Time:- " + recorder.getTimestamp());
long t = timestamps[i % timestamps.length] - startTime; if(t >= 0) { if(t > recorder.getTimestamp()) { recorder.setTimestamp(t); recorder.record(images[i % images.length]); recorder.recordSamples(samples[i % samples.length]); Log.v(LOG_TAG, "Finishing recording, calling stop and release on recorder"); try { recorder.stop(); recorder.release(); } catch(FFmpegFrameRecorder.Exception e) { e.printStackTrace();
FFmpegFrameGrabber grabber1 = new FFmpegFrameGrabber("song.mp3"); grabber1.start(); FFmpegFrameRecorder recorder = new FFmpegFrameRecorder("/mnt/sdcard/Video_images/output"+System.currentTimeMillis()+".mp4",200,150, grabber1.getAudioChannels()); try { recorder.setVideoCodec(a); //CODEC_ID_MPEG4 //CODEC_ID_MPEG1VIDEO recorder.setFrameRate(24); recorder.setPixelFormat(PIX_FMT_YUV420P); //PIX_FMT_YUV420P recorder.start(); com.googlecode.javacv.Frame frame1 = new com.googlecode.javacv.Frame(); for (int i=0;i<iplimage.length;i++) { frame1 = grabber1.grabFrame(); recorder.record(frame1); recorder.record(iplimage[i]); } recorder.stop(); grabber1.stop();
private void initRecorder() { Log.w(LOG_TAG,"initRecorder"); // region yuvImage = new Frame(imageWidth, imageHeight, Frame.DEPTH_UBYTE, 2); Log.d(LOG_TAG, "IplImage.create"); // endregion recorder = new FFmpegFrameRecorder(ffmpeg_link, imageWidth, imageHeight, 1); Log.v(LOG_TAG, "FFmpegFrameRecorder: " + ffmpeg_link + " imageWidth: " + imageWidth + " imageHeight " + imageHeight); recorder.setFormat("flv"); Log.v(LOG_TAG, "recorder.setFormat(\"flv\")"); recorder.setSampleRate(sampleAudioRateInHz); Log.v(LOG_TAG, "recorder.setSampleRate(sampleAudioRateInHz)"); // re-set in the surface changed method as well recorder.setFrameRate(frameRate); Log.v(LOG_TAG, "recorder.setFrameRate(frameRate)"); // Create audio recording thread audioRecordRunnable = new AudioRecordRunnable(); audioThread = new Thread(audioRecordRunnable); }
filter.push(tempVideoFrame); tempVideoFrame = filter.pull(); videoRecorder.record(tempVideoFrame); videoRecorder.stop(); filter.stop(); videoRecorder.release(); VIDEO_GRABBER.stop(); VIDEO_GRABBER.release(); videoRecorder.setAudioChannels(VIDEO_GRABBER.getAudioChannels()); videoRecorder.start(); } catch (FrameRecorder.Exception e) { e.printStackTrace();
public static FFmpegFrameRecorder createDefault(String f, int w, int h) throws Exception { return new FFmpegFrameRecorder(f, w, h); }
FFmpegFrameRecorder stableVideoRecorder = FFmpegFrameRecorder.createDefault(outputVideo, outImagePrev.cols(), outImagePrev.rows());//again, use your video stableVideoRecorder.start(); stableVideoRecorder.record(matConverter.convert(outImagePrev)); stableVideoRecorder.stop();
public void stop() throws Exception { if (oc != null) { try { synchronized (oc) { /* flush all the buffers */ while (video_st != null && ifmt_ctx == null && recordImage(0, 0, 0, 0, 0, AV_PIX_FMT_NONE, (Buffer[])null)); while (audio_st != null && ifmt_ctx == null && recordSamples(0, 0, (Buffer[])null)); if (interleaved && video_st != null && audio_st != null) { av_interleaved_write_frame(oc, null); } else { av_write_frame(oc, null); } /* write the trailer, if any */ av_write_trailer(oc); } } finally { release(); } } }
recorder.setTimestamp(videoTimestamp); recorder.record(yuvImage);
public void start(AVFormatContext ifmt_ctx) throws Exception { this.ifmt_ctx = ifmt_ctx; start(); }
@Override public void record(Frame frame) throws Exception { record(frame, AV_PIX_FMT_NONE); } public void record(Frame frame, int pixelFormat) throws Exception {