merge_av 此应用程序读入3mang webrtc课堂录像信息文件,根据各音频视频文件的开始和结束时间,运行ffmpeg获取各视频文件的实际时长,对音频文件进行切分,再与视频文件合成。对每段开始音频无视频对应部分,取下一段视频的第一帧图像重复。最后一段无视频对应的音频, 采用blank.jpg的图像与之合成。 各段音视频合成为ts文件后,再拼接。最后把拼接后的ts文件再重新转换时间戳。所有这些操作都是调用ffmpeg命令完成的,因此merge_av程序运行需要确保ffmpeg所在路径添加在系统执行路径环境变量里。 运行示例: merge_av uid_284176605_20171127113703805.txt 其中uid_284176605_20171127113703805.txt内容如下: 0.000 284176605_20171127113703805.aac create 1.681 284176605_20171127113705486.webm create 1.682 284176605_20171127113705486.webm info width=320 height=240 rotation=0 24.933 284176605_20171127113705486.webm close 27.729 284176605_20171127113731534.webm create 27.730 284176605_20171127113731534.webm info width=320 height=240 rotation=0 859.989 284176605_20171127113731534.webm close 895.640 284176605_20171127115159445.webm create 895.641 284176605_20171127115159445.webm info width=320 height=240 rotation=0 961.164 284176605_20171127115159445.webm close 964.639 284176605_20171127115308444.webm create 964.640 284176605_20171127115308444.webm info width=320 height=240 rotation=0 2770.511 284176605_20171127115308444.webm close 2780.447 284176605_20171127113703805.aac close 1.0.6之前版本: merge_av读入上述内容,解析后依次执行如下命令,最终生成dest.ts文件,是合成后是音视频文件,(各临时文件缺省删除,可以添加-k 参数保留,如merge_av uid_284176605_20171127113703805.txt -k) 这些命令可以通过 "merge_av uid_284176605_20171127113703805.txt -p"输出查看(-p就是只打印命令,不执行) : ;获取视频视频时长 ffmpeg -y -i 284176605_20171127113705486.webm -vcodec copy -an 284176605_20171127113705486.webm.mkv ffmpeg -i 284176605_20171127113705486.webm.mkv &> 284176605_20171127113705486.webm.txt #file:284176605_20171127113705486.webm , duration in recording file: 23.252, duration parsed from file: 23.170 ffmpeg -y -i 284176605_20171127113731534.webm -vcodec copy -an 284176605_20171127113731534.webm.mkv ffmpeg -i 284176605_20171127113731534.webm.mkv &> 284176605_20171127113731534.webm.txt file:284176605_20171127113731534.webm , duration in recording file: 832.260, duration parsed from file: 815.920 ffmpeg -y -i 284176605_20171127115159445.webm -vcodec copy -an 284176605_20171127115159445.webm.mkv ffmpeg -i 284176605_20171127115159445.webm.mkv &> 284176605_20171127115159445.webm.txt #file:284176605_20171127115159445.webm , duration in recording file: 65.524, duration parsed from file: 65.440 ffmpeg -y -i 284176605_20171127115308444.webm -vcodec copy -an 284176605_20171127115308444.webm.mkv ffmpeg -i 284176605_20171127115308444.webm.mkv &> 284176605_20171127115308444.webm.txt #file:284176605_20171127115308444.webm , duration in recording file: 1805.872, duration parsed from file: 1801.090 ;切分,合成 ffmpeg -y -i 284176605_20171127113703805.aac -ss 0.000 -t 1.681 -acodec copy 0_284176605_20171127113703805.aac ffmpeg -y -i 284176605_20171127113705486.webm -vframes 1 -ss 0 -f mjpeg -an 284176605_20171127113705486.webm.jpg ffmpeg -y -loop 1 -i 284176605_20171127113705486.webm.jpg -i 0_284176605_20171127113703805.aac -loop 0 -shortest -acodec copy -vcodec libx264 -level 3.1 -preset veryfast -g 40 -r 20 0.ts ffmpeg -y -i 284176605_20171127113703805.aac -ss 1.681 -t 23.170 -acodec copy 1_284176605_20171127113703805.aac ffmpeg -y -i 1_284176605_20171127113703805.aac -i 284176605_20171127113705486.webm -acodec copy -vcodec libx264 -level 3.1 -preset veryfast -g 40 -r 20 1.ts ffmpeg -y -i 284176605_20171127113703805.aac -ss 24.851 -t 2.878 -acodec copy 2_284176605_20171127113703805.aac ffmpeg -y -i 284176605_20171127113731534.webm -vframes 1 -ss 0 -f mjpeg -an 284176605_20171127113731534.webm.jpg ffmpeg -y -loop 1 -i 284176605_20171127113731534.webm.jpg -i 2_284176605_20171127113703805.aac -loop 0 -shortest -acodec copy -vcodec libx264 -level 3.1 -preset veryfast -g 40 -r 20 2.ts ffmpeg -y -i 284176605_20171127113703805.aac -ss 27.729 -t 815.920 -acodec copy 3_284176605_20171127113703805.aac ffmpeg -y -i 3_284176605_20171127113703805.aac -i 284176605_20171127113731534.webm -acodec copy -vcodec libx264 -level 3.1 -preset veryfast -g 40 -r 20 3.ts ffmpeg -y -i 284176605_20171127113703805.aac -ss 843.649 -t 51.991 -acodec copy 4_284176605_20171127113703805.aac ffmpeg -y -i 284176605_20171127115159445.webm -vframes 1 -ss 0 -f mjpeg -an 284176605_20171127115159445.webm.jpg ffmpeg -y -loop 1 -i 284176605_20171127115159445.webm.jpg -i 4_284176605_20171127113703805.aac -loop 0 -shortest -acodec copy -vcodec libx264 -level 3.1 -preset veryfast -g 40 -r 20 4.ts ffmpeg -y -i 284176605_20171127113703805.aac -ss 895.640 -t 65.440 -acodec copy 5_284176605_20171127113703805.aac ffmpeg -y -i 5_284176605_20171127113703805.aac -i 284176605_20171127115159445.webm -acodec copy -vcodec libx264 -level 3.1 -preset veryfast -g 40 -r 20 5.ts ffmpeg -y -i 284176605_20171127113703805.aac -ss 961.080 -t 3.559 -acodec copy 6_284176605_20171127113703805.aac ffmpeg -y -i 284176605_20171127115308444.webm -vframes 1 -ss 0 -f mjpeg -an 284176605_20171127115308444.webm.jpg ffmpeg -y -loop 1 -i 284176605_20171127115308444.webm.jpg -i 6_284176605_20171127113703805.aac -loop 0 -shortest -acodec copy -vcodec libx264 -level 3.1 -preset veryfast -g 40 -r 20 6.ts ffmpeg -y -i 284176605_20171127113703805.aac -ss 964.639 -t 1801.090 -acodec copy 7_284176605_20171127113703805.aac ffmpeg -y -i 7_284176605_20171127113703805.aac -i 284176605_20171127115308444.webm -acodec copy -vcodec libx264 -level 3.1 -preset veryfast -g 40 -r 20 7.ts ffmpeg -y -i 284176605_20171127113703805.aac -ss 2765.729 -t 14.718 -acodec copy 8_284176605_20171127113703805.aac ffmpeg -y -loop 1 -i /home/hubin/merge_av/blank.jpg -i 8_284176605_20171127113703805.aac -loop 0 -shortest -acodec copy -vcodec libx264 -level 3.1 -preset veryfast -g 40 -r 20 8.ts copy /B 0.ts + /B 1.ts + /B 2.ts + /B 3.ts + /B 4.ts + /B 5.ts + /B 6.ts + /B 7.ts +/B 8.ts m.ts ;windows cat 0.ts 1.ts 2.ts 3.ts 4.ts 5.ts 6.ts 7.ts 8.ts> m.ts ;linux ffmpeg -y -i m.ts -acodec copy -vcodec copy dest.ts 1.0.7 读入uid_322641689_20171226123032334.txt,把其中 0.000 322641689_20171226123032334.aac create 0.861 322641689_20171226123033194.webm create 0.861 322641689_20171226123033194.webm info width=320 height=240 rotation=0 44.875 322641689_20171226123032334.aac close 45.178 322641689_20171226123117511.aac create 108.525 322641689_20171226123117511.aac close 109.926 322641689_20171226123033194.webm close 115.278 322641689_20171226123227612.aac create 115.675 322641689_20171226123228008.webm create 115.677 322641689_20171226123228008.webm info width=320 height=240 rotation=0 1669.684 322641689_20171226123228008.webm close 1684.435 322641689_20171226123227612.aac close 生成uid_322641689_20171226123032334_out.txt,其中内容如下,每一行依次为开始时间,时长,合成的ts文件名。 0.000 108.610 322641689_20171226_0.ts 115.278 1569.190 322641689_20171226_1.ts 调用ffmpeg时,视频编码参数是: -vcodec libx264 -level 3.1 -preset veryfast -g 100 -r 20 -bf 0 -vsync cfr 如果源视频编码是h264,则缺省不做转码,-vcodec copy 音频编码参数是: -acodec copy 如果要修改,windows下在merge_av.exe同目录下新建merge_av.cfg文本文件,第一行保存视频编码,第二行保存音频编码;linux 下,merge_av.cfg保存在HOME目录下的merge_av目录。 对于录像文件只有音频的情况,merge_av把音频与blank.jpg合并成视频文件。blank.jpg 在windows系统里,与merge_av.exe放在同一目录。在linux下,放在HOME目录下的merge_av目录。 例如: uid_61712260_20171122130331754.txt内容如下: 0.000 61712260_20171122130331753.aac create 1366.801 61712260_20171122130331753.aac close 运行mergeav uid_61712260_20171122130331754.txt执行的命令是,linux下,HOME目录为/home/hubin windows(假定merge_av.exe在d:\Merge_av目录): ffmpeg -y -loop 1 -i D:\Merge_av\blank.jpg -i 61712260_20171122130331753.aac -loop 0 -shortest -acodec copy -vcodec libx264 -level 3.1 -preset veryfast -g 40 -r 20 dest.ts linux(linux下,假定HOME目录为/home/hubin): ffmpeg -y -loop 1 -i /home/hubin/merge_av/blank.jpg -i 61712260_20171122130331753.aac -loop 0 -shortest -acodec copy -vcodec libx264 -level 3.1 -preset veryfast -g 40 -r 20 dest.ts -c 把输入文件转换为ts,不做合并处理(输入的是音视频都存在的mp4文件) -t 如果视频是h264,也做转码。
M
merge_av_release
merge_av的编译版本
在 提交了
·
7d320fa6