我想实现暂停/恢复功能,同时录制视频。 MediaRecorder不具有暂停/恢复任何方法。内置相机应用程序有暂停/恢复功能。是否有可能实现吗?
I want to implement pause/resume functionality while recording video. MediaRecorder is not having any method for pause/resume. Native camera application is having pause/resume feature. Is it possible to implement it?
请指引我。任何帮助或指导将是非常美联社preciated。
Please guide me. Any help or guidance will be well appreciated.
推荐答案
最后我找到了答案:)我研究有关的FFmpeg似乎更深入,一些多天周围挖,但不能得到对于ffmepg适当的资源,我尝试使用mp4parser lib和成功地完成了我的要求。
Finally i find the answer :) i research about ffmpeg it seems more deeply and some more days digging around it but can't get proper resource for ffmepg and i try to use mp4parser lib and successfully completed my requirement.
code对于合并多个视频
Code For Merging Multiple Video
public class MergeVide extends AsyncTask<String, Integer, String> {
@Override
protected void onPreExecute() {
progressDialog = ProgressDialog.show(Video.this,
"Preparing for upload", "Please wait...", true);
// do initialization of required objects objects here
};
@Override
protected String doInBackground(String... params) {
try {
String paths[] = new String[count];
Movie[] inMovies = new Movie[count];
for (int i = 0; i < count; i++) {
paths[i] = path + filename + String.valueOf(i + 1) + ".mp4";
inMovies[i] = MovieCreator.build(new FileInputStream(
paths[i]).getChannel());
}
List<Track> videoTracks = new LinkedList<Track>();
List<Track> audioTracks = new LinkedList<Track>();
for (Movie m : inMovies) {
for (Track t : m.getTracks()) {
if (t.getHandler().equals("soun")) {
audioTracks.add(t);
}
if (t.getHandler().equals("vide")) {
videoTracks.add(t);
}
}
}
Movie result = new Movie();
if (audioTracks.size() > 0) {
result.addTrack(new AppendTrack(audioTracks
.toArray(new Track[audioTracks.size()])));
}
if (videoTracks.size() > 0) {
result.addTrack(new AppendTrack(videoTracks
.toArray(new Track[videoTracks.size()])));
}
BasicContainer out = (BasicContainer) new DefaultMp4Builder()
.build(result);
@SuppressWarnings("resource")
FileChannel fc = new RandomAccessFile(String.format(Environment
.getExternalStorageDirectory() + "/wishbyvideo.mp4"),
"rw").getChannel();
out.writeContainer(fc);
fc.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String mFileName = Environment.getExternalStorageDirectory()
.getAbsolutePath();
mFileName += "/wishbyvideo.mp4";
filename = mFileName;
return mFileName;
}
@Override
protected void onPostExecute(String value) {
super.onPostExecute(value);
progressDialog.dismiss();
Intent i = new Intent(Video.this, VideoUpload.class);
i.putExtra("videopath", value);
i.putExtra("id", id);
i.putExtra("name", name);
i.putExtra("photo", photo);
startActivity(i);
finish();
}
}
计数无非是视频文件的数量。
the count is nothing but video file count.
以上code对于合并更多的视频和发送的最后code到另一个活动在我决定preVIEW视频。之前使用上述code确保使用mp4parser库。
the above code for merge more video and send the final code to another activity in that i have decided to preview the video. before using above code make sure use mp4parser lib.
相关推荐
最新文章