Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to determine total duration from chapter.txt #33

Open
sandreas opened this issue Nov 8, 2019 · 0 comments
Open

Unable to determine total duration from chapter.txt #33

sandreas opened this issue Nov 8, 2019 · 0 comments

Comments

@sandreas
Copy link

sandreas commented Nov 8, 2019

Hello,

first i would like to thank you for this useful mp4 toolset. Great work!

When exporting, modifying and re-importing chapters, i came across an issue that i would like to discuss before taking the time for a pull request. Since i did not find a specification of the chapters.txt format, let me point what i know

*.chapters.txt contains the following format:

  • format per line
    • start of the chapter, e.g. 00:00:00.000
    • whitespace
    • title of the chapter as string
  • Comment lines (lines starting with # or whitespace followed by # (e.g. #) are ignored

Problems:

  • Total duration of the file cannot be determined, because start of the last chapter does not include this information
  • Invalid lines starting with none of these, e.g. a 00:22:34.721 testing lead to crash / freeze of mp4chaps
  • Importing chapters.txt with chapters LATER than the total file duration (e.g. importing chapter that starts at 5 mins to a file that is only 2 mins lead to undefined behaviour)

This sample can be successfully imported to a file longer than 5:53.382:

# comment line 1 is ignored
00:00:00.000 Intro
# comment line 2 is ignored
00:02:34.711 Chapter 1
00:03:31.640 Chapter 2
00:04:22.724 Chapter 3
00:05:53.382 Chapter 4

Unfortunately the format does not allow to determine or calculate total length of the file only with the *.chapters.txt file without re-analysing the original mp4 file.

My use case:

  • Parsing a *.chapters.txt with a shell script
  • Adding an Intro and Outro chapter of a fixed length
  • Re-importing the *.chapters.txt

mp4info can get the total duration but since the output format is different AND the chapter files should be parsed on another system, than the original files are it would be great, if the *.chapters.txt format could be extended to contain the total length of the file. It would make things a lot easier for my use case.

I would suggest the following extension, where a comment starting with a specific keyword, e.g. total-length followed by whitespace and then the value of the keyword would contain the required information:

# total-length 00:05:59.533
00:00:00.000 Intro
00:02:34.711 Chapter 1
00:03:31.640 Chapter 2
00:04:22.724 Chapter 3
00:05:53.382 Chapter 4

This extension would also allow to add other keywords, if required (e.g. codec, filesize or other meta tags of the file) but for now the missing information of total length would be great to have.

What do you think? If you are satisfied with the extended specification I could try to implement this feature and submit a pull request...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant