I am starting with an MP4 that has: no titles, no chapters, one audio track, one video track, no subtitle tracks, no data streams
When I view this file in VLC (ver 3.0.12), everything looks and works like I think it should. Then, I execute this command (ffmpeg version is: N-101923-gc012f9b265)Code:ffmpeg -i input.mp4 -f ffmetadata chapters.txt
The contents of chapters.txt is:
;FFMETADATA1
major_brand=isom
minor_version=512
compatible_brands=isomiso2avc1mp41
encoder=Lavf58.78.100
Then, I add this information to the bottom of chapters.txt:
[CHAPTER]
TIMEBASE=1/1
START=00
END=999
title=This is chapter 1
[CHAPTER]
TIMEBASE=1/1
START=1000
END=1999
title=This is chapter 2
[CHAPTER]
TIMEBASE=1/1
START=2000
END=2999
title=This is chapter 3
I save chapters.txt and then run this command:The ffmpeg console output looks like what I think it should: the chapters appear in the input #1 chapters section, the chapters appear in the output chapters section, and, there is no evidence of a data stream in the output file. Then, I go and view out.mp4 in VLC. I see the chapter names under "Playback > Chapter" and clicking on a chapter name takes me to the correct place in the video. But, when I go to "Subtitle > Sub Track", there is a new track #1 with the name "Track 1 - [English]". When I click on that track name to activate it, it displays the chapter name as a subtitle. When I do this commandCode:ffmpeg -i input.mp4 -i chapters.txt -map_metadata 1 -map_chapters 1 -c copy out.mp4there is now this at the end of the console output:Code:ffmpeg -i out.mp4
Stream #0:2(eng): Data: bin_data (text / 0x74786574)
Metadata:
handler_name: SubtitleHandler
Then, I execute this command:When I look at the ffmpeg console output of out2.mp4, the data stream is not there. When I view out2.mp4 in VLC, the chapters exist, but, the names have been changed to a generic name like: "Chapter 1". When I look at "Subtitle > Sub track", that subtitle track does not exist any more. So, the chapter names were removed when the data stream was removed, but, the chapter times remain.Code:ffmpeg -i out.mp4 -c copy -dn -map_metadata:c -1 out2.mp4
I have another MP4 (let's call it "foo.mp4") that has functioning chapter names in VLC, but, no subtitle track and the ffmpeg console output shows no data stream.
This is confusing to me and leads me to ask several questions:
1) why would ffmpeg put the chapter names into a data stream?
2) if that is where chapter names are supposed to go, how did foo.mp4 get created with chapter names but no data stream?
3) why is VLC showing information in a data stream as a subtitle track?
4) it seems like chapter times are in metadata, but, chapter names are in a data stream (sometimes). What is the reason for that?
+ Reply to Thread
Results 1 to 30 of 35
-
-
Clicking on some similar links at the bottom of this thread, it seems that either there isn't a standard for how MP4 handles/stores chapter information and/or many people don't follow the recommended/mandated standard. But, there seems to be two main ways to store and process chapter information in an MP4. Can somebody provide a site/sites that can tell me more about these two main ways of doing things? It would seem that one reason for the differences is to allow/help different playback devices to (at least try to) execute chapters properly. If that is the case, I would like to know how and where to store and/or remove the chapter information in these two different places in the MP4.
-
Have you tried without the '-map_metadata 1'?
when I use:
Code:ffmpeg -y -r 25/1 -itsoffset 00:00:00.017 -i "E:\Output\erst_mitChapter_2021-06-05@21_10_23_7810_02.mkv" -i "E:\Output\iId_3_aid_0_DELAY_17ms_2021-06-05@21_10_23_7810_01.mp2" -i "E:\Output\2021-06-05@21_10_23_7810__04.chp" -map_chapters 1 -vcodec copy -acodec copy -map 0:0 -map 1:0 -aspect 177833:100000 -r 25/1 "E:\Output\erst_mitChapter.mp4"
My chapter file looked like this:
Code:;FFMETADATA1 [CHAPTER] TIMEBASE=1/1000 START=0 END=4 title=Chapter 1 [CHAPTER] TIMEBASE=1/1000 START=5 END=19 title=Chapter 2 [CHAPTER] TIMEBASE=1/1000 START=20 END=49 title=Chapter 3 [CHAPTER] TIMEBASE=1/1000 START=50 END=59 title=Chapter 4 [CHAPTER] TIMEBASE=1/1000 START=60 END=63000 title=Chapter 5
users currently on my ignore list: deadrats, Stears555, marcorocchini -
Changing my statement to this does not make a difference:
Code:ffmpeg -i input.mp4 -i chapters.txt -map_chapters 1 -c copy out.mp4
And, when I change it to this:Code:ffmpeg -i input.mp4 -i chapters.txt -map_metadata -1 -map_chapters 1 -c copy out.mp4
-
Using
Code:MP4box -add "path to mp4" -chap "chapters.txt" -new "path to output mp4"
Code:CHAPTER01=00:00:00.000 CHAPTER01NAME=Chapter 1 CHAPTER02=00:00:05.000 CHAPTER02NAME=Chapter 2 CHAPTER03=00:00:20.000 CHAPTER03NAME=Chapter 3 CHAPTER04=00:00:50.000 CHAPTER04NAME=Chapter 4 CHAPTER05=00:01:00.000 CHAPTER05NAME=Chapter 5
But back to ffmpeg:
-------------------------------------- using
Code:-i video -i chapters -map_metadata 1:c:0
- one menu entry (no chapters) according to mediainfo
Code:Menu Count : 94 Count of stream of this kind : 1 Kind of stream : Menu Kind of stream : Menu Stream identifier : 0 Chapters_Pos_Begin : 94 Chapters_Pos_End : 94
- 'mp4box -info' reports chapters without titles
Code:Chapters: Chapter #1 - 00:00:00.000 - "" Chapter #2 - 00:00:00.005 - "" Chapter #3 - 00:00:00.020 - "" Chapter #4 - 00:00:00.050 - "" Chapter #5 - 00:00:00.060 - ""
- 'ffmpeg -i' reports: chapters without titles too
Code:Chapters: Chapter #0:0: start 0.000000, end 0.005000 Metadata: title : Chapter #0:1: start 0.005000, end 0.020000 Metadata: title : Chapter #0:2: start 0.020000, end 0.050000 Metadata: title : Chapter #0:3: start 0.050000, end 0.060000 Metadata: title : Chapter #0:4: start 0.060000, end 61.635031 Metadata: title :
- one menu entry (no chapters) according to mediainfo
- using:
Code:-i video -i chapters -map_chapters 1
- mediaInfo reports:two menu entries with chapters
Code:Menu #1 Count : 102 Count of stream of this kind : 2 Kind of stream : Menu Kind of stream : Menu Stream identifier : 0 Stream identifier : 1 StreamOrder : 1 ID : 2 ID : 2 Format : Timed Text Format : Timed Text Commercial name : Timed Text Codec ID : text Duration : 63000 Duration : 1 min 3 s Duration : 1 min 3 s 0 ms Duration : 1 min 3 s Duration : 00:01:03.000 Duration : 00:01:03.000 Language : en Language : English Language : English Language : en Language : eng Language : en Chapters_Pos_Begin : 94 Chapters_Pos_End : 99 Bit rate mode : CBR Menu For : 1 00:00:00.000 : Chapter 1 00:00:00.005 : Chapter 2 00:00:00.020 : Chapter 3 00:00:00.050 : Chapter 4 00:00:00.060 : Chapter 5 Bit rate mode : Constant Menu #2 Count : 99 Count of stream of this kind : 2 Kind of stream : Menu Kind of stream : Menu Stream identifier : 1 Stream identifier : 2 Chapters_Pos_Begin : 94 Chapters_Pos_End : 99 00:00:00.000 : Chapter 1 00:00:00.005 : Chapter 2 00:00:00.020 : Chapter 3 00:00:00.050 : Chapter 4 00:00:00.060 : Chapter 5
- mp4box reports: a broken file
Code:[iso file] Unknown box type trt00 in parent text [iso file] Box "text" (start 3083254) has 11 extra bytes [iso file] Box "stbl" (start 3083230) has 124 extra bytes [iso file] Box "moov" (start 3075932) has 205 extra bytes [iso file] Incomplete box moov - start 3075932 size 7730 [iso file] Incomplete file while reading for dump - aborting parsing [iso file] Unknown box type trt00 in parent text [iso file] Box "text" (start 3083254) has 11 extra bytes [iso file] Box "stbl" (start 3083230) has 124 extra bytes [iso file] Box "moov" (start 3075932) has 205 extra bytes Truncated file - missing 7730 bytes
- ffmpeg reports: proper chapters
Code:Chapters: Chapter #0:0: start 0.000000, end 0.005000 Metadata: title : Chapter 1 Chapter #0:1: start 0.005000, end 0.020000 Metadata: title : Chapter 2 Chapter #0:2: start 0.020000, end 0.050000 Metadata: title : Chapter 3 Chapter #0:3: start 0.050000, end 0.060000 Metadata: title : Chapter 4 Chapter #0:4: start 0.060000, end 63.000000 Metadata: title : Chapter 5
- mediaInfo reports:two menu entries with chapters
- using '-map_metadata 1' or '-map_chapters 1 -map_metadata 1' is reporting the same as when using the above '-map_chapters 1'
-> looks to me like ffmpeg is either broken atm. or they changed something I'm not aware of (I'm pretty sure '-map_chapters 1' worked fine at one point in time.
My recommendation would be to either use MP4Box instead of ffmpeg for muxing to mp4 or report the issue to the ffmpeg developers over at https://trac.ffmpeg.org/
If you report it and get a useful reply please let me know too.
Cu Selurusers currently on my ignore list: deadrats, Stears555, marcorocchini - using
-
okay,...
Code:-map_chapters 1 -movflags +faststart
Code:-map_chapters 1 -movflags +faststart -movflags disable_chpl
Code:-map_chapters 1 -movflags disable_chpl
Cu Selurusers currently on my ignore list: deadrats, Stears555, marcorocchini -
if you have timebase set to 1/1000 then your times have to be in thousands:
Entry =
[Attachment 59282 - Click to enlarge]
Results in a file named Metadata:
;FFMETADATA1
title="Wham_Last Christmas.mp4"
artist=Test
[CHAPTER]
TIMEBASE=1/1000
START=0
END=10000
TITLE=Chapter 1
[CHAPTER]
TIMEBASE=1/1000
START=10000
END=20000
TITLE=Chapter 2
[CHAPTER]
TIMEBASE=1/1000
START=20000
END=30000
TITLE=Chapter 3
[CHAPTER]
TIMEBASE=1/1000
START=30000
END=40000
TITLE=Chapter 4
[CHAPTER]
TIMEBASE=1/1000
START=40000
END=50000
TITLE=Chapter 5
[CHAPTER]
TIMEBASE=1/1000
START=50000
END=60000
TITLE=Chapter 6
"C:\Users\Bud\Desktop\TrimNMerge\TrimNMerge\bin\De bug\work\ffmpeg" -i "C:\Users\Bud\Desktop\Wham_Last Christmas.mp4" -i metadata -map_metadata 1 -codec copy "C:\Users\Bud\Desktop\TrimNMerge\TrimNMerge\bin\De bug\work\Wham_Last Christmas_Chapters.mp4"
[Attachment 59283 - Click to enlarge] -
if you have timebase set to 1/1000 then your times have to be in thousands:
(but thanks for the reminder)
Question is what does "MediaInfo --full <PATH to File>", "Mp4Box --info <PATH to file>" and "ffmpeg -i <Path to file>" report about the output.
The 'problem' I see is that MP4Box report the the files created with just -map_chapters X as broken
Code:[iso file] Unknown box type trt00 in parent text [iso file] Box "text" (start 3083242) has 11 extra bytes [iso file] Box "stbl" (start 3083218) has 124 extra bytes [iso file] Box "moov" (start 3075932) has 213 extra bytes [iso file] Incomplete box moov - start 3075932 size 7726 [iso file] Incomplete file while reading for dump - aborting parsing [iso file] Unknown box type trt00 in parent text [iso file] Box "text" (start 3083242) has 11 extra bytes [iso file] Box "stbl" (start 3083218) has 124 extra bytes [iso file] Box "moov" (start 3075932) has 213 extra bytes Truncated file - missing 7726 bytes Error opening file e:\Output\erst_mitChapter.mp4: IsoMedia File is truncated
Last edited by Selur; 6th Jun 2021 at 02:20.
users currently on my ignore list: deadrats, Stears555, marcorocchini -
-
that was related to my post since I used 1/1000 (since I usually add chapter at specific frames and not roughly at a given second)
users currently on my ignore list: deadrats, Stears555, marcorocchini -
Yes 1/1 will work for seconds, 1/100 will work for milliseconds.
MediaInfo Reports: (Truncated with only pertinent info)
General
Complete name : Wham_Last Christmas_Chapters.mp4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom (isom/iso2/avc1/mp41)
File size : 313 MiB
Duration : 4 min 37 s
Overall bit rate : 9 441 kb/s
Movie name : Wham_Last Christmas.mp4
Performer : Test
Writing application : Lavf58.49.100
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L3
Audio
ID : 2
Format : AAC LC
Format/Info : Advanced Audio Codec Low Complexity
Codec ID : mp4a-40-2
Alternate group : 1
Menus : 3
Menu #1
ID : 3
Codec ID : text
Duration : 1 min 0 s
Language : English
Bit rate mode : CBR
Menu For : 1,2
00:00:00.000 : Chapter 1
00:00:10.000 : Chapter 2
00:00:20.000 : Chapter 3
00:00:30.000 : Chapter 4
00:00:40.000 : Chapter 5
00:00:50.000 : Chapter 6
Bit rate mode : Constant
Menu #2
00:00:00.000 : Chapter 1
00:00:10.000 : Chapter 2
00:00:20.000 : Chapter 3
00:00:30.000 : Chapter 4
00:00:40.000 : Chapter 5
00:00:50.000 : Chapter 6 -
And there are the two menu entries.
One from ttxt chapters and one from itunes chapters, later one can be omitted by using '-movflags disable_chpl', what worries me is what MP4Box reports that those files the way ffmpeg creates them seem to be truncated.
-> Do you know a way to add chapter to mp4 using ffmpeg in a way that Mp4Box, ffmpeg and MediaInfo all three report the file as correct (= not broken/truncated)?
Cu Selurusers currently on my ignore list: deadrats, Stears555, marcorocchini -
-
@the_steve_randolph: using:
Code:-map_chapters 1 -movflags disable_chpl
Cu Selurusers currently on my ignore list: deadrats, Stears555, marcorocchini -
**** the original message here has been edited/deleted because of numerous corrections. The corrected version is now post #16
Last edited by the_steve_randolph; 6th Jun 2021 at 16:20. Reason: Multiple corrections shown in a separate message
-
*** This is the second posting this message - to correct and clarify various pieces of information.
OK, now I have found something even more bizarre.
I start with a DVD that has chapters and it has several non-English subtitle tracks. I use HandBrake to convert to an MP4 - let's call it X.mp4 Since I have not found any English audio tracks, I tell HandBrake to remove the original subtitle tracks and to import a subtitle file, and, tell it to burn-in those subtitles. When I view X in VLC, the original DVD subtitle tracks are gone, the imported English subtitles file is shown as a subtitle track available for selection, and, the English subtitles are burned-in. Viewing ffmpeg console output on X.mp4, there is that data stream that we have learned contains the chapter names in addition to the chapter names showing up in the "Chapters" section. That data stream looks like this:Code:Stream #0:2(eng): Data: bin_data (text / 0x74786574) Metadata: creations time: 2021-06-05T02:03:09.000000Z handler_name: SubtitleHandler
Code:ffmpeg -i X.mp4 -c copy Y.mp4
So, upon further investigation, in this folder I have X.mp4, Y.mp4, several other MP4's, as well as a subfolder of the name "Subtitles". In that "Subtitles" subfolder, I have an SRT file for each of the MP4's in the file name format of: "X - English.srt", "Y - English.srt", etc. Now, we know from the previous paragraph that viewing Y in VLC lists the imported subtitle track, it also lists two subtitle tracks from that "Subtitles" subfolder that are NOT X or Y. Just for grins, I renamed the "Subtitles" subfolder to "something else" (that is, it does not have the word "subtitle" in it). Now when I view Y in VLC, there are NO subtitle tracks listed - it is even missing the original DVD subtitle track!
To (try to) recap converting X to Y (doing nothing except "-c copy"). When there is a "Subtitles" subfolder containing multiple SRT files, viewing Y in VLC shows 3 subtitle tracks and Movies & TV shows 1 subtitle tracks. When there is no "Subtitles" subfolder, viewing Y in VLC shows 0 subtitle tracks and Movies and TV shows 0 subtitle tracks. Nowhere in this folder or subfolders are any files with the name format of "Z.srt" that any viewing app would find by default. The name of that subfolder has seemingly no effect on the available subtitle tracks when viewing X. The ffmpeg console output for X and Y are the same, showing a single data stream.
Y'all try to figure that out while I go have several beers.
**** EDIT: The reasons for only using VLC and Windows Movies & TV to view the MP4s is two-folder. First, I am trying to limit the number of variables in this testing to try to hone in on one thing at a time. Second, I have been unable to figure out how to see or select a subtitle track in these apps: Zoom Player MAX ver. Giveaway v14 build 1400, PowerDVD 19, and, Nero Showtime 4. When I use Windows Media Player to view X, under the menu option "Lyrics, captions, and subtitles", I have "On if available" clicked on, but, it is not showing subtitles from a subtitle track during playback. VLC shows the imported DVD subtitle track when viewing X and the subtitles from that track are displayed when selected.
**** SECOND EDIT: After a couple of beers, it occurs to me that the issue involved here is using ffmpeg in two different modes: default stream selection/processing versus mapping. Maybe after a few more beers and/or a very long nap, I will run a couple more tests to compare those two different modes.Last edited by the_steve_randolph; 6th Jun 2021 at 16:28.
-
-
That "Menu #2" info came from "Budman 1" not me. And, I don't know what he is trying to tell me with showing output but not commenting on it.
I first posted the changing from 1/1 to 1/1000 because I thought it gave better accuracy, as Selur mentioned.
Then I posted a method that will add successfully add Chapter marks, without realizing the 2nd menu was a problem. (Should have read slower).
After a little research, I found the second menu is located in the 'CHPL' atom and if you remove,disable, or zero it out, you can eliminate the 2nd menu.
Sorry for my confusion. -
as a side note: when using vlc, make sure you don't have subtitles names the same as the original file you are playing next to the file, otherwise those files will be listed as subtitles and might cause confusion
users currently on my ignore list: deadrats, Stears555, marcorocchini -
-
-
Inside the mp4 container data is stored in atoms. The 'chpl' atom is an entry recognized by itunes/Apple to store chapter data.
And, perhaps just as important, what are "Chapter marks" compared to my usage of the term of just "chapters"?users currently on my ignore list: deadrats, Stears555, marcorocchini -
-
OK, so, if I want to look for " 'CHPT' atom" in ffmpeg console output, am I looking at the "Chapters:" section?
-
In my testing (and Selur can tell you this), I am trying to reduce the number of apps so that I don't introduce more variables in the testing. Since I am using ffmpeg to execute the conversion commands, and, ffmpeg can show me lotsa information, I prefer to at least start with ffmpeg. So, can ffmpeg show me the " 'CHPL' atom" information?
-
Looking back on this thread to see if I missed something, I have a few questions.
Selur said to use this command:Code:-map_chapters 1 -movflags disable_chpl
Code:ffmpeg -i X.mp4 -i chapters.txt -map_metadata 1 -map_chapters 1 -movflags disable_chpl -c copy Z.mp4
Looking at "Budman 1"s posts, I still don't understand what you are trying to tell me. You seem to be saying that there is extra information in this " 'CHPL' atom" that is not shown in ffmpeg console output, and, you are recommending additional apps that will reveal that information.
OK, let's say that is true. But, you have failed to say what I am supposed to do with that information. What would that information tell me? What will I look for or see that will tell me what is wrong? And, most importantly, what will I do with that information to create a ffmpeg command that will resolve my overall problem? Do you have a recommended ffmpeg command? -
Ok... Not sure what was the starting goal was any more but to take an existing MP4 and add Chapters to it and/or subtitles (as a track) and assuming you have a valid "Metadata" file:
Code:"ffmpeg" -i "C:\Users\Bud\Desktop\Wham_Last Christmas.mp4" -i "C:\Users\Bud\Desktop\metadata" -i "C:\Users\Bud\Desktop\Subtitles.srt" -c copy -c:s mov_text -map_metadata 1 -movflags disable_chpl "C:\Users\Bud\Desktop\Wham_Last Christmas_Chapterssubs.mp4"
Code:"ffmpeg" -i "C:\Users\Bud\Desktop\Wham_Last Christmas.mp4" -i "C:\Users\Bud\Desktop\metadata" -map_metadata 1 -movflags disable_chpl -c copy "C:\Users\Bud\Desktop\Wham_Last Christmas_Chaptersnosubs.mp4"
-
The issue is that I have multiple MP4 files that have chapters, but, the names are in a data stream, which shows up in VLC as a subtitle track. But, that subtitle track only shows the chapter names. So, I want to get rid of the data stream without losing the chapter names. Your ffmpeg commands have already been tried and they don't resolve the issue.
-
OK, as part of this project and thread, I have now tried to play my MP4 files on the disc player connected to my TV. The player is "LG UP870", which is a 4K Blu-ray player and these MP4s have chapter names (and in the MP4 data stream). The files played fine, but, there was no indication that there are chapters in the MP4 and I don't have the ability to skip ahead to a specific chapter time. I don't know if this is a "failure" of the player or the fact that the chapter names are also in the data stream. Since the chapter times exist in the MP4, I suspect that my player cannot figure out that there are chapters - for whatever reason. Obviously it would be nice to have functioning chapters to be able to skip ahead to a desired scene, and, that is actually part of the "desired results". There are other options for me to try (i.e. convert to a MKV that has chapters) that I have to test. While I understand that everybody's situation may be different, any feedback from others would be appreciated.
I am kinda torn as to what to do right now. My HDD is running out of space and I need to burn these files and move on to other videos/projects. For the time being, I will burn them to DVD-RW discs, hoping that I can find a resolution to this chapter/data stream issue and "fix" these MP4s in the future. I guess that having the data stream and VLC being a bit confused is acceptable, but, I really want to be able to view these videos on my 55" TV in the future. I can tell Windows that I have 2 monitors and drag the VLC app to the TV to view it. But, I would really like to have a resolution to this chapter/data stream issue so that I can deal with future files/projects. How much are others "worrying" about this situation?Last edited by the_steve_randolph; 7th Jun 2021 at 22:37.
Similar Threads
-
Adding subs and chapters to mp4
By rumblylwc in forum SubtitleReplies: 17Last Post: 10th Nov 2021, 09:27 -
Renaming chapters in an mp4 from a text file
By RandmTask in forum Video ConversionReplies: 5Last Post: 24th Sep 2020, 04:06 -
.DATA files to .MP4 PLEASE FOR THE LOVE OF GOD SOMEBODY HELP!!!! LOL
By WiseGyeBri in forum Newbie / General discussionsReplies: 4Last Post: 11th Feb 2020, 18:29 -
Which Player for MP4 / M4A with chapters?
By Rigsel in forum Newbie / General discussionsReplies: 7Last Post: 24th Nov 2019, 08:09 -
Adding Chapters To Mp4 File
By wulf109 in forum Video ConversionReplies: 5Last Post: 6th Sep 2017, 21:35