如何添加暂停和恢复功能,而在Android的重新编码视频 [英] How to add pause and resume feature while recoding video in android

查看:168
本文介绍了如何添加暂停和恢复功能,而在Android的重新编码视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要求:

我想开发一个应用程序,具有视频重新编码以暂停和恢复功能。

我曾尝试:

我已经开发了应用程序高达使用表面观重新编码的视频。

研究之已经:

我已经找遍了所有的网站,也,但到现在我不能得到的解决方案, 我知道有对暂停和恢复视频的android没有默认选项,也知道通过合并,我们可以实现它的视频。

我需要的是什么:

请分享我,如果有任何外部插件可用的,指导我如何,如果你已经达到了实现这一目标,同时也分享我的搜索,有关如何合并视频..我任何种源,但没有适当的资源我看到了,请分享任何事情,如果你发现......

Requirement :

I want to develop an app that has Video Recoding with pause and resume feature.

I Have Tried :

I have developed the app upto recoding the video by using surface view.

Already Researched :

I have already searched all the site and also like but till now i can't get the solution and that i know there is no default option in android for pause and resume video and also know by merging the video we can achieve it.

What i need:

Please share me if there is any external plugin available for it, guide me how to achieve this if you already achieved, and also share me any resouce that related to how to merge video ..i have searched but no proper resource i had seen please share any thing if you find..

推荐答案

终于让我找到了答案:)
    我考证一下FFmpeg的似乎更深入,一些多天周围挖,但却无法获得ffmepg
适当的资源,我尝试使用mp4parser的 LIB ,并成功地完成了我的要求。

code对于合并多个视频

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 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.

以上$ C $下合并更多的视频和发送的最后code到另一个活动中,我已决定,以preVIEW视频。
使用上述code确保使用mp4parser LIB前。

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.

这篇关于如何添加暂停和恢复功能,而在Android的重新编码视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