This commit is contained in:
alban 2019-10-02 21:53:11 +02:00
parent ac50292883
commit ed6d6e367c
2 changed files with 79 additions and 3 deletions

73
README.md Normal file
View File

@ -0,0 +1,73 @@
#Time lapse using phone
**Goal** : upcycle an old phone into an IP Webcam and then make time lapse.
**Hardware :**
- and old phone
- a strong stand for your phone, use clamps and metal sticks
- a WIFI network
- a PC always on (server, raspberry, old laptop)
- free space on the PC hard drive
**Requirement :**
- a linux like system
- python
- ffmpeg
##Installation of IP Webcam
- get an old phone
- setup Wifi on the phone
**Install an IP Webcam software on it**
- using Google play : (not tested)
add your credential and install IPWebcam from google play
- without :
get the APK from :
\url{https://apkpure.com/ip-webcam/com.pas.webcam/versions}
On my android 6 I had to use IP Webcam\_v1.13.25
\url{https://apkpure.com/ip-webcam/com.pas.webcam/download/608-APK?from=versions%2Fversion}
##Using IP Webcam
**On Mobile**
- Setup the camera settings
- Setup the network settings, notice the capture image URL : \url{http://192.168.?.?:8080/photo.jpg}
- Position the phone and start the server
**On the PC**
- From your PC open the capture image URL \url{http://192.168.?.?:8080/photo.jpg}
- You should see if it works
##Picture automation
###Using the python script
$ python capture.py <directory> <delay> <resolution>
current script take 1 picture and save it as last.jpg
it also make a copy of this image, convert it to smaller resolution and save it with an timestamp name
you can change line resolution = "1280x960"
##Produce the timelapse
$ bash makevideo.sh -d <directory> -s <rate> -p <prefix> -v <video_dir> -s <size>
——————————————————————————————————————————————————————————————————————————————————
Opt | Variable | Type | Definition | Default value
——————————————————————————————————————————————————————————————————————————————————
-d directory path Directory path of images to convert ./pics
-r rate int Convert only 1/N images 1
-p prefix str Images filename prefix. ''
-v video_dir path Directory path to store video file. ./videos
-s size str Images geometry. '1024x768'
——————————————————————————————————————————————————————————————————————————————————
Will save an mp4

View File

@ -2,7 +2,7 @@
usage(){ usage(){
cat << EOF cat << EOF
$(basename $0) -d <directory> -s <rate> -p <prefix> -v <video_dir> $(basename $0) -d <directory> -s <rate> -p <prefix> -v <video_dir> -s <size>
—————————————————————————————————————————————————————————————————————————————————— ——————————————————————————————————————————————————————————————————————————————————
Opt | Variable | Type | Definition | Default value Opt | Variable | Type | Definition | Default value
@ -73,6 +73,9 @@ video_dir="$( realpath ${video_dir} 2>/dev/null )/"
} }
[ -n "$( ls ${directory}/${prefix}* 2>/dev/null)" ] || panic "${directory}/${prefix}\* doesn't match any file. Exiting." [ -n "$( ls ${directory}/${prefix}* 2>/dev/null)" ] || panic "${directory}/${prefix}\* doesn't match any file. Exiting."
# Set video file name
date=$(date +%s) date=$(date +%s)
ffmpeg -pattern_type glob -i "pics/*.jpg" -filter:v "setpts=(${pts})*PTS" -pix_fmt yuv420p -s "${size}" -vcodec libx264 "${video_dir}/$date.mp4" video_file="${video_dir}$date.mp4"
echo -e "\nSaving to video file $video_file.\n"
ffmpeg -hide_banner -loglevel quiet -stats -pattern_type glob -i "pics/*.jpg" -filter:v "setpts=(${pts})*PTS" -pix_fmt yuv420p -s "${size}" -vcodec libx264 "${video_file}"