-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathedlextract
More file actions
executable file
·53 lines (42 loc) · 1.19 KB
/
edlextract
File metadata and controls
executable file
·53 lines (42 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#! /bin/bash
#
# Marc Groenewegen © 2015
#
if [ $# -lt 1 ]; then
echo "Extract fragment(s) from video file based on markers in edl file"
echo "Usage: $0 videofile"
echo
echo "The name of the edl file is videofile.edl"
exit
fi
INFILE=$1
EXTENSION="${INFILE##*.}"
FILEBASENAME=`basename $INFILE .${EXTENSION}`
EDL_FILE=${FILEBASENAME}.edl
echo $EXTENSION
echo $EDL_FILE
FRAMERATE=`get_framerate $INFILE`
INDEX=1
#
# Dec 2015 - apparently ffmpeg/avconv read from stdin, which caused a
# problem in the loop because it took characters from the start of $line
# Solution / hack: let ffmpeg read from a dummy file
#
cat $EDL_FILE |
while read nextline; do
echo
echo
echo "Line: $nextline"
FROM=`echo $nextline | awk 'BEGIN {FS=" "} {print $1}'`
TO=`echo $nextline | awk 'BEGIN {FS=" "} {print $2}'`
LENGTH=`echo "$TO $FROM - p" | dc`
NROFFRAMES=`echo "$LENGTH $FRAMERATE * 1 / p" | dc`
OUTFILE=${FILEBASENAME}_${INDEX}.${EXTENSION}
echo $OUTFILE
echo "From: $FROM";
echo "To: $TO";
echo "Length: $LENGTH";
echo "Nr of frames: $NROFFRAMES"
ffmpeg -ss $FROM -i $INFILE -frames:v $NROFFRAMES -acodec copy -vcodec copy $OUTFILE < /dev/null
INDEX=`echo "$INDEX 1 + p" | dc`
done