VideoHelp Forum
+ Reply to Thread
Results 1 to 7 of 7
Thread
  1. Member
    Join Date: Aug 2013
    Location: Sierra Leone
    Search Comp PM
    Hello,
    I have a lot of videos in MKV and I would like to add chapters to them. But I want to add chapters every time a scene ends. This is usually indicated by a black frame. I know there are software out there that can create frames automatically every x seconds/frames but as I have already said I have a lot of videos and I want chapters to begin at the transition of new scenes which happens and a black frame. So:
    1. Is there a software that can do that automatically.
    2. If there's no software, is there a software that can detect all black frames and report their frame number ?
    Thanks
    Quote Quote  
  2. I'm a MEGA Super Moderator Baldrick's Avatar
    Join Date: Aug 2000
    Location: Sweden
    Search Comp PM
    1. Nope.
    2. Some editors can detect scene changes. Maybe videoredo h264 suite. But I doubt they can export any frame number...and mkv support is not that good.
    Quote Quote  
  3. Member
    Join Date: Sep 2012
    Location: Australia
    Search Comp PM
    AVIDemux can detect black frames, but there's nothing that will let you add chapters, or export frames. Try it and see how many false positives you get before you decide automatic chapters would be a good idea.

    and... oh, it doesn't do MKV's very well... um, echo, I remux my files into TS files using TSMuxer and load the TS files into AVIDemux to find chapter positions.
    Quote Quote  
  4. Member
    Join Date: Sep 2007
    Location: Canada
    Search Comp PM
    is there a software that can detect all black frames and report their frame number ?
    There are black frame detection scripts in avisynth, with adjustable thresholds, that output a text file list

    eg.
    http://forum.doom9.org/showthread.php?p=1573376#post1573376
    Quote Quote  
  5. Member
    Join Date: Sep 2012
    Location: Australia
    Search Comp PM
    That's cool actually, I could probably write a Powershell script that could take that AVISynth output and build an MKVToolNix chapter xml file out of it, complete with 'End Times', or I could just settle for OGG But from experience, there's still the problem of false positives, black frames aren't the exclusive domain of ad breaks. Plus, since audio tends to stretch into the black frames rather than just stop with the video you'd need a script that checks the Audio too to make sure it captures a silent/black frame. If you intend to fix the chapters afterwards then you might as well do the whole thing manually with AVIDemux, but if you just want a quick hack-job then the AVISynth scripts would be the solution.
    Quote Quote  
  6. As a side note:

    ffprobe could be used
    Code:
    ffprobe.exe -show_frames -of compact=p=0 -f lavfi "movie=\'F:\\\\Movies\\\\Movie name.mkv\',select=gt(scene\,0.4)" > scene-changes.txt
    to create a scene change file, which contains a lot of lines like:
    Code:
    media_type=video|key_frame=1|pkt_pts=47548|pkt_pts_time=47.548000|pkt_dts=47548|pkt_dts_time=47.548000|best_effort_timestamp=47548|best_effort_timestamp_time=47.548000|pkt_duration=N/A|pkt_duration_time=N/A|pkt_pos=8892987|pkt_size=N/A|width=720|height=304|pix_fmt=rgb24|sample_aspect_ratio=1:1|pict_type=I|coded_picture_number=0|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|tag:lavfi.scene_score=0.490000
    where 0.4 in the first call is the minimal scene_score which is required to indicate a scene change.
    Analyzing that scene-changes.txt file a mkv chapter file could be created.

    Alternatively ffmpeg also has two filters blackdetect and blackframe which might also be interesting,..
    see: http://www.ffmpeg.org/ffmpeg-all.html#blackframe and http://www.ffmpeg.org/ffmpeg-all.html#blackdetect

    => rudimentary scene or black frame detection isn't that complicated and doesn't necessarily require Avisynth
    Quote Quote  
  7. If the video is silent for the duration of the black frame, there is a semi-auto way of chapter creation in AviUtl:


    Click image for larger version

Name:	VH-20140605-SCChapter.png
Views:	8
Size:	452.1 KB
ID:	25532

    Under the Window/Display menu, there is an item called "Chapter Editing". Open it...

    (1) The minimum duration of silence to trigger the addition of chapter (as number of frames)
    (2) Lower threshold allows the inclusion of faint sound/BG noise, use High threshold to find absolute silence
    (3) Adjust the chapter point to the nearest scene change (may or may not work as intend)
    (4) Click the button to begin processing
    (Optional) Click on the Name field to change the chapter's name

    When done, follow the instruction here (from step 4):
    http://mavericktse.mooo.com/wordpress/archives/1014
    To encode the video with chapters.

    You may also try to save that chapter file and mux it back to video using MKVMerge... but I haven't tried that myself and can't guarantee if the chapter format is compatible.
    Quote Quote