Skip to content

Commit

Permalink
Add creation datetime to output
Browse files Browse the repository at this point in the history
  • Loading branch information
jburnhams authored and time4tea committed Sep 8, 2024
1 parent 57ac4e1 commit 7768cf4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
6 changes: 4 additions & 2 deletions bin/gopro-dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@ def fmtdt(dt: datetime.datetime):
output=output,
options=ffmpeg_options,
overlay_size=dimensions,
execution=execution
execution=execution,
creation_time=frame_meta.date_at(frame_meta.min)
)
else:
output.unlink(missing_ok=True)
Expand All @@ -328,7 +329,8 @@ def fmtdt(dt: datetime.datetime):
output=output,
options=ffmpeg_options,
overlay_size=dimensions,
execution=execution
execution=execution,
creation_time=frame_meta.date_at(frame_meta.min)
)

draw_timer = PoorTimer("drawing frames")
Expand Down
11 changes: 9 additions & 2 deletions gopro_overlay/ffmpeg_overlay.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import contextlib
import datetime
from pathlib import Path

from gopro_overlay.dimensions import Dimension
Expand Down Expand Up @@ -42,11 +43,13 @@ def __init__(
output: Path,
overlay_size: Dimension,
options: FFMPEGOptions = None,
execution=None
execution=None,
creation_time: datetime.datetime = None
):
self.exe = ffmpeg
self.output = output
self.overlay_size = overlay_size
self.creation_time = creation_time if creation_time else datetime.datetime.now()
self.execution = execution if execution else InProcessExecution()
self.options = options if options else FFMPEGOptions()

Expand All @@ -63,6 +66,7 @@ def generate(self):
"-i", "-",
"-r", "30",
self.options.output,
"-metadata", f"creation_time={self.creation_time.isoformat()}",
str(self.output)
])

Expand All @@ -78,13 +82,15 @@ def __init__(
output: Path,
overlay_size: Dimension,
options: FFMPEGOptions = None,
execution=None
execution=None,
creation_time: datetime.datetime = None
):
self.exe = ffmpeg
self.output = output
self.input = input
self.options = options if options else FFMPEGOptions()
self.overlay_size = overlay_size
self.creation_time = creation_time if creation_time else datetime.datetime.now()
self.execution = execution if execution else InProcessExecution()

@contextlib.contextmanager
Expand All @@ -101,6 +107,7 @@ def generate(self):
"-i", "-",
"-filter_complex", self.options.filter_complex,
self.options.output,
"-metadata", f"creation_time={self.creation_time.isoformat()}",
str(self.output)
])

Expand Down

0 comments on commit 7768cf4

Please sign in to comment.