This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Automatic scene split: Not working or user error?

Tags: None
(comma "," separated)
jphfilm
Registered Member
Posts
2
Karma
0
I'm trying to use the "Automatic Scene Split" feature in Kdenlive v16.08.2, running on Ubuntu 16.04, but I'm not getting any results.
I'm fairly new to kdenlive, so I don't know whether I'm experiencing a bug or just failing to understand how the feature works.

I right-click on a clip in the project bin, and select "Clip Jobs -> Automatic Scene Split".
In the following box, 'Add Clip Markers (Category 1)' is already selected. No matter which other boxes I also select, after I click 'OK', I can see the job running and the clip being analyzed, but when it finishes there are never any markers or cuts identified in the project monitor, or in the timeline if I add the clip there later. No markers appear in the clip properties.
If I select 'Save Result in clip metadata', it will save a long list of cuts (which I don't know the meaning of) which show in the 'Analysis Data' panel of clip properties: this suggests to me that the analysis IS identifying scene changes, but it's either not applying them, or I'm misunderstanding how to use this feature.
If I save the analysis data to a file, it looks like:

Code: Select all
[Analysis]
shot_change_list=1=14020/0:0x0:0;40=6470;42=4256;115=3319;208=2826;268=6793;384=2566;474=3518;654=2608;1230=5224;1351=8278;1546=6394;1822=3798;1941=2607;2503=5226;2743=3026;2827=6062;2968=15153;2970=4453

(The sequence is longer than this; I just included the first third or so. FWIW, Higher numbers seem to line up with obvious scene changes, but some of the lower numbers seem like false positives.)

Can anyone else identify this same behavior to determine if this is a bug - or perhaps explain how I should be using this feature? It would be extremely useful if I could get it working.
pcurtis
Registered Member
Posts
1
Karma
0
I have the same behavior using kdenlive 16.08.2 under Mint 18.0 so I believe this is a bug rather than a user error. Files I have tested are standard H264/MP4.

It is possible that there are dependencies on other software which are not satisfied unless one is using a KDE desktop. I recall in the old days there used to be check of what software was available when you first ran Kdenlive.
bstewart
Registered Member
Posts
5
Karma
0
I'm using Ubuntu 18.10 and kdenlive 18.08.2

I have also been suffering from this feature not working.
Having also ticked the option (Save result in clip metadata) and analysed the data there I have concluded the following:
Data starts with "shot_change_list=1=14020/0:0x0:0;" - I've not been able to dechiper this, but following the ";" there are pairs of data, the first of which is the frame count of the detected scene change, then "=" and a second number I can't decode, but maybe some indication of the amount of change - pure guess.

This data is also written into the saved kdenlive file eg "myfile.kdenlive".

I wrote a python3 script which reads the kdenlive file and creates a new one "myfile_new.kdenlive" with guide markers inserted at each of the scene changes found.
This new file can be opened with kdenlive and now contains labelled guide markers which can be easily found and the clip split if required by normal editing.

The script can be run from the command line
Code: Select all
python3 kden_C2G.py myfile.kdenlive
or just
Code: Select all
./kden_C2G.py myfile.kdenlive
from the directory where the script is placed with "myfile.kdenlive" being the path to the kdenlive filename you have saved from kdenlive.
If the script file is saved in (.local/share/nautilus/scripts) then it can be run by right clicking on your required kdenlive file directly.

The kdenlive file should be created by importing just one clip file, placing it on the timeline then right clicking on the clip in the clip window and selecting (Clip Jobs/Automatic scene split/Save result in clip metadata) then clicking OK. Then from the main menu save the kdenlive file. - Run the script and then open the new file in kdenlive.

I am not an experienced programmer and my code may not be the most efficient but it works for me and the code is given in good faith.
Obviously you should use it at your own risk and I cannot accept any responsibilities for any errors, omissions, faults etc.

save as kden_C2G.py (kdenlive Clips to Guides)
Code: Select all
#!/usr/bin/env python3
# Filename kden_C2G.py

# Version 1.0 29-Jan-2019
# Brian Stewart 29 Jan 2019
# Reads kdenlive file, looking for clipanalysis.shot_change_list
# extracts the clip shot frames and creates a new kdenlive output file with
# clip timings as guides. Requires initial file to have:-
# "save result in clip metadata" enabled from "clip jobs/Automatic scene split"
# kdenlive file should have only 1 clip and be added to timeline
# the resultant new file can be opened in kdenlive which will now have guide markers
# set at each scene/shot change.
# Titles of guides can be seen by setting "Timeline/Show marker comments"

import sys

filein = sys.argv[1]  # Filename from command line
filename_stem = filein[0:filein.find(".")]
fileout = filename_stem + "_new.kdenlive"

fps_search = '<profile frame_rate_num="'
clip_find = '<property name="kdenlive:clipanalysis.shot_change_list">'
xml_retain = '<property name="xml_retain">'
fps = None
clips = None
xml = None

# find fps (framerate) of video file.
def findfps(line):
   i = line.find(fps_search, 0)
   if i > 0: # fps should be in this line
      return int(line[i+len(fps_search):line.find('"', i + len(fps_search))])
   return

# find line containing clipanalysis.shot_change list
# This line contains frame numbers of scene/shot changes
def findclipanal(line):
   i = line.find(clip_find, 0)
   if i > 0: # clip analysis should be in this line
      return findclips(line, line.find(';', i + len(clip_find)))
   return

# Extract frame numbers of changes and divide by fps to calculate time in seconds
# of shot changes, place into tupple "clips"
def findclips(line, i):
   clips = [0,]
   while True:
      i +=1
      j = line.find('=',i)
      if j >0:
         x = i
         y = j
         # Next 3 lines ensure whole seconds have no decimal places
         t = int(line[i:j])/fps
         if t%1 == 0:
            t = int(t)
         clips.append(t)
         i = line.find(';',j)
         if i < 0:
            return clips
   return

# Copy lines from input to output file, inserting guide lines with time and label for
# each scene change before line containing (property name="xml_retain)
def findxml(line):
   i = line.find(xml_retain, 0)
   if i > 0: # xml_retain should be in this line
      for x in range(len(clips)):
         outline = ' ' * i + '<property name="kdenlive:guide.' + str(clips[x]) + '">shot' + str(x+1) + '</property>\n'
         fw.write(outline)
      fw.write(line)
      return True
   fw.write(line)
   return

# open input file for searching, break out on EOF
f = open(filein, 'r')
while True:
   line = f.readline()
   if len(line) == 0:
      break

   # Search for fps and clipanalysis
   if not fps:
      fps = findfps(line)
   if not clips:
      clips = findclipanal(line)

# Close input file, then re-open to start copying to output file
f.close()
f = open(filein, 'r')
fw = open(fileout, 'w')

# Again break out on EOF of input file
while True:
   line = f.readline()
   if len(line) == 0:
      break
   else:
      if not xml:
         # search for xml_retain line
         xml = findxml(line)
      else:
         fw.write(line)

# Finished, close open files.
f.close()
fw.close()


I have also written another script which I use to use kdenlive file with guides or markers to create a video file with Chapters inserted at each marker. Which I can make available if required.

I hope this helps until someone fixes kdenlive


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]