i wanted to create a timelapse with the file-names burned into the image..
should be a quick ffmpeg commandline – i thought..
lots of hours later..
you can now find the result in the battery run-time post.
Workflow is as following:
using blender with a special python script to burn the filenames onto the output.
# based on https://blender.stackexchange.com/a/8087/16634
import bpy
#debug helper
print("all vse strips:", end="\n ")
print(*bpy.context.scene.sequence_editor.sequences, sep="\n ")
# output VSE Text strip:
text_overlay = bpy.context.scene.sequence_editor.sequences["Text"]
#x = bpy.context.scene.sequence_editor.sequences["day2"]
def get_combined_speed_factor(strip):
# this does not handle all possible configuration options!
# only
# - Stretch to input strip length
# - Speed factor
# - Multiply Speed
# are handled.
#print("strip", strip)
combined_speed_factor = 1.0
#print(" use_default_fade", strip.use_default_fade)
#print(" speed_factor", strip.speed_factor)
#print(" multiply_speed", strip.multiply_speed)
if strip.use_default_fade:
# update / overwrite not used speed_factor value.
orig = strip.input_1
strip.speed_factor = orig.frame_duration / orig.frame_final_duration
# calculate
combined_speed_factor = strip.speed_factor
combined_speed_factor *= strip.multiply_speed
return combined_speed_factor
def get_speed_factor_for_strip(scene, strip):
strips_all = scene.sequence_editor.sequences
strips_speed = (i for i in strips_all if i.type == 'SPEED')
effects_for_strip = (i for i in strips_speed if i.input_1 == strip)
combined_speed_factor = 1.0
# this should calculate the overall speed for this input strip
for effect_strip in effects_for_strip:
combined_speed_factor *= get_combined_speed_factor(effect_strip)
return combined_speed_factor
def find_current_img_filename(scene):
frame_current = scene.frame_current
#print("scene.frame_current", scene.frame_current)
#print("scene.frame_current_final", scene.frame_current_final)
file_name = None
# print("\n")
strips_all_sorted = list(sorted(scene.sequence_editor.sequences,
key=lambda x: x.frame_final_start))
strips_image = (i for i in strips_all_sorted if i.type == 'IMAGE')
strips_speed = (i for i in strips_all_sorted if i.type == 'SPEED')
for strip in strips_image:
strip_speed_factor = get_speed_factor_for_strip(scene, strip)
#print("strip", strip)
#print("strip_speed_factor", strip_speed_factor)
#print(" frame_final_start", strip.frame_final_start)
#print(" frame_final_end", strip.frame_final_end)
if strip.frame_final_start <= frame_current < strip.frame_final_end:
#print("strip", strip)
#print(" frame_current", frame_current)
#print(" strip_speed_factor", strip_speed_factor)
#print(" frame_final_start", strip.frame_final_start)
#print(" frame_final_end", strip.frame_final_end)
strip_frame = (
(frame_current - strip.frame_final_start)
* strip_speed_factor
) + strip.frame_final_start
#print(" → strip_frame", strip_frame)
file_name = strip.strip_elem_from_frame(strip_frame).filename
return file_name
def recalculate_text(scene):
filename = find_current_img_filename(scene)
#print("filename", filename)
text_new = "-"
if (filename):
text_new = filename.replace(".png", "")
text_overlay.text = text_new
bpy.app.handlers.frame_change_pre.clear()
bpy.app.handlers.frame_change_pre.append(recalculate_text)
bpy.app.handlers.render_pre.clear()
bpy.app.handlers.render_pre.append(recalculate_text)
this allows for files in multiple directories with complex filenames (like date_time) and additional tweaking of the speed and so on…
rendering this as png sequence.
than use a classic ffmpeg image-sequence to create the final video with this (2-pass) commandline:
$ ffmpeg -framerate 30 -start_number 0 -i %04d.png -c:v libvpx-vp9 -pass 1 -b:v 1000K -threads 8 -speed 4 -tile-columns 6 -frame-parallel 1 -an -f webm temp
$ ffmpeg -framerate 30 -start_number 0 -i %04d.png -c:v libvpx-vp9 -pass 2 -b:v 1000K -threads 8 -speed 1 -tile-columns 6 -frame-parallel 1 -auto-alt-ref 1 -lag-in-frames 25 -an -f webm out.webm
next step would be to change the script to really generate the runtime in minutes from the timestamps…