Skip to content

Instantly share code, notes, and snippets.

@CFM880
Last active May 21, 2019 06:03
Show Gist options
  • Save CFM880/ad24dbbda784d93a1e02b404ccf15070 to your computer and use it in GitHub Desktop.
Save CFM880/ad24dbbda784d93a1e02b404ccf15070 to your computer and use it in GitHub Desktop.
根据id对应的视频文件下载对应的视频文件保存为id.mp4,同时生成局域网流媒体对应的json配置
#!/usr/bin/env bash
devices_info=`adb devices`
echo $devices_info
devices_info=`echo ${devices_info} | sed 's/^List of devices attached//'`
devices_info=(${devices_info})
device_names=""
for(( i=0;i<${#devices_info[@]};i++));
do
if [ $((i%2)) == 0 ]; then
device_names=${device_names}" "${devices_info[i]}
fi
done
real_devices=(${device_names})
for(( i=0;i<${#real_devices[@]};i++));
do
echo ${real_devices[i]}
adb -s ${real_devices[i]} push video_config.json /sdcard/spax_video/video_local.json
adb -s ${real_devices[i]} shell cat /sdcard/spax_video/video_local.json | jq
done
#!/usr/bin/env bash
video_config=video_config.json
# 获得IP地址
server_ip=`/sbin/ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"`
echo "{" > ${video_config}
cat id_with_url.txt | while read line
do
temp=`echo "${line}" | grep -Eo '[0-9]+\t'`
id=`echo ${temp} | sed "s/[ \t]*$//g"`
http=`echo "${line}" | grep -Eo 'http://.*$'`
wget -c -O ../video/${id}.mp4 ${http}
echo " \"${id}\": \"http://${server_ip}:8080/${id}.mp4\"," >> ${video_config}
done
# 最后一行需要删除,
json=`sed '$ s/.$//' ${video_config}`
echo ${json} > ${video_config}
echo "}" >> ${video_config}
cat ${video_config} | jq > new_video_config.json
mv new_video_config.json ${video_config}
./adb_options.sh
100452 http://xxx/f0.mp4
100456 http://xxx/f0.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment