Batch/bulk merging/including of subtitles

Discussion of the HandBrake command line interface (CLI)
Forum rules
An Activity Log is required for support requests. Please read How-to get an activity log? for details on how and why this should be provided.
Post Reply
bpleat
Posts: 2
Joined: Sat Sep 14, 2019 8:13 am

Batch/bulk merging/including of subtitles

Post by bpleat » Sat Sep 14, 2019 8:27 am

Description of problem or question:

I'm trying to loop, via batch file, through all my folders and, where subtitles are present, merge them into existing files.
Subtitles could be srt/sub/idx/etc., basically any format.
Most are English, but a few are other languages.
The video files could be MP4, MKV, AVI.

I don't want to "burn in" the subtitles, I just want them available.

I don't want to reencode any of the files, just add in the subtitles so I don't need the separate subtitle files.

I'd appreciate it someone could share the proper-syntax command line to do this.

I have the (however inelegant) framework (batch file), basically:
For /R %%A in (D:\Movies) Do (
If Exist %%~dpn.srt (
[awaiting HandbrakeCLI synax]
Del %%~dpn.srt
)
For /R %%B in ("%%~dpn.?_Eng.srt") Do (
[awaiting HandbrakeCLI synax]
Del %%B
)
If Exist %%~dpn.ITA.srt (
[awaiting HandbrakeCLI synax]
Del %%~dpn.srt
)
For /R %%B in ("%%~dpn.?_Ita.srt") Do (
[awaiting HandbrakeCLI synax]
Del %%B
)
If Exist %%~dpn.sub (
[awaiting HandbrakeCLI synax]
Del %%~dpn.srt
)
If Exist %%~dpn.idx (
[awaiting HandbrakeCLI synax]
Del %%~dpn.srt
)
[repeat for each subtitle format]
)

What I'm missing is a simple clear understanding of the CLI to only embed (but not "burn in") the subtitles, without otherwise re-encoding each file.

Appreciate your help in advance.

HandBrake version (e.g., 1.0.0):
1.2.2

Operating system and version (e.g., Ubuntu 16.04 LTS, macOS 10.13 High Sierra, Windows 10 Creators Update):
Windows 10

HandBrake Activity Log ***required*** (see How-to get an activity log)
N/A

Code: Select all

Please replace this text with the contents of your log file between the two code tags - OR -  provide a pastebin URL in place of these 3 lines.

User avatar
s55
HandBrake Team
Posts: 9535
Joined: Sun Dec 24, 2006 1:05 pm

Re: Batch/bulk merging/including of subtitles

Post by s55 » Sat Sep 14, 2019 10:08 am

HandBrake is not the tool your looking for. We don't support pure muxing, nor AVI, Not all of the above subtitle options.

Try ffmpeg command line instead.

User avatar
Rodeo
HandBrake Team
Posts: 12195
Joined: Tue Mar 03, 2009 8:55 pm

Re: Batch/bulk merging/including of subtitles

Post by Rodeo » Sat Sep 14, 2019 12:07 pm

Or mkvmerge CLI, if your output is MKV.

bpleat
Posts: 2
Joined: Sat Sep 14, 2019 8:13 am

Re: Batch/bulk merging/including of subtitles

Post by bpleat » Sat Sep 14, 2019 11:44 pm

s55 and Rodeo, thank you for your view.

(Realizing this is out of normal scope for this forum) Thoughts on the syntax for ffmpeg and mkvmerge? I've been unsuccessful with both...

s55, why can't I use HandBrake for this? (I don't know what "muxing" is.)
(I understand I might need to specify a new (temp) target file and then move the temp file on top of my original.)

Again, thank you in advance.

rollin_eng
Veteran User
Posts: 3163
Joined: Wed May 04, 2011 11:06 pm

Re: Batch/bulk merging/including of subtitles

Post by rollin_eng » Sun Sep 15, 2019 7:44 am

HB is a video converter, therefore it always reencodes the video.

User avatar
JohnAStebbins
HandBrake Team
Posts: 5442
Joined: Sat Feb 09, 2008 7:21 pm

Re: Batch/bulk merging/including of subtitles

Post by JohnAStebbins » Sun Sep 15, 2019 3:07 pm

bpleat wrote:
Sat Sep 14, 2019 11:44 pm
I don't know what "muxing" is.
Muxing is the process of putting raw media streams (audio, video, subtitles, etc) into a container. Demuxing does the reverse, extracts them from the container. Remuxing demuxes and then muxes. HandBrake also transcodes the video. I.e. it decodes the raw video stream into raw frames composed of pixels and encodes those raw frames to a new format.

HandBrake also only supports muxing to 2 container types, mp4 and mkv.

What you want to do is called remuxing. You want to keep the original media streams and add a new stream. This requires demuxing the original file to get the original streams, then muxing those original streams plus your new stream to a new file.

mduell
Veteran User
Posts: 6669
Joined: Sat Apr 21, 2007 8:54 pm

Re: Batch/bulk merging/including of subtitles

Post by mduell » Sun Sep 15, 2019 6:40 pm

bpleat wrote:
Sat Sep 14, 2019 11:44 pm
(Realizing this is out of normal scope for this forum) Thoughts on the syntax for ffmpeg and mkvmerge? I've been unsuccessful with both...
They have their own support forums.

Post Reply