使用Java将wmv文件转码为mp4

时间:2012-04-13 09:33:35

标签: ffmpeg mp4 transcoding

我正在尝试使用Jave将wmv文件转换为h264(mp4)。 由Jave创建的最终版本可以很好地使用VLC播放器,但是当我尝试在HTML5视频标签中使用它时,它无法播放该文件。

我猜这个问题与我为视频属性设置的属性有关。

Java代码:

    videoAttributes.setCodec("mpeg4");
    videoAttributes.setTag("mpeg4");
    videoAttributes.setBitRate(new Integer(5000));
    videoAttributes.setFrameRate(new Integer(30));
    videoAttributes.setSize(new VideoSize(512, 384));
    encodingAttributes.setVideoAttributes(videoAttributes);
    encodingAttributes.setFormat("mp4");

HTML code:

    <video controls="true" width=400 height=200>
        <source src="path_to_converted_mp4_file" type="video/mp4" />
        Not Supported
    </video>

2 个答案:

答案 0 :(得分:1)

不知道Jave如何识别编解码器,但如果它使用与FFmpeg相同的命名,则HTML5的编解码器应为libx264。根据{{​​1}},mpeg4编解码器是“MPEG-4第2部分”。

ffmpeg -codecs

答案 1 :(得分:0)

根据JAVE文档,格式名称为“mp4”而非“mpeg4”