dadiyang / jave

音频转码工具,主要用于将微信语音 amr 格式转换为 mp3 格式以便在 html5 的 audio 标签中进行播放
GNU General Public License v2.0
217 stars 72 forks source link

建议:新增VideoUtils工具类,同时更新FFMPEG文件到较为新的版本,旧版本scale分辨率调整的功能会用不了 #3

Closed lynk-coder closed 5 years ago

lynk-coder commented 5 years ago

代码如下

public class VideoUtils { public static void getVedioThumbnail(File source, File imageTarget, float frameTime) throws IllegalArgumentException, EncoderException {

    if (!source.exists()) {
        throw new IllegalArgumentException("source file does not exists: " + source.getAbsoluteFile());
    }
    Encoder encoder = new IgnoreErrorEncoder();

    MultimediaInfo multimediaInfo = encoder.getInfo(source);
    VideoAttributes video = new VideoAttributes();
    EncodingAttributes attrs = new EncodingAttributes();
    attrs.setFormat("image2");
    attrs.setOffset(frameTime);
    attrs.setDuration(1f);
    attrs.setVideoAttributes(video);
    try {
        encoder.encode(source, imageTarget, attrs);
    } catch (Exception e) {
        throw new IllegalStateException("error: ", e);
    }

}

}

dadiyang commented 5 years ago

方便提一下PR吗?

lynk-coder commented 5 years ago

哥们,本机没有弄GIT,不好意思哈。

dadiyang commented 5 years ago

好的。我晚点评估一下。感谢!

lynk-coder commented 5 years ago

ffmepg可以挖掘的东西非常多,加油哈。尽量做全点,使用的人也会越来越多

dadiyang commented 5 years ago

嗯嗯。需要大家共同努力。有需求尽管提。

lynk-coder commented 5 years ago

比如修改视频宽高,包里的ffmpeg版本没办法做到伸缩。必须通过width,height去处理,但是width、height必须计算精确,稍微有点偏差都不能生成新的视频。 参考新的option -vf scale=x:-1

dadiyang commented 5 years ago

视频工具类已添加。FFMPEG我这边只使用过音频转换的功能,没用过更多的场景。高版本的包你那里有吗?方便分享一下吗?

lynk-coder commented 5 years ago

不好意思,最近回老家办事。具体的文件我这里没有。要花点时间去编译

在2019年03月21日 21:57,Huang Xuyang 写道:

视频工具类已添加。FFMPEG我这边只使用过音频转换的功能,没用过更多的场景。高版本的包你那里有吗?方便分享一下吗?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.