This series of articles navigation
Quick Start for ffmpeg under Windows
FFmpeg parameter explanation
MEncoder and FFmpeg parameter detailed (Java processing video)
Java generated video thumbnails (ffmpeg)
Using FFmpeg to convert video files into FLV finishing
Java Video processing MEncoder
Java Video Processing Ffmped+mencoder
1, first download ffmpeg
2, extract the extracted ffmpeg.exe and PthreadGC2.dll files to any directory (of course, can also be webroot in the directory)
3. Create bat file Convertvideo.bat and add the following: (see appendix I for parameter description)
%1/ffmpeg-i%2-y-ab 56-ar 22050-b 500-r 15-s 320*240%3
exit
******************
%1 is a ffmpeg storage directory
%2 is the file path that needs to be converted
%3 for FLV file output directory
******************
Note that the path to the bat file cannot contain spaces
"Grab thumbnails while converting file formats"
Ffmpeg-i "Test.avi"-y-f image2-ss 8-t 0.001-s 350x240 "Test.jpg"
"On an existing FLV catch map"
Ffmpeg-i "test.flv"-y-f image2-ss 8-t 0.001-s 350x240 "Test.jpg"
****************
The time unit followed by the-SS is seconds
****************
"Ffmpeg-i" "
Test.avi"-y-f image2-ss 8-t 0.001-s 350x240 "Test.jpg"
on an existing FLV capture "
ffmpeg-i" t est.flv "-y-f image2-ss 8-t 0.001-s 350x240" Test.jpg "
the time unit followed by the-ss is seconds
****************
4. Create Class
public class Convertvideo {private static string Input_path; private static string Output_path; private static string PRO Ject_path; private static hashmap<string, string> FileType; static {FileType = new hashmap<string, string> (); Filetype.put ("Avi", "true"); Filetype.put ("mpg", "true"); filety Pe.put ("WMV", "true"); Filetype.put ("3gp", "true"); Filetype.put ("mov", "true"); Filetype.put ("mp4", "true"); Filetype.put ("ASF", "true"); Filetype.put ("ASX", "true"); Filetype.put ("flv", "true"); public static void converttoflv (String projectpath, String inputfile, String outputfile) {Input_path = Inputfile; Output_path = outputfile; Project_path = ProjectPath; if (Checkcontenttype ()) processflv ()//Direct file to FLV file} private static Boolean Checkcontenttype () {String type = Input_pat H.substring (Input_path.lastindexof (".") + 1, input_path.length ()). toLowerCase (); FFmpeg can parse the format: (asx,asf,mpg,wmv,3gp,mp4,mov,avi,flv, etc.) return "true". Equals (Filetype.get (type)); } private static void Processflv () {if (new File (Input_path). Isfile ()) {try {String cmd = ' cmd/c start x://ffmpeg.bat/' + Project_path + '/ "/" "+ Input_path +"/"/" "+ Output_path +"/""; Runtime.getruntime (). exec (CMD); catch (Exception e) {e.printstacktrace ();}} } }
5. Test code
public static void Main (string[] args) {convertvideo.converttoflv ("X://convertvideo", "x://a.wmv", "x://a.flv");}
JS Code
var swf_width= "100%"; var swf_height= "100%"; var files= ' nba.flv '; var config= ' 0: AutoPlay |1: Continuous playback |100: Default volume | control bar Location: Control bar display |0x000033: Body color |60: Body transparency |0x66ff00: Halo color |0xffffff: Icon color |0xffffff: Text color |:logo text |:logo address |: End SWF address '; var texts= ' NBA wonderful goal TOP10 '; document.write (' <object classid= ' clsid:d27cdb6e-ae6d-11cf-96b8-444553540000 "codebase=" http:// fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0 "width=" ' +swf_width+ ' "height=" ' + swf_height+ ' ">"); document.write (' <param name= "movie" value= "vcastr2.swf"/> "); document.write (' <param name= "quality" value= "High"/> "); document.write (' <param name= "menu" value= "false"/> '); document.write (' <param name=wmode value= ' opaque '/> '); document.write (' <param name= "flashvars" value= "vcastr_file= ' +files+ ' &vcastr_title= ' +texts+ ') &vcastr_ config= ' +config+ ' ">"); document.write (' <embed src= "vcastr2.swf" mce_src= "vcastr2.swf"/> "wmode=" opaque "flashvars=" vcastr_file= "+ files+ ' &vcastr_title= ' +texts+ ' &vcastr_config= ' +config+ ' "menu=" false "quality=" High "width=" ' +swf_width+ ' "height=" ' +swf_height+ ' "type=" Application/x-shockwave-flash "pluginspage=" Http://www.macromedia.com/go/getflashplayer "/>"); document.write (' </object> ');
Supplemental Notes If you encounter a video format other than FFmpeg, you can use a different conversion tool to convert first, such as MEncoder.
Appendix I (ffmpeg parameter description):
Parameters |
Description |
Example |
-I "Path" |
Specify the file path to convert |
-I "c:/nba.wmv" |
-Y |
Overwrite the output file, that is, if the nba.xxx file already exists, direct overwrite |
|
Control screen Parameters |
-bitexac |
Use standard bit rate |
|
-vcodec XviD |
Using XviD compression |
|
-s < width/height ratio > |
Specify resolution Size |
-S 320*240 |
-R < numerical > |
Frame rate (non-standard values cause the tone picture to be unsynchronized "standard value is 15 or 29.97") |
-R 15 |
-b < bit rate > |
Specify the compression bit rate |
-B 1500 |
-qmin < numerical > |
Set minimum Quality |
-qmin 10 |
-qmax < numerical > |
Contrary to-qmin, it can be used concurrently with-qmin |
-qmax 30 |
-sameq |
Use the same quality as the source video |
|
Controlling sound Parameters |
-acodec AAC |
Set Sound coding |
|
-ac < numerical > |
Set channel number: 1 for mono, 2 for stereo |
-ac 2 |
-ar < sampling rate > |
Set sound sampling rate (8000,11025,22050) |
-ar 22050 |
-ab < bit rate > |
Set the sound bit rate (-AC is set to half bit rate in stereo, for example, 192kbps is set to 96) |
-AB 96 |
-vol <% > |
Set the volume size, such as setting 200 will be twice times larger than the original volume |
-vol 200 |
Blog Source: http://www.javaeye.com/topic/333994