一、下载ffmpeg
下载地址:http://www.ffmpeg.org/download.html。下载完成后,解压到自己喜欢的目录。
二、命令行转码(参考https://blog.csdn.net/guojianwei2011/article/details/83242789)
进入上一步解软件目录的bin目录下,输入以下命令即可,
ffmpeg -i “https://xxx/xxx/xxx.m3u8” -vcodec copy -acodec copy -absf aac_adtstoasc /xxx/xxx/xxx.mp4
其中 http://xxx/xxx/xxx.m3u8 视频的m3u8地址, /xxx/xxx/xxx.mp4 为输出mp4的文件目录及文件名
三、Java程序解码(代码仅供参考)
/**
* hilbert.xu 2019-03-01
*/
public class ConvertVideo {
private static final String projectDir = new ApplicationHome(ConvertVideo.class).getDir().toString();
/**
* 视频转化
*
* @param url 视频源地址
* @param ffmpegPath ffmpeg 软件安装目录
* @return
*/
public static Map<String, Object> convertVideo(String url, String ffmpegPath) {
Map<S