Skip to content

Instantly share code, notes, and snippets.

@ryanfb
Created August 26, 2014 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanfb/311ac8ee04cf5c4af11a to your computer and use it in GitHub Desktop.
Save ryanfb/311ac8ee04cf5c4af11a to your computer and use it in GitHub Desktop.
Script to convert and join a directory of youtube-dl flv files from Twitch to mp4 for upload/archiving to YouTube
#!/bin/bash
function join { local IFS="$1"; shift; echo "$*"; }
outfile="$(basename "$(ls -1 *.flv|head -1)" .flv).mp4"
if [ ! -f outfile ]; then
i=0
lnfiles=()
for j in *.flv; do
echo $j
targetfile="file$i.flv"
ln -sv "$j" $targetfile
lnfiles[$i]=$targetfile
i=$(($i+1))
done
declare -p lnfiles
ffmpeg -n -i "concat:$(join "|" ${lnfiles[@]})" -threads 0 "$outfile"
for lnfile in "${lnfiles[@]}"; do
rm -v $lnfile
done
else
echo $outfile exists, skipping
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment