org.bytedeco.javacv.FrameRecorder Java Examples
The following examples show how to use
org.bytedeco.javacv.FrameRecorder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RecorderActivity.java From VideoAndroid with Apache License 2.0 | 6 votes |
private void stopRecorder() { if(mRecorder == null || !mRecorder.isRecording()) { return; } if(mMyHandler.hasMessages(MSG_STOP)) { mMyHandler.removeMessages(MSG_STOP); } try { mRecorderCircleView.stop(); long recordingTime = mRecorder.getRecordingTime(); mRecorder.stop(); if(recordingTime < MIN_RECORDER_TIME) { //少于最少录制时间 Toast.makeText(getApplicationContext(), "录制时间至少" + MIN_RECORDER_TIME / 1000 + "s", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), "录制完成", Toast.LENGTH_SHORT).show(); startActivity(RecoderPlayerActivity.createIntent(this, mRecorder.getOutputPath())); finish(); } } catch (FrameRecorder.Exception|FrameFilter.Exception e) { e.printStackTrace(); } }
Example #2
Source File: Recorder.java From VideoAndroid with Apache License 2.0 | 6 votes |
/** * 开始录制 * @throws FrameRecorder.Exception * @throws FrameFilter.Exception */ public void start() throws FrameRecorder.Exception, FrameFilter.Exception { if(mRecording) { return; } int rotation = mBuilder.mMyOrientationDetector.getOrientation(); if(rotation == 0 || rotation == 180) { mFFmpegFrameRecorder = mFFmpegFrameRecorderV; } else { mFFmpegFrameRecorder = mFFmpegFrameRecorderL; } initFilter(); mBuilder.mCamera.setPreviewCallback(this); mFFmpegFrameRecorder.start(); mFFmpegFrameFilter.start(); mRecording = true; mRunAudioThread = true; mAudioThread = new Thread(mAudioRecordRunnable); mAudioThread.start(); mStartTime = System.currentTimeMillis(); }
Example #3
Source File: Recorder.java From VideoAndroid with Apache License 2.0 | 6 votes |
/** * 暂停视频 * @throws FrameRecorder.Exception * @throws FrameFilter.Exception */ public void stop() throws FrameRecorder.Exception, FrameFilter.Exception { if(!mRecording) { return; } mStartTime = 0L; mRunAudioThread = false; try { mAudioThread.join(); } catch (InterruptedException e) { // reset interrupt to be nice Thread.currentThread().interrupt(); return; } mAudioThread = null; if (mFFmpegFrameRecorder != null && mRecording) { mRecording = false; mFFmpegFrameRecorder.stop(); mFFmpegFrameRecorder.release(); mFFmpegFrameFilter.stop(); mFFmpegFrameFilter.release(); } }
Example #4
Source File: FFMPEGWriter.java From ssj with GNU General Public License v3.0 | 6 votes |
private void writeFrame(byte[] frameData, long time) { try { // Update frame ((ByteBuffer) imageFrame.image[0].position(0)).put(frameData); // Update timestamp long t = 1000 * (time - startTime); if (t > writer.getTimestamp()) { writer.setTimestamp(t); } // Write frame writer.record(imageFrame, pixelFormat); } catch (FrameRecorder.Exception e) { Log.e("Error while writing frame", e); } }
Example #5
Source File: RecorderActivity.java From VideoAndroid with Apache License 2.0 | 5 votes |
private void startRecorder() { if(mRecorder == null || mRecorder.isRecording()) { return; } try { mRecorder.start(); mRecorderCircleView.start(); mMyHandler.sendEmptyMessageDelayed(MSG_STOP, MAX_RECORDER_TIME); //MAX_RECORDER_TIME后自动停止 } catch (FrameRecorder.Exception|FrameFilter.Exception e) { e.printStackTrace(); Toast.makeText(getApplicationContext(), "录制失败", Toast.LENGTH_SHORT).show(); } }
Example #6
Source File: RecorderActivity.java From VideoAndroid with Apache License 2.0 | 5 votes |
private void releaseRecoder() { if(mRecorder != null) { if(mRecorder.isRecording()) { try { mRecorder.stop(); } catch (FrameRecorder.Exception|FrameFilter.Exception e) { e.printStackTrace(); } } mRecorder = null; } }
Example #7
Source File: FFMPEGWriter.java From ssj with GNU General Public License v3.0 | 5 votes |
@Override public void flush(Stream[] stream_in) throws SSJFatalException { try { writer.stop(); writer.release(); } catch (FrameRecorder.Exception e) { Log.e("Error while stopping writer", e); } }
Example #8
Source File: LivePlayTest2.java From oim-fx with MIT License | 4 votes |
/** * 转流器 * * @param inputFile * @param outputFile * @throws Exception * @throws org.bytedeco.javacv.FrameRecorder.Exception * @throws InterruptedException */ public static void recordPush(String inputFile, int v_rs) throws Exception, org.bytedeco.javacv.FrameRecorder.Exception, InterruptedException { Loader.load(opencv_objdetect.class); long startTime = 0; FrameGrabber grabber = FFmpegFrameGrabber.createDefault(inputFile); try { grabber.start(); } catch (Exception e) { try { grabber.restart(); } catch (Exception e1) { throw e; } } OpenCVFrameConverter.ToIplImage converter = new OpenCVFrameConverter.ToIplImage(); Frame grabframe = grabber.grab(); IplImage grabbedImage = null; if (grabframe != null) { System.out.println("取到第一帧"); grabbedImage = converter.convert(grabframe); } else { System.out.println("没有取到第一帧"); } System.out.println("开始推流"); CanvasFrame frame = new CanvasFrame("camera", CanvasFrame.getDefaultGamma() / grabber.getGamma()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setAlwaysOnTop(true); while (frame.isVisible() && (grabframe = grabber.grab()) != null) { System.out.println("推流..."); frame.showImage(grabframe); grabbedImage = converter.convert(grabframe); Frame rotatedFrame = converter.convert(grabbedImage); if (startTime == 0) { startTime = System.currentTimeMillis(); } Thread.sleep(40); } frame.dispose(); grabber.stop(); System.exit(2); }