How to generate a thumbnail for a Java video

Source: Internet
Author: User

How to generate a thumbnail for a Java video

 

 

I found a lot of related information on the Internet.

But the problem persists.

I finally found it on the javaeye website today.

 

To facilitate searching for and helping friends who encounter the same problem in the future

Write a tutorial

 

 

You can use FFMPEG to generate thumbnails for uploaded videos.

I found out how to compile FFMPEG on the Internet.

But it's too complicated.

The compiled FFMPEG file is found on csdn.

Download

 

For everyone

Http://download.csdn.net/source/453719

 

I realized that FFmpeg is very powerful, and most popular video formats can generate thumbnails.

 

Start now

Download FFMPEG and decompress it.

Create a BAT file

Start

E:/FFMPEG/bin/ffmpeg.exe-I % 1-SS 20-vframes 1-R 1-Ac 1-AB 2-S 160*120-F image2 % 2

Exit

The meaning of using red bars

 

 

E:/FFMPEG/bin/ffmpeg.exe FFMPEG path

% 1% 2 is similar to the C language in that it is reserved for passing parameters.

20. How many seconds will the image be taken?

Open myeclipse and create a project and a Java File

Package test;

Import java. Io. ioexception;

Public class FFMPEG {

Public static void main (string [] ARGs ){

// Video file

String videorealpath = "F: // instantaneous. FLV ";

// Path (output path)

String imagerealpath = "F: // a.jpg ";

Try {

// Call the batch processing file

Runtime.getruntime(cmd.exe C ("CMD/C start F: // FFMPEG. Bat" + videorealpath + "" + imagerealpath );

} Catch (ioexception e ){

// Todo auto-generated Catch Block

E. printstacktrace ();

}

}

}

 

 

 

Run it and try again. You can see it in drive F.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.