forked from patrickward/osx-timelapse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextract-panopticon-video
More file actions
executable file
·92 lines (71 loc) · 2.91 KB
/
Copy pathextract-panopticon-video
File metadata and controls
executable file
·92 lines (71 loc) · 2.91 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
#
# Create timelapse movies from images in the output/screen and output/isight folders
#
SOURCES=( screen webcam )
#output_dir="output"
output_dir=$1
mkdir -p ${output_dir}/videos
#FFMPEG_BIN="ffmpeg -loglevel warning -y "
FFMPEG_BIN="ffmpeg -loglevel panic -y "
#FFMPEG_BIN="ffmpeg -y "
VIDEO_HEIGHT=360
stream_width() {
ffprobe -v error -of flat=s=_ -select_streams v:0 -show_entries stream=width $1 | awk -F= '{print $2}'
}
stream_height() {
ffprobe -v error -of flat=s=_ -select_streams v:0 -show_entries stream=height $1 | awk -F= '{print $2}'
}
for src in "${SOURCES[@]}"
do
echo "Building $src video from raw images"
COUNTER=0;
rm -f ${output_dir}/$src/series/*.jpg
mkdir -p ${output_dir}/$src/series/
for i in `find ${output_dir}/$src -name '*.jpg'` ;
do
# Write the filename to be friendly with ffmpeg's old filename input
FILENAME=`printf '%09d.jpg' $COUNTER`
echo "Copying $i to ${output_dir}/$src/series/$FILENAME"
cp $i ${output_dir}/$src/series/$FILENAME
let COUNTER=COUNTER+1;
done
vheight=${VIDEO_HEIGHT}
if [ "$src" == "webcam" ]; then
vheight=180
fi
nice ${FFMPEG_BIN} -i ${output_dir}/$src/series/%9d.jpg -vf scale=-1:${vheight} ${output_dir}/videos/timelapse-$src.mov
rm -f ${output_dir}/$src/series/*.jpg
done
video_webcam="${output_dir}/videos/timelapse-webcam.mov"
video_webcam_padded="${output_dir}/videos/timelapse-webcam-padded.mov"
video_screen="${output_dir}/videos/timelapse-screen.mov"
video_screen_padded="${output_dir}/videos/timelapse-screen-padded.mov"
video_timelapse="${output_dir}/videos/timelapse.mov"
video_screen_width=$(stream_width ${video_screen})
video_webcam_width=$(stream_width ${video_webcam})
video_screen_height=$(stream_height ${video_screen})
video_webcam_height=$(stream_height ${video_webcam})
pad_width=${video_screen_width}
pad_pos=$((${video_screen_width}/2 - ${video_webcam_width}/2))
#echo "video_screen_width: ${video_screen_width}"
#echo "video_webcam_width: ${video_webcam_width}"
#echo "pad_width: ${pad_width}"
#echo "pad_pos: ${pad_pos}"
if [ $(($pad_pos > 0)) -eq 1 ]; then
# pad webcam video
echo "Adding padding to webcam video"
nice ${FFMPEG_BIN} -i ${video_webcam} -vf "pad=width=${pad_width}:height=${video_webcam_height}:x=${pad_pos}:y=0:color=black" ${video_webcam_padded}
cp ${video_webcam_padded} ${video_webcam}
elif [ $(($pad_pos < 0)) -eq 1 ]; then
# pad screen video
echo "Adding padding to screen video"
pad_width=${video_webcam_width}
pad_pos=$((${video_webcam_width}/2 - ${video_screen_width}/2))
nice ${FFMPEG_BIN} -i ${video_screen} -vf "pad=width=${pad_width}:height=${video_screen_height}:x=${pad_pos}:y=0:color=black" ${video_screen_padded}
cp ${video_screen_padded} ${video_screen}
elif [ $(($pad_pos == 0)) -eq 1 ]; then
echo "webcam equal to screen"
fi
# build stacked timelapse video
nice ${FFMPEG_BIN} -i ${video_webcam} -i ${video_screen} -filter_complex vstack ${video_timelapse}