Use timestamp from image EXIF
This commit is contained in:
parent
e441b4880f
commit
ede8a4cd48
17
main.go
17
main.go
@ -136,14 +136,22 @@ func filesToSequenceFile(fname string, files []string) { // {{{
|
||||
}
|
||||
}
|
||||
} // }}}
|
||||
func updateEXIFTimestamp(files []string) { // {{{
|
||||
for _, f := range files {
|
||||
t := filenameToTime(f, true)
|
||||
fmt.Printf("exif for %s\n", f)
|
||||
exiftool := exec.Command("exiftool", "-CreateDate="+t.Format("2006-01-02 15:04"), "-overwrite_original", f)
|
||||
exiftool.Run()
|
||||
}
|
||||
} // }}}
|
||||
func timelapse(date string, files []string) { // {{{
|
||||
sequenceFile := fmt.Sprintf("/tmp/timelapse/sequence_%s", date)
|
||||
videoFile := fmt.Sprintf("/tmp/timelapse/video_%s.mp4", date)
|
||||
text := fmt.Sprintf("drawtext=text='%s':fontsize=30:x=10:y=10:fontcolor=#71b045:bordercolor=black:borderw=1", date)
|
||||
text := `drawtext=text='%{metadata\:DateTimeDigitized}':fontsize=30:x=10:y=10:fontcolor=#71b045:bordercolor=black:borderw=1`
|
||||
|
||||
filesToSequenceFile(sequenceFile, files)
|
||||
os.Remove(videoFile)
|
||||
ffmpeg := exec.Command("ffmpeg", "-safe", "0", "-f", "concat", "-i", sequenceFile, "-filter_complex", text, "-framerate", framerate, "-c:v", "libx264", "-crf", "23", videoFile)
|
||||
ffmpeg := exec.Command("ffmpeg", "-r", framerate, "-safe", "0", "-f", "concat", "-i", sequenceFile, "-filter_complex", text, "-c:v", "libx264", "-crf", "23", videoFile)
|
||||
out, err := ffmpeg.CombinedOutput()
|
||||
if err != nil {
|
||||
fmt.Printf("%s\n", out)
|
||||
@ -180,6 +188,11 @@ func main() {
|
||||
for date, files := range *sortedDays {
|
||||
fmt.Printf("Create timelapse for %s\n", date)
|
||||
dates = append(dates, date)
|
||||
// This is now done when downloading the image from the camera,
|
||||
// since it takes too damn long time when running this program.
|
||||
// It is preserved for the times when the source images are missing
|
||||
// the EXIF data.
|
||||
// updateEXIFTimestamp(files)
|
||||
timelapse(date, files)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user