Skip to content

Commit

Permalink
fix iterator bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
jasongdove committed Oct 23, 2021
1 parent d6872b3 commit 9ab51c6
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions mkchap.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ def process(inputfile, outputfile):


def get_chapters(inputfile, duration):
output = get_output(['ffprobe', '-f', 'lavfi', '-i', 'movie=\'{}\',blackdetect=d={}:pic_th={}:pix_th=0.00[out0]'.format(inputfile, min_black_seconds, ratio_black_pixels),
output = get_output(['ffprobe', '-f', 'lavfi', '-i', 'movie=\'{}\',blackdetect=d={}:pic_th={}:pix_th={}[out0]'.format(inputfile, min_black_seconds, ratio_black_pixels, pixel_threshold),
'-show_entries', 'frame_tags=lavfi.black_start,lavfi.black_end', '-of', 'default=nw=1', '-v', 'panic'])
raw_pairs = filter(lambda c: len(c) == 2, chunks(output.splitlines(), 2))
numeric_pairs = map(
lambda p: [float(p[0].split('=')[1]), float(p[1].split('=')[1])], raw_pairs)
valid_pairs = filter(lambda p: p[0] > min_black_seconds and p[1] - p[0]
> min_black_seconds, numeric_pairs)
numeric_pairs = list(map(
lambda p: [float(p[0].split('=')[1]), float(p[1].split('=')[1])], raw_pairs))
valid_pairs = list(filter(lambda p: p[0] > min_black_seconds and p[1] - p[0]
>= min_black_seconds, numeric_pairs))
chapters = list(map(lambda p: p[0] + (p[1] - p[0]) / 2.0, valid_pairs))
chapters = [val for val in chapters for _ in range(2)]
chapters.insert(0, 0)
Expand Down

0 comments on commit 9ab51c6

Please sign in to comment.