Android:在捕获期间拆分视频 [英] Android: Split video during capture
问题描述
我正在寻找在捕获期间将视频拆分为 5 分钟部分的解决方案.例如,在一小时的旅行(视频拍摄)期间,我想将此视频(旅行期间)分割为更小的视频 12 * 5 分钟 = 1 小时.不是在停止捕获之后,而是在此期间.
I am looking for solution to split video during capture to 5 minutes parts. For example, during one hour trip (video capture) I would like to divide this video (during trip) to smaller videos 12 * 5 min = 1h. Not after stop capture, but in the meantime.
我想做一些像录像机这样的事情.你能告诉我我需要用什么来解决这个问题吗?
I would like to do something like video recorder. Could you tell me what I need to use to do this issue?
推荐答案
我找到了解决方案,需要使用:
I found the solution, you need to use:
MediaRecorder.MEDIA_RECORDER_INFO_MAX_DURATION_REACHED
Android 文档中的完整说明:MediaRecorder |安卓
Here is full description in Android documentation: MediaRecorder | Android
以下是我正在使用的代码的一部分 &它正在工作:)
Below is part of my code which I am using & it is working :)
if(what==MediaRecorder.MEDIA_RECORDER_INFO_MAX_DURATION_REACHED)
recorder.stop();
recorder.reset();
// Flag to recording (in my code I am using to stop/start capturing)
recording = false;
recording = true;
initRecorder();
prepareRecorder();
recorder.start();
Toast.makeText(MainActivity.this, "Again",Toast.LENGTH_LONG).show();
// 5 000 ms - 5 s
// 300 000 ms - 5 min
}
要设置最大持续时间,您需要声明:
To set Max Duration you need to declare:
recorder.setMaxDuration(300000);
在 initRecorder()
函数中.
我建议您还阅读以下内容:SetMaxDuration
in initRecorder()
function.
I recommend you also read this: SetMaxDuration
希望我写的东西对你有帮助.
I hope that what I wrote will help you.
这篇关于Android:在捕获期间拆分视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!