Hi hubble,
Omitting Timebase and entering times as nanoseconds, the file is accepted and muxed with CleverFFMpeg. My mediaplayer though prefers the timebase set to 1/1000 with times in milliseconds. On pc, PotPlayer has no trouble with both.
Maybe something worth to mention, MediaInfo displays added info at the "Menu" section on the mp4 "done" with timebase=1/1000 set. For this I created two testfiles.
Without timebase set
gives in MediaInfoCode:;FFMETADATA1 [CHAPTER] START=0 END=100000000000 title=Chapter 1 [CHAPTER] START=100000000000 END=200000000000 title=Chapter 2 [CHAPTER] START=200000000000 END=1000000000000 title=Chapter 3 [CHAPTER] START=1000000000000 END=1628418000000 title=Chapter 4
Code:Menu ID : 3 Format : Timed Text Codec ID : text Duration : 27 min 8 s Language : English Encoded date : 2022-06-06 16:28:42 UTC Tagged date : 2022-06-06 16:28:42 UTC Bit rate mode : CBR Menu For : 1,2 00:00:00.000 : Chapter 1 00:01:40.000 : Chapter 2 00:03:20.000 : Chapter 3 00:16:40.000 : Chapter 4 Bit rate mode : Constant
With timebase=1/1000 set
gives in MediaInfoCode:;FFMETADATA1 [CHAPTER] TIMEBASE=1/1000 START=0 END=100000 title=Chapter 1 [CHAPTER] TIMEBASE=1/1000 START=100000 END=2000000 title=Chapter 2 [CHAPTER] TIMEBASE=1/1000 START=200000 END=1000000 title=Chapter 3 [CHAPTER] TIMEBASE=1/1000 START=1000000 END=1628418 title=Chapter 4
Maybe reason my player prefers the timebase=1/1000 set and go for that? I can imagine other mediaplayers acting differently though. Thinking out loud, maybe you can add a user option to not set/do set (any) timebase that's supported by ffmpeg?Code:Menu ID : 3 Format : Timed Text Codec ID : text Duration : 33 min 20 s Language : English Encoded date : 2022-06-06 16:28:42 UTC Tagged date : 2022-06-06 16:28:42 UTC Bit rate mode : CBR Menu For : 1,2 Source duration : 1628418 Source frame count : 4 Source stream size : 92 Stream size : 92 mdhd_Duration : 2000000 00:00:00.000 : Chapter 1 00:01:40.000 : Chapter 2 00:03:20.000 : Chapter 3 00:16:40.000 : Chapter 4 Bit rate mode : Constant
+ Reply to Thread
Results 121 to 150 of 170
-
-
OK. An option to set the TIMEBASE with a valid value should be fine. I like options
Do you know which values are valid for ffmpeg? -
-
OK. In the specs (from the link) there is no restriction, a value of 12/3456 is/should be also valid.
-
You almost got me going there with the 12/3456 value
Maybe this tells something? I created the mp4 using the chapters format without the timebase argument
Code:;FFMETADATA1 [CHAPTER] START=0 END=100000000000 title=Chapter 1 [CHAPTER] START=100000000000 END=200000000000 title=Chapter 2 [CHAPTER] START=200000000000 END=1000000000000 title=Chapter 3 [CHAPTER] START=1000000000000 END=1628418000000 title=Chapter 4
Code:;FFMETADATA1 major_brand=isom minor_version=512 compatible_brands=isomiso2avc1mp41 title=Banshee encoder=Lavf60.16.100 [CHAPTER] TIMEBASE=1/1000 START=0 END=100000 title=Chapter 1 [CHAPTER] TIMEBASE=1/1000 START=100000 END=200000 title=Chapter 2 [CHAPTER] TIMEBASE=1/1000 START=200000 END=1000000 title=Chapter 3 [CHAPTER] TIMEBASE=1/1000 START=1000000 END=1628418 title=Chapter 4
Anyways, note the TIMEBASE argument being "re-introduced" with the proper seconds values. I'm not sure what to think of this; note I used the GUI to extract. Just letting you know.Last edited by Ennio; 27th Jan 2024 at 05:42.
-
hubble, at the Doom 9 forums, -QfG- recently put up a link which target concerns adding chapters with ffmpeg.
https://ikyle.me/blog/2020/add-mp4-chapters-ffmpeg
Reading it, here too TIMEBASE=1/1000 is used. I also noticed the difference=1 between every END and successive START. And the empty lines preceding each chapter entry.
It does more or less confirm using TIMESTAMP=1/1000 to be common.
Maybe you want to particularly check out the mentioned "Helper script".Last edited by Ennio; 28th Jan 2024 at 06:37.
-
Thanks for the link, any information helps.
I still find the END times a bit confusing.
Because it is not clear whether the times have to be in a row without gaps or whether there can be gaps between the end and start times (next chapter).
For Matroska it doesn't matter what value the timestamps have, since such ordered chapters determine the playback order and the player has to stick to the chapter times.
Reading in such chapters already works in cE, and I'm in the process of finishing coding the output in the converter (but it's a little more than expected, because of these end times).
The converter isn't really equipped to work with end times and I'm not sure how to install that yet.
For easy handling you would only need the START time. The END time could be calculated and only the last END timestamp would have to be available as an input option. -
-
Yes I read this and I'm sure the a END must be the same value liek the START time of the prev chapter.
In Matroska is the END time exclusive. A Player play until the END time is reached. -
Surely you mean this the other way around.
Then I can imagine standalone mediaplayers, running on poorly written firmware, expecting this also for mp4. Can't vouch for it, but I don't expect ffmpeg being able to mux chapters-metadata files with "END=..." only at the last chapter. -
-
Can you make a test please?
Use for the first chapter START=0, END=1000 (TIMEBASE=1/10000) and for a second START=2000, END=3000
What is the play duration of such file?
Matroska(an MKV) would play now only 2 seconds of a video. -
Will do, also I'll try with and without the bespoken "gaps". Will report back, gimme some time.
[EDIT]
i also want to test this, but I don't know how the data in xml would look like. As I'm importing xml into MKVToolNix for muxing, could you please provide with a sample?Last edited by Ennio; 28th Jan 2024 at 08:20.
-
I've done your required test, both with and without the "gaps".
Where I did the gaps, FYI the syntax I used is:
Code:;FFMETADATA1 [CHAPTER] TIMEBASE=1/1000 START=0 END=1000 title=Chapter 1 [CHAPTER] TIMEBASE=1/1000 START=2000 END=3000 title=Chapter 2
Code:;FFMETADATA1[CHAPTER]TIMEBASE=1/1000START=0END=1000title=Chapter 1[CHAPTER]TIMEBASE=1/1000START=2000END=3000 title=Chapter 2
Still, please provide me with a xml-text example where "END" is used. I do want to see whether mkv-playback will end after the END time. -
BTW, having a look with MediaInfo on the two videos, there is difference between infos at the "Menu" section.
Where the syntax was written with the gaps, the info is:
Code:Menu ID : 3 Format : Timed Text Codec ID : text Duration : 3 s 0 ms Language : English Encoded date : 2024-01-28 14:55:36 UTC Tagged date : 2024-01-28 14:55:36 UTC Bit rate mode : CBR Menu For : 1,2 Duration_FirstFrame : 1000 00:00:00.000 : Chapter 1 00:00:02.000 : Chapter 2 Bit rate mode : Constant
Code:Menu ID : 3 Format : Timed Text Codec ID : text Duration : 1 s 0 ms Language : English Encoded date : 2024-01-28 14:55:36 UTC Tagged date : 2024-01-28 14:55:36 UTC Menu For : 1,2 Source duration : 3000 Source frame count : 1 Source stream size : 23 Stream size : 0 mdhd_Duration : 1000 00:00:00.000 : Chapter 2
-
Hi Ennio
In the attachments there is the 2-ordered-chapter.xml. You can add this chapter to any MKV and it will be play only 2 seconds.
(The Player must handle ordered chapters, if not the entire file is played with two chapter marks)
mp4 is a container which don't support ordered chapters, but FFmpeg can mux to MKV directly and maybe is then the END time used.?
Could you test this please?
MediaInfo is a very great tool, but I would not fully trust the chapter section.Last edited by hubblec4; 28th Jan 2024 at 15:11.
-
Take all the time you need. Maybe I have in night a test version for you.
cE will initially generate the end times automatically and only the start times are important. Existing end times should and will also be taken into account. -
Hi Ennio
Here is a test version of cE for you. -
Ah, I plainly didn't know, thanks.
Tests with ffmpeg muxing to mkv, using the ordered textfiles (as in my post #121, please correct me if I misunderstood):
Written "with gaps" and "without gaps", playback of both mkvs continues on pc PotPlayer, pc MPV player and my mediaplayer.
=====
Tests with your attached "2ordered-chapters.xml" --> imported in MKVToolNix and muxed to mkv:
PC PotPlayer and my mediaplayer continue playback, but on pc MPV player indeed stops after 1 second.
Maybe already safe to say my mediaplayer doesn't support ordered chapters.
=====
Reading back on this:
I'm confused here, probably because I don't have enough knowledge about the usage of "ordered chapters".
Why would the last end timestamp be unknown? I mean, for starters, can't a user set a desired one? And, if it would be the last chapter that ends at the very end of the video, could it be so hard to just "read & copy" video's runtime and "paste/set" that last end timestamp?
I'll be back with my findings on provided "test cE".
Again, please don't hesitate to point me if I've misinterpreted anything and you need some other testings. -
Never mind, my warped mind is not full throttle today; I think things are becoming more clear because of my first test with the testversion of cE.
Test with Converter: import XML, ouput to "FFmpeg MetaData (txt)"
source xml:
Code:<?xml version="1.0" encoding="UTF-8"?> <!-- <!DOCTYPE Chapters SYSTEM "matroskachapters.dtd"> --> <Chapters> <EditionEntry> <EditionUID>81380214092263253</EditionUID> <EditionFlagHidden>0</EditionFlagHidden> <EditionFlagDefault>0</EditionFlagDefault> <ChapterAtom> <ChapterUID>26017142771098923</ChapterUID> <ChapterTimeStart>00:00:00.000000000</ChapterTimeStart> <ChapterFlagHidden>0</ChapterFlagHidden> <ChapterFlagEnabled>1</ChapterFlagEnabled> </ChapterAtom> <ChapterAtom> <ChapterUID>7478758528289142</ChapterUID> <ChapterTimeStart>00:06:48.950000000</ChapterTimeStart> <ChapterFlagHidden>0</ChapterFlagHidden> <ChapterFlagEnabled>1</ChapterFlagEnabled> </ChapterAtom> <ChapterAtom> <ChapterUID>80483442088</ChapterUID> <ChapterTimeStart>00:15:08.157000000</ChapterTimeStart> <ChapterFlagHidden>0</ChapterFlagHidden> <ChapterFlagEnabled>1</ChapterFlagEnabled> </ChapterAtom> <ChapterAtom> <ChapterUID>2820206076687</ChapterUID> <ChapterTimeStart>00:23:13.809000000</ChapterTimeStart> <ChapterFlagHidden>0</ChapterFlagHidden> <ChapterFlagEnabled>1</ChapterFlagEnabled> </ChapterAtom> </EditionEntry> </Chapters>
cE ffmpeg output.txt:
Code:;FFMETADATA1 [CHAPTER] TIMEBASE=1/1000 START=0 END=408950 title= [CHAPTER] TIMEBASE=1/1000 START=408950 END=908157 title= [CHAPTER] TIMEBASE=1/1000 START=908157 END=1393809 title= [CHAPTER] TIMEBASE=1/1000 START=1393809 END=1393809 title=
So I assume this value can be set when the Converter would be fed a mkv as source.
It doesn't; I've tried. Where from the hip, I'm guessing cE would only read the chapter-information part of the mkv and not it's video duration. If I'm right with this, can cE (parsing?) be modified so it can establish and use the videoduration?Last edited by Ennio; 30th Jan 2024 at 08:14.
-
Hi Ennio
Yes it looks like your player don't support ordered chapters. mpv, VLC and MPC are the ones which have this support long time ago.
Last end time stamp:
When you feed cE with a chapter format which don't use a duration of the entire file, there is no way to know what the last end timestamp is.
Scanning a media file to get the highest timestamp is easy, but you have to use external programs. (cE is not MediaInfo)
All other END time stamps are simple the next start timestamp.
In cE in the Multi-MKV editor there is only an Edit field where the user can enter a last END timestamp. Such a field, I could add it to the Converter. -
Yes, cE can read from some formats the duration, like MKV's and other chapter formats.
I have to implement this for this new format, so that the Converter has this info. -
That would be great. Reading it, do I understand correctly that ffmpeg's format is the new & only one that would use end time - also for the last chapter, that is?
Another thing, in test cE I noticed when deleting or adjusting the default 1/1000 value in the "Time base" window, the listed timecodes are dynamically altered. Which is good and up till now I think 1/1000 should be default. I can however imagine (future-)users desiring another value, and go clicking on the drop-down arrow to select another one from an expected list. Which is currently empty. Does this need reconsideration? -
No there are some other formats which support an END time. Matroska of course, GraseVallyEdius V2 + V3 (with using a chapter duration) and some more. But only Matroska seems to use this value in a meaningful way (my opinion).
It's not a problem for Matroska if the timestamps are distributed all over the place.
So a chapter with start = 1h - end = 2h can be before a chapter with start = 0h - end = 1h.
But that will definitely cause problems in FFmpeg MetaData format (I suspect).
Yes, in cE all values are altered dynamically, and the value "1/1000" is currently the default value in cE.
The drop-down list in the Combobox is not empty, there is only value "1/1000". (delete the Combobox text and open the drop-down list).
For the moment is this the only one predefined value, but I can add more predefined values to this list if needed. -
Hi Ennio
Here a new test version with END time support. -
Hi hubble,
A few test already show XML to ffmpeg-format.txt and vice versa working well; both exports are muxed properly.
Remuxing these results back to other container also goes flawlessly. Happy camping here
In case something comes up and you want me to test anything else, don't hesitate.
Thanks for your work ! -
I don't know where my brain is lately. I realize I totally forgot testing with sources where duration can be retrieved. Which second cE testversion was about in the first place
Making amends, I ran some tests today. Where I didn't test usage of duration in "Matroska" as XML will only use start times.
In "Converter", importing mkv (and mp4 to be sure) and export to ffmpeg, the videodurations show properly set as last chapter's end time. Importing in - and muxing with CleverFFmpegGUI into both mkv and mp4 goes well. Remuxing results back to "first" container also works. Nice!
I also tried importing mkv, mp4 but also ffmpeg-format into Converter for editing. Do I understand correctly that - for ffmpeg export - the listed time codes can't be edited? Converter's "editing" button does not seem to offer the same options it does provide in "Matroska" mode. There, start times can be adjusted. Maybe I'm overlooking something here.
I noticed the testversion forgetting (some) settings. After succesful mp4 import sessions earlier - I was thrown an error because the path to MKVToolNix wasn't remembered anymore.
Maybe it's related to having both the testversion and latest non-test.
Similar Threads
-
ffmpeg convert from mkv to mp4 [matroska,webm @ 0x1d06640] Read error at
By blurry in forum Video ConversionReplies: 6Last Post: 15th Jan 2018, 05:36 -
MKV Metadata Tags
By EspressoMachine in forum Newbie / General discussionsReplies: 2Last Post: 2nd Feb 2016, 13:08 -
Latest Unofficial MediaInfo dll for dealing with Matroska Statistic Tags
By ndjamena in forum Newbie / General discussionsReplies: 6Last Post: 22nd Nov 2015, 08:08 -
MKV File Statistics Tags
By ndjamena in forum Latest Video NewsReplies: 0Last Post: 27th May 2014, 20:00 -
can ffdshow decode mkv matroska files?
By marcorocchini in forum Newbie / General discussionsReplies: 1Last Post: 23rd Oct 2013, 15:55