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.