Last active
April 17, 2019 06:24
-
-
Save RicherMans/f851d54db3962df40c2a0a5fbf69d85d to your computer and use it in GitHub Desktop.
Split video file into audio / video indep. components
This file contains hidden or 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
#!/usr/bin/env bash | |
if [[ $# -lt 2 ]]; then | |
echo "Input Flist and Output dir" | |
exit | |
fi | |
module load parallel | |
module load ffmpeg | |
scp_file=$1 | |
output_dir=$2 | |
scale=${3:-256} | |
fps=${4:-30} | |
audio_outputdir=${output_dir}"/audio" | |
video_outputdir=${output_dir}"/video" | |
mkdir -p ${audio_outputdir} ${video_outputdir} | |
export audio_outputdir video_outputdir scale fps | |
function extract() { | |
scp_line=$1 | |
path=$(echo $scp_line | awk '{print $2}') | |
fname=$(basename $path ".mp4") | |
ffmpeg -loglevel quiet -i $path -vn -acodec pcm_s16le -ac 1 -y $audio_outputdir/$fname".wav" | |
ffmpeg -loglevel quiet -i $path -vf "scale=${scale}:${scale},fps=${fps}" -an -y $video_outputdir/$fname".mp4" | |
} | |
export -f extract | |
cat $scp_file | parallel --eta extract |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment