Last active
November 9, 2020 02:32
-
-
Save Matthew238/3eee437dc505c708014df3f0171b9b62 to your computer and use it in GitHub Desktop.
A convert shell script from ts to mp4 with VLC
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 | |
vlc="/mnt/c/Program\ Files/VideoLAN/VLC/vlc.exe" | |
directory="tvrec" | |
lin_directory="/mnt/f/"$directory | |
win_directory="f:\\"$directory | |
src_ext="ts" | |
dst_ext="mp4" | |
files=$lin_directory"/*."$src_ext | |
#filearr=() | |
MAX_FILES=${1:-100} | |
file_counter=0 | |
for file_path in $files ; do | |
if [ -f "$file_path" ] ; then | |
file_full_name="${file_path##*/}" | |
file_name=("${file_full_name%.*}") | |
file_counter=$((file_counter + 1)) | |
if [ ! -f "$lin_directory/$file_name.$dst_ext" ] ; then | |
command=$vlc" -I dummy \"$win_directory\\$file_name.$src_ext\" --sout='#transcode{vcodec=h264,vb=1024,scale=1,deinterlace,audio-sync}:standard{access=file,mux="$dst_ext",dst=\""$win_directory\\$file_name.$dst_ext\""}' vlc://quit" | |
echo $file_counter : $file_name | |
eval $command | |
if [ $file_counter -ge $MAX_FILES ] ; then | |
break | |
fi | |
else | |
echo $file_counter : $file_name : skipped. | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Rev 4 : This change can show a progress number and a processing file name each processing.
Rev 5 : This script skips a convert process if there is already the mp4 file that is converted to.
Rev 6 : Done refactoring and adding an argument to give a maximum number of times to convert.