部分mp4不能在google浏览器里面播放需要转码一下

import lombok.extern.slf4j.Slf4j;
import ws.schild.jave.*;

import java.io.File;
import java.util.Date;

@Slf4j
public static void main(String[] args) {
    File source = new File("/Users/sunhongjie/Downloads/DS/VIDEO/22.MP4");
    File target = new File("/Users/sunhongjie/Downloads/DS/VIDEO/2222.MP4");
    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("libx264");
    video.setBitRate(new Integer(800000));
    video.setFrameRate(new Integer(15));
    EncodingAttributes attrs = new EncodingAttributes();
    attrs.setFormat("mp4");
    attrs.setAudioAttributes(audio);
    attrs.setVideoAttributes(video);
    Encoder encoder = new Encoder();
    try {
        log.info("mp4转MP4 --- 转换开始:"+new Date());
        MultimediaObject multimediaObject = new MultimediaObject(source);
        encoder.encode(multimediaObject, target, attrs);
        log.info("mp4转MP4 --- 转换结束:"+new Date());
    } catch (IllegalArgumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (InputFormatException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (EncoderException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

    ws.schild
    jave-core
    2.4.5


    ws.schild
    jave-native-win64
    2.4.5



    ws.schild
    jave-native-osx64
    2.4.5



    ws.schild
    jave-native-linux64
    2.4.5

你可能感兴趣的:(java)