前提:1.maven工程一个
2.avi视频一个
第一步:
通过pom.xml导入jave相关包
<dependency> <groupId>ws.schild</groupId> <artifactId>jave-core</artifactId> <version>2.4.5</version> </dependency>
<dependency> <groupId>ws.schild</groupId> <artifactId>jave-native-win64</artifactId> <version>2.4.5</version> </dependency>
第二步:
示例:
File source = new File("d://123.avi"); //源avi格式视频 File target = new File("d://456.mp4"); //转换后的mp4格式视频 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("libx264");//视频编码格式 video.setBitRate(new Integer(180000)); video.setFrameRate(new Integer(1)); EncodingAttributes attrs = new EncodingAttributes(); attrs.setFormat("mp4"); attrs.setAudioAttributes(audio); attrs.setVideoAttributes(video); Encoder encoder = new Encoder(); MultimediaObject multimediaObject = new MultimediaObject(source); encoder.encode(multimediaObject, target, attrs);//转换开始。。。