标签:
JAVE 官方的jar包带了ffmpeg的exe程序,所以在windows上可以直接使用,但是如果要在Linux上用就得先把ffmpeg的环境装好。
官方的jar包在这里下载:http://www.sauronsoftware.it/projects/jave/download.php
在这里列几个官方的demo:
1、From a generic AVI to a youtube-like FLV movie, with an embedded MP3 audio stream:
File source = new File("source.avi"); File target = new File("target.flv"); AudioAttributes audio = new AudioAttributes(); audio.setCodec("libmp3lame"); audio.setBitRate(new Integer(64000)); audio.setChannels(new Integer(1)); audio.setSamplingRate(new Integer(22050)); VideoAttributes video = new VideoAttributes(); video.setCodec("flv"); video.setBitRate(new Integer(160000)); video.setFrameRate(new Integer(15)); video.setSize(new VideoSize(400, 300)); EncodingAttributes attrs = new EncodingAttributes(); attrs.setFormat("flv"); attrs.setAudioAttributes(audio); attrs.setVideoAttributes(video); Encoder encoder = new Encoder(); encoder.encode(source, target, attrs);
File source = new File("source.avi"); File target = new File("target.wav"); AudioAttributes audio = new AudioAttributes(); audio.setCodec("pcm_s16le"); EncodingAttributes attrs = new EncodingAttributes(); attrs.setFormat("wav"); attrs.setAudioAttributes(audio); Encoder encoder = new Encoder(); encoder.encode(source, target, attrs);
File source = new File("source.wav"); File target = new File("target.mp3"); AudioAttributes audio = new AudioAttributes(); audio.setCodec("libmp3lame"); audio.setBitRate(new Integer(128000)); audio.setChannels(new Integer(2)); audio.setSamplingRate(new Integer(44100)); EncodingAttributes attrs = new EncodingAttributes(); attrs.setFormat("mp3"); attrs.setAudioAttributes(audio); Encoder encoder = new Encoder(); encoder.encode(source, target, attrs);
File source = new File("source.avi"); File target = new File("target.avi"); AudioAttributes audio = new AudioAttributes(); audio.setCodec("libmp3lame"); audio.setBitRate(new Integer(56000)); audio.setChannels(new Integer(1)); audio.setSamplingRate(new Integer(22050)); VideoAttributes video = new VideoAttributes(); video.setCodec(VideoAttributes.DIRECT_STREAM_COPY); EncodingAttributes attrs = new EncodingAttributes(); attrs.setFormat("avi"); attrs.setAudioAttributes(audio); attrs.setVideoAttributes(video); Encoder encoder = new Encoder(); encoder.encode(source, target, attrs);
File source = new File("source.avi"); File target = new File("target.avi"); AudioAttributes audio = new AudioAttributes(); audio.setCodec("libvorbis"); VideoAttributes video = new VideoAttributes(); video.setCodec("mpeg4"); video.setTag("DIVX"); video.setBitRate(new Integer(160000)); video.setFrameRate(new Integer(30)); EncodingAttributes attrs = new EncodingAttributes(); attrs.setFormat("mpegvideo"); attrs.setAudioAttributes(audio); attrs.setVideoAttributes(video); Encoder encoder = new Encoder(); encoder.encode(source, target, attrs);
6、A smartphone suitable video:
File source = new File("source.avi"); File target = new File("target.3gp"); AudioAttributes audio = new AudioAttributes(); audio.setCodec("libfaac"); audio.setBitRate(new Integer(128000)); audio.setSamplingRate(new Integer(44100)); audio.setChannels(new Integer(2)); VideoAttributes video = new VideoAttributes(); video.setCodec("mpeg4"); video.setBitRate(new Integer(160000)); video.setFrameRate(new Integer(15)); video.setSize(new VideoSize(176, 144)); EncodingAttributes attrs = new EncodingAttributes(); attrs.setFormat("3gp"); attrs.setAudioAttributes(audio); attrs.setVideoAttributes(video); Encoder encoder = new Encoder(); encoder.encode(source, target, attrs);
这里发两个其它的博客地址,大家可以参考下:
http://mfan.iteye.com/blog/2032454
http://blog.csdn.net/qllinhongyu/article/details/29817297
标签:
原文地址:http://my.oschina.net/u/555639/blog/419026