

"c:\ffmpeg\bin\ffmpeg" -ss %%H -to %%I -i %1 -vn -c:a libmp3lame -b:a 32k -ac 1 -metadata title="%%J" -id3v2_version 3 -write_id3v1 1 -y "%~dpnx1-!padded:~-3!.mp3"įor your video file file, I have changed it to the following to handle both video and audio data by straight copying. This exports MP3-file numbered by chapter to the same path as the source file: offįor /f "tokens=2,5,7,8 delims=," %%G in ('c:\ffmpeg\bin\ffprobe -i %1 -print_format csv -show_chapters -loglevel error 2^> nul') do ( I don't know python or bash, and I am no expert in batch at all, but I tried to read up on how one might do it, and came up with the following which seems to work. m4b audiobook myself the other day, and stumbled over this thread and others, but I couldn't find any examples using batch-script. (Ie, the title and chapter data are found in separate loops through the metadata output)īut it works and it should save you a lot of time. It's also inelegant as there were many hoops to jump through since it is processing the metadata line by line. This took a good bit to figure out since I'm definitely NOT a Python guy.

Output = sp.check_output(command, stderr=sp.STDOUT, universal_newlines=True) # when it does not get one so we need to capture stderr, # ffmpeg requires an output file and so it errors

If you want to improve please submit pull requests. Python isn't my first language but I noticed you use it so I figure writing it in Python might make more sense. I tested it on several videos and it worked well. If I was writing this again I'd use ffprobe's json options You can get chapters using: ffprobe -i fname -print_format json -show_chapters -loglevel error (Edit: This tip came from via this issue: )
