My DVD player is getting old and fast forward for MP4 files on a USB drive doesn't always work very well. Could someone tell me how to write a DOS batch file to add chapters every 10 minutes to MP4 files with ffmpeg?
It would be very much appreciated...
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays! or rip iTunes movies!
+ Reply to Thread
Results 1 to 5 of 5
Thread
-
-
Hello. The batch file just got edited. I missed a % character. If it fails for you, grab it again.
I've found over the years the simplest way is by doing a 2 step tango.
The following batch file creates a new MKV file in the New\ folder.
Changes to that folder.
Creates a new MP4 next to the MKV.
The process is almost a direct stream copy for all tracks and is quick.
There are no chapter titles, etc. In fact nothing but chapter markers. TWICE.
Yeah, you end up with 2 lots of chapter markers. It doesn't seem to hurt anything. Check it with MediaInfo.
There's probably a fix for that, but I'm not bothered.
It is quick and easy.
Code:@echo off :: MP4 - MKV with chapters. if not exist New\*.* md New for %%a in ("*.mp4") do "C:\Program Files\MKVToolNix\mkvmerge.exe" --ui-language en "%%a" --output "New\%%~na.mkv" --generate-chapters interval:00:10:00.000 --track-order 0:0,0:1 cd New for %%a in ("*.mkv") do ffmpeg -i "%%a" -codec copy -threads 0 -y "%%~na.mp4" pause
Every video I have these days plays wirelessly through a laptop under my TV. All MKV.
CheersLast edited by pcspeak; 15th Jan 2022 at 20:39. Reason: Left a % character off.
-
Thanks, Mate!
Any chance you could edit it and remove the MKV stuff? I pretty much do the same thing as you, I bought a laptop specifically to use as a movie player. (Fortunately, right before the pandemic hit and the price for the same laptop went up by nearly 50%!) But nearly all of my videos are MP4 files. The only MKV files I have are MakeMKV copies of some of my DVDs.
I have been using Drax and that method works ok, but it's one file at a time and that can be a bit time consuming. Based on what little I know about using ffmpeg in batch files, your batch appears to me to be able to do multiple videos at a time without changing the batch file, which is exactly what I was hoping to find. However, I freely admit that I probably know considerably less than I think I do about all sorts of things. So I could be way off base on that. Which is why I don't assume that I know what I don't and I am always eager to learn more. Even if the ol' sponge in my head isn't as absorbent as it used to be... -
The batch file is to work with MP4 videos.
MKV is only an interim step and any MKV videos can be deleted.
It's the easiest way I know of to add chapters.
Grab a copy of mkvmerge.exe and put it with ffmpeg.exe.
The following changes wil clean up all MKV videos in the New\ folder.
Code:@echo off :: MP4 -> MKV -> MP4 with chapters. if not exist New\*.* md New for %%a in ("*.mp4") do mkvmerge.exe --ui-language en "%%a" --output "New\%%~na.mkv" --generate-chapters interval:00:10:00.000 --track-order 0:0,0:1 cd New for %%a in ("*.mkv") do ffmpeg -i "%%a" -codec copy -threads 0 -y "%%~na.mp4" del *.mkv pause
-
Cool, thanks. 10 or 15 years ago I would have thought of that myself... I guess I am getting old.
Edit: Works like a charm. Very fast, and does do multiple files. Which will really speed things up. Thanks again, Mate!Last edited by Axel Slingerland; 22nd Jan 2022 at 00:47.
Similar Threads
-
Visual Tool for Adding Custom Chapters in MKV?
By hurricane1951 in forum EditingReplies: 2Last Post: 18th Feb 2022, 00:51 -
Adding subs and chapters to mp4
By rumblylwc in forum SubtitleReplies: 17Last Post: 10th Nov 2021, 09:27 -
Adding audio to specific MKV chapters
By zomzom82 in forum Video ConversionReplies: 2Last Post: 22nd Jan 2020, 10:18 -
Batch Adding Chapters to Multiple MKV Files
By Shady in forum Newbie / General discussionsReplies: 15Last Post: 2nd Jun 2018, 09:34 -
Adding Chapters To Mp4 File
By wulf109 in forum Video ConversionReplies: 5Last Post: 6th Sep 2017, 21:35