Skip to content

Commit d9897d4

Browse files
committed
Make movie FPS configurable
1 parent c271114 commit d9897d4

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ Option `--encode` (added by default, use `--no-encode` to disable).
150150

151151
In the case of time-lapse experiments, remixes of consecutive time points may be used as frames of a movie.
152152

153-
The frame rate is always adjusted so that one hour of experiment real time is one second of the movie.
153+
The frame rate is adjusted so that one hour of experiment real time is one second of the movie. This default can be changed in the config file (see the optional sections).
154154

155155
Hint: To watch movies with zoom, you may use [VLC](https://videolan.com) and then in its menu Tools → Adjustments and Effects → Video effects tick the option 'Interactive zoom'; use the bird-view in the top-left corner to move around.
156156

@@ -197,6 +197,9 @@ The four sections above are obligatory. You may also include optional sections:
197197
```
198198
Annotations:
199199
font_size: 32pt # default is 96pt
200+
201+
Movies:
202+
realtime_speedup: 60x # one minute of the real time -> one second of the movie
200203
```
201204

202205

maestro.py

+14-3
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@
124124
FFMPEG_OPTS_QUALITY = '-preset medium -crf 28 -tune fastdecode'.split()
125125
FFMPEG_VIDSTAB_FILE_PATH_CORE = Path('/tmp/vidstab-')
126126

127+
MOVIE_DEFAULT_REALTIME_SPEEDUP = 3600 # 1m of live experiment => 1h of movie
128+
127129
CLICK_EXISTING_FILE_PATH_TYPE = click.Path(exists=True, file_okay=True, dir_okay=False)
128130
CLICK_EXISTING_FOLDER_PATH_TYPE = click.Path(exists=True, file_okay=False, dir_okay=True)
129131

@@ -846,6 +848,7 @@ def encode_movies(
846848
delta_t: timedelta,
847849
well_remixes_folder_path: Path,
848850
well_movies_folder_path: Path,
851+
realtime_speedup: int,
849852
force: bool = False,
850853
annotate_with_timestamp: bool = True,
851854
annotation_font_size: int = TEXT_ANNOTATIONS_DEFAULT_FONT_SIZE,
@@ -857,8 +860,8 @@ def encode_movies(
857860

858861
assert delta_t is not None
859862
delta_t_secs = delta_t.total_seconds()
860-
movie_fps_s = f"3600/{round(delta_t_secs)}" # rational
861-
movie_fps_i = round(3600/delta_t_secs) # used for frequency of keyint insertion
863+
movie_fps_s = f"{round(realtime_speedup)}/{round(delta_t_secs)}" # rational
864+
movie_fps_i = round(realtime_speedup/delta_t_secs) # used for frequency of keyint insertion
862865
movie_fps_i = max(movie_fps_i, 1)
863866

864867
well_movies_folder_path.mkdir(exist_ok=True, parents=True)
@@ -1510,7 +1513,14 @@ def remaster(
15101513
remixing_downscale = config['Remixes']['downscale'] \
15111514
if 'downscale' in config['Remixes'] else False
15121515

1513-
# text annotation settings
1516+
# (optional) movie settings
1517+
if 'Movies' in config and 'realtime_speedup' in config['Movies']:
1518+
realtime_speedup = int(config['Movies']['realtime_speedup'].replace('x', ''))
1519+
else:
1520+
realtime_speedup = MOVIE_DEFAULT_REALTIME_SPEEDUP
1521+
print(f"Info: Assumed default movie realtime speedup: {MOVIE_DEFAULT_REALTIME_SPEEDUP}x.")
1522+
1523+
# (optional) text annotation settings
15141524
if 'Annotations' in config and 'font_size' in config['Annotations']:
15151525
annotation_font_size = int(config['Annotations']['font_size'].replace('pt', ''))
15161526
else:
@@ -1710,6 +1720,7 @@ def remaster(
17101720
time_interval,
17111721
well_remixes_folder_path,
17121722
well_movies_folder_path,
1723+
realtime_speedup=realtime_speedup,
17131724
force=force_encode,
17141725
annotation_font_size=annotation_font_size,
17151726
)

0 commit comments

Comments
 (0)