0

I need to convert result from ffmpeg blackdetect to work in mkvtoolnix chapter. Maybe the middle off time of black_start and black_end should be the result that is used in the xml-file.

This is outside what I know and understand (I just seem to not understand the way to write the script) so I do need a full script that works. I'm using C++ in Code::Blocks. I did find this link and I think this is the math needed.

This result from ffmpeg in a *.txt-file:

    black_start:2455.09 black_end:2458.09 black_duration:3
black_start:3147.5 black_end:3150.92 black_duration:3.41667
black_start:3263.67 black_end:3266.88 black_duration:3.20833
 black_start:3379.46 black_end:3379.96 black_duration:0.5
 black_start:3384.92 black_end:3385.42 black_duration:0.5
 black_start:3388.88 black_end:3389.38 black_duration:0.5
black_start:3822.34 black_end:3822.63 black_duration:0.291667
 black_start:3830.75 black_end:3831.17 black_duration:0.416667
 black_start:3914.34 black_end:3918.34 black_duration:4
black_start:4161.09 black_end:4164.05 black_duration:2.95833
 black_start:4745.71 black_end:4747.71 black_duration:2
 black_start:4919.59 black_end:4921.88 black_duration:2.29167

what the *.xml shoud look like:

<?xml version="1.0"?>
<!-- <!DOCTYPE Chapters SYSTEM "matroskachapters.dtd"> -->
<Chapters>
  <EditionEntry>
    <EditionUID>13986225704000329578</EditionUID>
    <ChapterAtom>
      <ChapterTimeStart>00:00:00.000000000</ChapterTimeStart>
      <ChapterDisplay>
        <ChapterString>Chapter 01</ChapterString>
        <ChapterLanguage>und</ChapterLanguage>
      </ChapterDisplay>
      <ChapterUID>2416969533838069235</ChapterUID>
    </ChapterAtom>
    <ChapterAtom>
      <ChapterTimeStart>00:04:04.000000000</ChapterTimeStart>
      <ChapterDisplay>
        <ChapterString>Chapter 02</ChapterString>
        <ChapterLanguage>und</ChapterLanguage>
      </ChapterDisplay>
      <ChapterUID>3721621575396755001</ChapterUID>
    </ChapterAtom>
    <ChapterAtom>
      <ChapterTimeStart>00:47:53.570000000</ChapterTimeStart>
      <ChapterDisplay>
        <ChapterString>Chapter 02</ChapterString>
        <ChapterLanguage>und</ChapterLanguage>
      </ChapterDisplay>
      <ChapterUID>17369006734853656568</ChapterUID>
    </ChapterAtom>
  </EditionEntry>
</Chapters>
  • Welcome to stackoverflow.com. Please take some time to read [the help pages](http://stackoverflow.com/help), especially the sections named ["What topics can I ask about here?"](http://stackoverflow.com/help/on-topic) and ["What types of questions should I avoid asking?"](http://stackoverflow.com/help/dont-ask). Also please [take the tour](http://stackoverflow.com/tour) and [read about how to ask good questions](http://stackoverflow.com/help/how-to-ask). Lastly please read [this question checklist](https://codeblog.jonskeet.uk/2012/11/24/stack-overflow-question-checklist/). – Some programmer dude Dec 04 '19 at 09:00
  • The question has not been asked before, I have done some code before to get the result, but i don't know/understand/can't learn how to solve this. I have tried for 3 weeks and even went to a short course without luck. I feel stupid, and this is the last chance to get help. I have looked upp a but, and thats what I have posted, link to the math for example. Or do you meen I am unclear with what I want? I have done some C# before, C++ is completely new. – stackoverflowknitter Dec 04 '19 at 09:07
  • 1
    @stackoverflowknitter: If you can use `std::chrono`, you can look at [this example](https://en.cppreference.com/w/cpp/chrono/duration/operator_arith4) to see how you can break down a duration. [This answer](https://stackoverflow.com/a/42139394) also looks helpful. – Hasturkun Dec 04 '19 at 15:42

0 Answers0