Skip to content

Instantly share code, notes, and snippets.

@eightpigs
Last active June 8, 2020 00:41
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save eightpigs/284db225b8b3bc07b0ffb16cd30469ea to your computer and use it in GitHub Desktop.
Save eightpigs/284db225b8b3bc07b0ffb16cd30469ea to your computer and use it in GitHub Desktop.
#!/bin/bash
clear
cat << EOF
################### 腾讯视频(MacOS)缓存文件合成脚本 ###################
Author: eightpigs <isme@lyinlong.me>
Date: 2018-04-14
EOF
echo -n "=> 准备数据... "
# 生成的目标文件
target=$2
# 源文件(.ts文件的目录)
source='/Users/'$USER'/Library/Containers/com.tencent.tenvideo/Data/Library/Application Support/Download/video/'$1'/'
# 使用时间戳来做临时目录
tmpDir='/tmp/merge_tencent/'`date +%s`'/'
mkdir -p $tmpDir
# 进入到视频的ts目录
cd "$source"
echo "完成"
echo -n "=> 合并文件夹... "
# 将文件递归移动到临时目录
for i in $(find ./ -name '*.ts');
do
cp -vf $i $tmpDir > /dev/null 2>&1;
done
echo "完成"
cd $tmpDir
echo -n "=> 获取需要合成文件数... "
# 总共有多少文件
# 因为ts 文件是有顺序的(文件名)
count=`ls -l $tmpDir |grep "^-"|wc -l | sed 's/[[:space:]]//g'`
echo "完成"
echo -n "=> 合成文件... "
# 按顺序合并
for ((i=0; i<$count; i ++))
do
cat "$tmpDir"$i'.ts'>>"$target"
done
echo "完成"
cat << EOF
结果:
文件数: $count
大小: `ls -lh $target | awk '{print $5}'`
路径:$target
######################################################################
EOF
rm -rf $tmpDir
@eightpigs
Copy link
Author

################### 腾讯视频(MacOS)缓存文件合成脚本 ###################

Author: eightpigs <isme@lyinlong.me>
Date: 2018-04-14

=> 准备数据... 完成
=> 合并文件夹... 完成
=> 获取需要合成文件数... 完成
=> 合成文件... 完成

结果:
    文件数: 732
    大小:  3.8G
    路径:/Users/ep/Downloads/合成.mp4

###################################################################

@DaZhuzhu
Copy link

DaZhuzhu commented Apr 8, 2019

怎么运行这个文件。。。。

@DaZhuzhu
Copy link

DaZhuzhu commented Apr 8, 2019

怎么运行这个文件。。。。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment