0

There is a solution for android (java), to create thumbnails from a video that is online and weighs (658mb) about 2 hours and 30 minutes.

I read that ffmpeg, allows you to do such a thing to create thumbnails.

So I have some questions, since the video is online (http), it weighs a lot, so I can not download it:

1) ffmpeg can run on an android app? without having performance problems?

2) Is there probable solution without using ffmpeg?

Paul
  • 3,644
  • 9
  • 47
  • 113
  • take a look at this issue : https://stackoverflow.com/questions/22954894/is-it-possible-to-generate-a-thumbnail-from-a-video-url-in-android – user 007 Jul 03 '18 at 12:37

1 Answers1

0
    String outputPath= videoFile.getAbsolutePath();

        Bitmap bmThumbnail;
                    bmThumbnail = ThumbnailUtils.createVideoThumbnail(outputPath, MediaStore.Video.Thumbnails.MINI_KIND);
                    if (bmThumbnail == null) return;
                    thumb = getThumbMediaFile();
                    try {
                        OutputStream os;
                        os = new FileOutputStream(thumb);
                        bmThumbnail.compress(Bitmap.CompressFormat.PNG, 100, os);
                        os.flush();
                        os.close();
                    } catch (Exception e) {
                        Log.e(getClass().getSimpleName(), "Error writing bitmap", e);
                    }

 public static File getThumbMediaFile() {
        File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(
                Environment.DIRECTORY_PICTURES), "YOUR DIRECTORY NAME"+ File.separator + "THUMB DIRECTORY NAME");
        if (!mediaStorageDir.exists()) {
            if (!mediaStorageDir.mkdirs()) {
                Log.e(getClass().getSimpleName(), "failed to create directory");
                return null;
            }
        }
        // Create a media file name
        String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
        File mediaFile;

        mediaFile = new File(mediaStorageDir.getPath() + File.separator +
                "IMG_" + timeStamp + ".png");

        return mediaFile;
    }
Kamlesh
  • 407
  • 1
  • 3
  • 17
  • Thank you for answering, but this solution would not be suitable for a video that is on the device? outputPath is not a path of video file. – Paul Jul 03 '18 at 13:08
  • Describe more so i can help you in this. – Kamlesh Jul 03 '18 at 13:09
  • Outpath is just taking video file path which will help to create video thumb – Kamlesh Jul 03 '18 at 13:11
  • Being that I am developing to player based on exoplayer, I would like to implement PreviewSeekBar on it: https://github.com/rubensousa/PreviewSeekBar which allows you to preview a video. But to do this, I need to create miniatures. As I have specified, the kind of videos played are very large in size around 700 mb or so. let me know if there is something I have not explained correctly. – Paul Jul 03 '18 at 13:16