How can I mix two movies together before I handbrake them?

8

5

How can I mix two movies together before I handbrake them?

I've got a two part movie on my disk as a pair of VideoTS folders. I want to generate one output movie. I plan on using handbrake to do the encoding, unless someone can point out a better way to do it. The final intent is to create a video file for my iPhone or iPod. I've got about 90 videos already like this, but never done a two-parter.

Am I forced to handbrake it and then reauthor it using another platform? I can do that, but figured there was an easier way to do it. If there is another bit of software that changes my workflow but does this in less steps, I can accept that as an answer as well.

If there isn't a way to combine the two into one video file neatly, then my choice will be to open it in something like Windows Live Movie Maker and just mix the two input mp4/m4v into one file.

jcolebrand

Posted 2012-01-29T18:09:42.350

Reputation: 1 020

3Just remove the first paragraph and the name of the movie and nobody will care. There are enough free movies, or movies you could have created yourself, to make this a generally useful topic without implied legal issues. – Daniel Beck – 2012-01-29T18:13:28.330

Think so? I wasn't sure. – jcolebrand – 2012-01-29T18:19:30.390

Yeah, never saw somebody ranting about that here, like ever. Basically, you don't want to ever re-encode anything. I would suggest to rip them both to h.264 / MP4 using Handbrake and the exact same settings, then merging them with a tool like MP4Box.

– slhck – 2012-01-29T18:27:57.447

So technically, @slhck, I want to ask how to reflow two video files together with something like MP4Box instead of asking how to do it with handbrake? Reckon I should start a new Q and leave this one for the googlers? – jcolebrand – 2012-01-29T18:31:48.627

No, it's fine to stay. The solution is kinda the same, I guess. I'm just trying to find out how to do that all on Windows :) – slhck – 2012-01-29T18:34:03.087

If you do type it up as an answer, I think you should definitely include about how re-encoding would be bad here, since I mentioned that. :-\ – jcolebrand – 2012-01-29T18:34:51.617

As always, let me know if you experience any problem with this approach. It worked for me – but it's always difficult to answer for another system. – slhck – 2012-01-29T18:46:59.230

I'm in the process of encoding the two videos according to the first part of the process, and will then run the MP4Box afterwards, and then will test watch on my iPod/iPhone later tonight. Let you know after that point. – jcolebrand – 2012-01-29T20:00:03.647

Answers

6

How to approach this

If you have two input movies, and want to generate one output movie, you should try not to re-encode them as you go, but rather take the original bitstream.

In your case, the possibilities are either:

VideoTS Part 1 → MP4 Part 1
VideoTS Part 2 → MP4 Part 2
MP4 Part 1 & MP4 Part 2 → Final MP4

… or:

VideoTS Part 1 & VideoTS Part 2 → Intermediate Video
Intermediate Video → Final MP4

Concatenating with MP4Box

I would choose the first option since I don't know if there's any tool that would take the "raw" DVD files and concatenate them for you.

You can simply use Handbrake to encode the videos to MP4 files with appropriate settings (e.g. using the iPhone or iPod presets). It's important you choose exactly the same settings for both videos.

Then, use MP4Box to concatenate those:

mp4box -cat video-a.mp4 -cat video-b.mp4 final.mp4

Why you shouldn't re-encode

The important part is that you actually use a tool like MP4Box to concatenate the videos, and not a Non Linear Editor like Windows Movie Maker. As far as I know, WMM will not allow you to just copy the h.264 codec bitstreams, but needs to re-encode the video after you've concatenated them.

This means that you will experience generation loss, like you know from JPEG images. It might not be noticeable, but I don't know how good Windows Movie Maker's encoder even is to begin with. I would doubt the quality would be the same.

slhck

Posted 2012-01-29T18:09:42.350

Reputation: 182 472

New tool and everything! Yay workflows! I honestly didn't think it would cause generation loss to do that in WMM, but now that you point it out, that makes some sense. I thought maybe Handbrake could do the job alone. Ah well, this will be great! – jcolebrand – 2012-01-29T18:46:48.777

6

I haven't been able to do it in Handbrake (Kev's answer suggests it's possible with batch conversion but that doesn't work for me) but ffmpeg supports it using its concatenate feature. Concatenate multiple input files and encode the video stream with x264 and copy the audio stream to a single MP4 output file:

ffmpeg -f concat -i files.txt -c:v libx264 -crf 22 -c:a copy output.mp4

files.txt is a list of input files in the format

file '/path/to/file1'
file '/path/to/file2'

kynan

Posted 2012-01-29T18:09:42.350

Reputation: 2 646

4I would even recommend ffmpeg -f concat -i files.txt -c:v copy -c:a copy output.mp4 (resp. output.avi or similar), which is faster and does no re-encoding as @slhck recommends. – white_gecko – 2016-05-20T19:12:21.200

1

There is no need to re-encode. To combine the .VOB files in the VideoTS folder:

  1. Copy them to your harddrive.
  2. Open a DOS command prompt
  3. Go to the directory where you copied the files
  4. and the use the following command

    copy /B VTS_xx_1.VOB+VTS_xx_2.VOB newmovie.mpg

For xx use the number from the actual file information.

This will combine them into a single mpg output file that you can then Handbrake into a smaller file by selecting an mp4 format. You should Handbrake them or the resulting file will have timing issues. E.g. a 2 hour movie may show as 5 minutes in length.

Generally the VOB file size(s) are 1,073,739,776 plus one remainder file To be sure, play the VOB files first by double-clicking them to make sure they are the ones you want.

Draat

Posted 2012-01-29T18:09:42.350

Reputation: 11

-1

If you drop all the files in one directory with names that put them in the right order then open the directory in handbrake (rather than the files) it will automatically merge them - so no need to merge before hand.

  • I randomly tried that after failing to get other things to work (YMMV).

Kev

Posted 2012-01-29T18:09:42.350

Reputation: 7

1Doesn't work for me. Handbrake only encodes one title at a time, couldn't find an option for merging. – kynan – 2015-02-12T20:37:52.280

doesn't work for me either. Using v0.10.0 – some user – 2016-04-19T04:29:29.317

1You should fix your answer in order for it to be understand easily. And don't place a bullet without a list like that – phuclv – 2013-10-21T08:48:44.357