Search code examples
androidbitmapjcodec

Creating video from images with jcodec (error)


I'm trying to use jcodec library to create video from images but sequenceEncoder.encodeImage(bitmap) is showing error.

my code for encoding is :-

class EncodeImages extends AsyncTask<File, Integer, Integer>{

        @Override
        protected Integer doInBackground(File... params) {
            SequenceEncoder sequenceEncoder;

            try {
                sequenceEncoder = new SequenceEncoder(new File(params[0].getParentFile(),"Frames Video.mp4"));

                for (int i = 0; !flag; i++) {
                    File imagesFile = new File(params[0].getParentFile(), String.format(params[0].getName(), i));

                    if(!imagesFile.exists()){
                        break;
                    }
                    Bitmap bitmap = BitmapFactory.decodeFile(imagesFile.getAbsolutePath());

                    sequenceEncoder.encodeImage(bitmap);

                    publishProgress(i);

                }

                sequenceEncoder.finish();
            } catch (IOException e) {
                e.printStackTrace();
            }

            return null;
        }

    }

But the line - sequenceEncoder.encodeImage(bitmap); is showing following errors :-

Multiple markers at this line - The type java.awt.image.BufferedImage cannot be resolved. It is indirectly referenced from required .class files... - The method encodeImage(BufferedImage) from the type SequenceEncoder refers to the missing type BufferedImage...

it is asking me to configure build path. I've tried like everything, but in vain. What should I do next???


Solution

  • java.awt classes are not present in Android. You should try JavaCV for Video encoding or as I see jcodec added Android version on September 14 2013. You should download android version from https://github.com/jcodec/jcodec and add that into your project.