1 2 3 4 5 6 | <!-- mov 转换 mp4 --> <dependency> <groupId>ws.schild</groupId> <artifactId>jave-all-deps</artifactId> <version>3.0.1</version> </dependency> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | public static void main(String[] args) {<!-- --> File source = new File("D:\\mov视频文件\\视频\\视频\\IMG_0604.MOV"); File target = new File("D:\\mov视频文件\\视频\\视频\\IMG_0604-target.mp4"); try {<!-- --> AudioAttributes audio = new AudioAttributes(); audio.setCodec("libmp3lame"); audio.setBitRate(new Integer(800000));//设置比特率 audio.setChannels(new Integer(1));//设置音频通道数 audio.setSamplingRate(new Integer(44100));//设置采样率 VideoAttributes video = new VideoAttributes(); // video.setCodec("mpeg4"); video.setCodec("libx264"); video.setBitRate(new Integer(3200000)); video.setFrameRate(new Integer(15)); EncodingAttributes attrs = new EncodingAttributes(); attrs.setOutputFormat("mp4"); attrs.setAudioAttributes(audio); attrs.setVideoAttributes(video); Encoder encoder = new Encoder(); encoder.encode(new MultimediaObject(source), target, attrs); } catch (Exception e) {<!-- --> e.printStackTrace(); } } |