Last active
March 2, 2020 08:00
-
-
Save void285/76baaf1a5a94dece94c877cca42f86cb to your computer and use it in GitHub Desktop.
自动合并哔哩哔哩官方客户端下载的flv格式分段视频。直接合并,不重编码。放到可执行目录下后,cd到分段视频所在目录,执行即可。如需要可指定保存文件名。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# ########### | |
# | |
# put the file at any executable path, cd to the video path, and do the cmd below: | |
# | |
# cmd format: bilibili.sh filename [1] | |
# | |
# filename is the output name of the video/audio | |
# if the optional arg is 1, an audio file will be extractd from the generated video file | |
# | |
# ########### | |
# get output file name | |
name=output | |
if [ -n "$1" ];then | |
name=$1 | |
fi | |
v="${name}.mkv" | |
# rm filelist.txt to prevent repeation | |
if [ -f filelist.txt ];then | |
rm filelist.txt | |
fi | |
# generate concat file | |
for flv in `ls -tr *.flv` | |
do | |
echo $flv | |
echo "file '"$flv"'" >> filelist.txt | |
done | |
# concat the video | |
if [ ! -n "$v" ];then | |
ffmpeg -f concat -i filelist.txt -c copy "${name}.mkv" | |
fi | |
# extract audio | |
if [ -n "$2" ] && [ "$2" == "1" ];then | |
ffmpeg -i "$v" -vn -y -acodec copy "${name}.aac" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment