creating video from sequence of images javacv

vach

For creating video from sequence of images in android I used javacv 0.6 library, but I meet problem: It normally works on htc Sensation(Android 4.0.1, Processor type armv7) and htc Desire(Android 2.3.3, Processor type arm7) phones, but it doesn't work on htc Wildfire (Android 2.3.5,Processor type armv6) phone particularly it fails in this part of code

FFmpegFrameRecorder recorder = new FFmpegFrameRecorder(videoFilePath,       
TalkingPhotoConstants.VIDEO_FRAME_WIDTH,TalkingPhotoConstants.VIDEO_FRAME_HEIGHT);

in the attached code.

public class MovieCreator extends AsyncTask<String, Void, Boolean> {

private opencv_core.IplImage[] iplimage;
private String audioFilePath;


private ProgressDialog progressDialog;
private Context context;
private List<TalkFrame> frames;

public MovieCreator(Context context, opencv_core.IplImage[] images, String audioFilePath,           
List<TalkFrame> frames) {
    this.context = context;
    this.iplimage = images;
    this.audioFilePath = audioFilePath;
    this.frames = frames;

}

private String createMovie() {

    String videoName = TalkingPhotoConstants.TMP_VIDEO_NAME;
    String path = TalkingPhotoConstants.RESOURCES_TMP_FOLDER;
    String videoFilePath = path + videoName;
    String finalVideoName = TalkingPhotoConstants.FINAL_VIDEO_NAME + 
    System.currentTimeMillis() + ".mp4";
    String finalVideoPath = TalkingPhotoConstants.RESOURCES_FOLDER + finalVideoName;

    try {

        FFmpegFrameRecorder recorder = new FFmpegFrameRecorder(videoFilePath, 
        TalkingPhotoConstants.VIDEO_FRAME_WIDTH,TalkingPhotoConstants.VIDEO_FRAME_HEIGHT);


        //int frameCount = iplimage.length;
        int frameCount = frames.size();
        recorder.setAudioCodec(AV_CODEC_ID_AMR_NB);
        recorder.setVideoCodec(AV_CODEC_ID_MPEG4);

        recorder.setVideoBitrate(120000);
        recorder.setFrameRate(TalkingPhotoConstants.VIDEO_FRAME_RATE);

        recorder.setPixelFormat(AV_PIX_FMT_YUV420P);
        recorder.setFormat("mp4");

        recorder.start();


        for (int i = 0; i < frameCount; i++) {
            TalkFrame currentFrame = frames.get(i);
            long duration = currentFrame.getDuration();
            opencv_core.IplImage iplImage = cvLoadImage(currentFrame.getImageName());

            for (int j = 0; j < TalkingPhotoConstants.VIDEO_FRAME_RATE * duration; j++) {
                recorder.record(iplImage);

            }

        }

        recorder.stop();

        mergeAudioAndVideo(videoFilePath, audioFilePath, finalVideoPath);

    } catch (Exception e) {
        Log.e("problem", "problem", e);
        finalVideoName = "";
    }
    return finalVideoName;
}

private boolean mergeAudioAndVideo(String videoPath, String audioPath, String outPut)  
throws Exception {
    boolean isCreated = true;
    File file = new File(videoPath);
    if (!file.exists()) {
        return false;
    }


    FrameGrabber videoGrabber = new FFmpegFrameGrabber(videoPath);
    FrameGrabber audioGrabber = new FFmpegFrameGrabber(audioPath);

    videoGrabber.start();
    audioGrabber.start();
    FrameRecorder recorder = new FFmpegFrameRecorder(outPut,
            videoGrabber.getImageWidth(), videoGrabber.getImageHeight(),
            audioGrabber.getAudioChannels());


    recorder.setFrameRate(videoGrabber.getFrameRate());
    recorder.start();
    Frame videoFrame = null, audioFrame = null;
    while ((audioFrame = audioGrabber.grabFrame()) != null) {
        videoFrame = videoGrabber.grabFrame();
        if (videoFrame != null) {
            recorder.record(videoFrame);
        }
        recorder.record(audioFrame);

    }
    recorder.stop();
    videoGrabber.stop();
    audioGrabber.stop();
    return isCreated;
}

@Override
protected Boolean doInBackground(String... params) {
    String fileName = createMovie();
    boolean result = fileName.isEmpty();
    if (!result) {
        VideoDAO videoDAO = new VideoDAO(context);
        videoDAO.open();
        videoDAO.createVideo(fileName);
        videoDAO.close();
    }
    //Utils.cleanTmpDir();
    return result;
}

@Override
protected void onPreExecute() {
    progressDialog = new ProgressDialog(context);
    progressDialog.setTitle("Processing...");
    progressDialog.setMessage("Please wait.");
    progressDialog.setCancelable(false);
    progressDialog.setIndeterminate(true);
    progressDialog.show();
}

@Override
protected void onPostExecute(Boolean result) {
    if (progressDialog != null) {
        progressDialog.dismiss();

    }
}

}

