Hi, how to import guided exported as FFMPEG chapters to different project?
Or chapters extracted from MKV file?
I’d like to start rendering but need import chapters (to render splitted files), I exported from different project before
so I solved problem:
use
ffmpeg -i input.mp4 -f ffmetadata chapters.txt
then I made this script:
import re, json
def FFMETADATA_chapters_to_KDENLIVE_guides(file, offset=0, TIMEBASE=1000000000, FPS=25):
# open file
with open(file, 'r', encoding='utf-8') as f:
txt = f.read().split('[CHAPTER]')[1:] # Split based on '[CHAPTER]' and ignore the first part
new_chaps = []
for chap in txt:
# Extract start time and title
s = re.search(r'START=(\d+)', chap)
t = re.search(r'title=(.*?)$', chap, re.MULTILINE)
if s and t:
comment = t.group(1)
pos = int(s.group(1))
# Convert start time to frames and apply offset
frames = int(pos / TIMEBASE * FPS) + offset
new_chaps.append({"comment": comment, "pos": frames, "type": 2})
# Write the new chapters to a JSON file
with open(file.rsplit('.', 1)[0]+'.json', 'w', encoding='utf-8') as out:
json.dump(new_chaps, out, indent=4, ensure_ascii=False)
#------------USE SCRIPT HERE-------------------
FFMETADATA_chapters_to_KDENLIVE_guides('chapters.txt', offset=0, FPS=25)
adjust FPS etc. and edit project file in any notepad then paste generated guides in correct place.
Also, there are topics you can refer and hope you find you are looking for
Ref: From Kdenlive docs https://docs.kdenlive.org
Export guides as chapters description
Rendering Using Guides (Recommended, this is what you’re trying to achieve which is already built-in feature in kdenlive)