You are not logged in.
Pages: 1
Videosplit is something I wrote earlier today for an experiment working with videos that were simply too long for youtube to allow me to upload them. I present the code bellow. It's only dependency should be mencoder, but if anyone has any information on a dependency I missed I will update my comments.
#!/bin/bash
if [ ! -f "$1" ]; then
echo "Error, usage: $0 <VIDEO_INPUT> [ <video length> [ <repeat length> ]]";
exit;
fi
VIDEOIN="$1"
if [ -z "$3" ]; then
OVER=30
else
OVER=$(echo "$3" | grep -o \[0-9\]* | head -n 1)
fi
if [ -z "$2" ]; then
CHUNK=570
else
CHUNK=$[ $(echo "$2" | grep -o \[0-9\]* | head -n 1) - $OVER];
if [ $CHUNK <= 0]; then
echo 'Error, repeat length is too large';
exit;
fi
fi
eval "VIDLEN$(mplayer -identify "$VIDEOIN" -ao null -vo null -frames 0 2>/dev/null |
grep ^ID_LENGTH | grep -o =\[0-9\]*)";
if [ "$VIDLEN" = "" ]; then
echo "Not a video, exiting.";
exit;
fi
PARTS=$[ ( $VIDLEN / $CHUNK ) ];
if [[ $PARTS = "0" ]]; then
echo "No work to be done";
exit
fi;
EXT=$(echo "$VIDEOIN" | grep -o '[^.]*$');
FNAME=$(basename "$VIDEOIN" | grep -o '.*[.]');
OPTIONS='-ovc copy -oac';
if [ "$EXT" = "mp4" ]; then
OPTIONS="$OPTIONS pcm";
else
OPTIONS="$OPTIONS copy";
fi
END=$[ $CHUNK + $OVER ];
for i in $(seq 0 $PARTS); do
echo "part $i";
START=$[ $i * $CHUNK ];
mencoder "$VIDEOIN" \
-o "${FNAME}${i}.${EXT}" \
$OPTIONS \
-ss $START \
-endpos $END >/dev/null
done
Offline
Pages: 1