There is no exception.

1.how can i fix it?

2.I have a version that problem is connected with device's processor type.

If I'm right how can I solve it?

Thanks in advance.

chiastic-security

JavaCV contains some native C code that gets invoked by the Java. It looks as though you've got a version that's been compiled for ARMv7 but not for ARMv6.

In order to get it to work, you'll need to recompile the JavaCV native bits, for the processor you're wanting to target (ARMv6 in this case). Once you've done this, you should find it works OK.

Native code is a pain, but it is important for applications like this where it's doing some very CPU-intensive stuff.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Creating a video from a sequence of images in Matlab

From Dev

ffmepg video from uneven sequence of png images

From Dev

Creating a sequence of images from lyrics to use in ffmpeg

From Java

Python creating video from images using opencv

From Dev

Creating video from images with different SARs with FFMPEG

From Dev

Creating a video from set of images Android

From Dev

JavaCV Display image in color from video capture

From Dev

Android ffmpeg: create video from sequence of images using jni

From Dev

Creating an MJPEG video from still images using C#

From Dev

ffmpeg slideshow video from images creating empty mp4

From Dev

How to extract original images from a lossless compressed video which is composed from a sequence of images?

From Dev

Dynamically creating images in a sequence and having the sequence reset

From Dev

Creating video from images produces black screen video for certain image formats

From Dev

Extract Images from video and rebuild video with these images

From Dev

FFMPEG images to video with reverse sequence with other filters

From Dev

Convert a sequence of ppm images to avi video

From Dev

Converting a sequence of ppm images to video with python

From Dev

Create video from image sequence

From Dev

Add watermark to each frame while creating video from images using ffmpeg

From Dev

Creating MJEPG video from multiple JPEG encoded images without using cv::imdecode()

From Dev

Resolution Issue when creating an MPEG4 video from images (Windows Media Foundation)

From Dev

creating video from selected images using FFMPEG through command Line Android

From Dev

Creating Video Slideshow From Images With Different Sizing/Aspect Ratio Using FFMPEG?

From Dev

Stitching some images use JavaCV

From Dev

Creating a video from individual frames

From Dev

Creating Snapshoot Gallery From Video

From Dev

Create video from images in Flutter

From Dev

Create video from single images

From Dev

Create video from a list of images

Related Related

  1. 1

    Creating a video from a sequence of images in Matlab

  2. 2

    ffmepg video from uneven sequence of png images

  3. 3

    Creating a sequence of images from lyrics to use in ffmpeg

  4. 4

    Python creating video from images using opencv

  5. 5

    Creating video from images with different SARs with FFMPEG

  6. 6

    Creating a video from set of images Android

  7. 7

    JavaCV Display image in color from video capture

  8. 8

    Android ffmpeg: create video from sequence of images using jni

  9. 9

    Creating an MJPEG video from still images using C#

  10. 10

    ffmpeg slideshow video from images creating empty mp4

  11. 11

    How to extract original images from a lossless compressed video which is composed from a sequence of images?

  12. 12

    Dynamically creating images in a sequence and having the sequence reset

  13. 13

    Creating video from images produces black screen video for certain image formats

  14. 14

    Extract Images from video and rebuild video with these images

  15. 15

    FFMPEG images to video with reverse sequence with other filters

  16. 16

    Convert a sequence of ppm images to avi video

  17. 17

    Converting a sequence of ppm images to video with python

  18. 18

    Create video from image sequence

  19. 19

    Add watermark to each frame while creating video from images using ffmpeg

  20. 20

    Creating MJEPG video from multiple JPEG encoded images without using cv::imdecode()

  21. 21

    Resolution Issue when creating an MPEG4 video from images (Windows Media Foundation)

  22. 22

    creating video from selected images using FFMPEG through command Line Android

  23. 23

    Creating Video Slideshow From Images With Different Sizing/Aspect Ratio Using FFMPEG?

  24. 24

    Stitching some images use JavaCV

  25. 25

    Creating a video from individual frames

  26. 26

    Creating Snapshoot Gallery From Video

  27. 27

    Create video from images in Flutter

  28. 28

    Create video from single images

  29. 29

    Create video from a list of images

HotTag

Archive