Multiple Inputs

Questions involving a Windows version of FFmpeg.
tommik
Posts: 5
Joined: Tue Mar 06, 2018 5:50 pm

Multiple Inputs

Post by tommik » Tue Mar 06, 2018 5:59 pm

Hi,

1. I'm trying to convert DVDs to .mp4 files with ffmpeg - which works fine. However, there are lots of DVDs and I'm tired of writing the command and waiting for the process to end.
I'm new to this, so all I do right now is:
ffmpeg -i "input.vob" c:v copy c:a copy output.mp4"
Is there a way to process multiple inputs ony by one?

2. Also, some DVDs split single videos into two sequences. Is there a way to merge them?
Maybe something like
ffmpeg -i "input1.vob" "input2.vob" c:v copy c:a copy output1+2.mp4
Thank you!

User avatar
Zeranoe
Site Admin
Posts: 702
Joined: Sat May 07, 2011 7:12 pm
Contact:

Re: Multiple Inputs

Post by Zeranoe » Thu Mar 08, 2018 9:26 pm

Simple batch for (assuming input.vob is a variable filename):

Code: Select all

for %i in (*.vob) do @ffmpeg -i %i -c copy %~ni.mp4
To merge you want concatenation: https://trac.ffmpeg.org/wiki/Concatenate

tommik
Posts: 5
Joined: Tue Mar 06, 2018 5:50 pm

Re: Multiple Inputs

Post by tommik » Sun Mar 11, 2018 12:15 pm

Thanks for your reply.

Unfortunately I don't really get it :D
I have 20 DVD-folders. Each has about 3 .vob files in it. So what do I have to edit in your code?

Code: Select all

for %i in (*.vob) do @ffmpeg -i %i -c copy %~ni.mp4
Sorry, but I'm absolutely new to this.

roderrooder
Posts: 62
Joined: Tue Jan 02, 2018 10:41 am

Re: Multiple Inputs

Post by roderrooder » Wed Mar 14, 2018 7:12 pm

If you are simply trying to circumvent doing each file individually just stack the commands, merging some is a bit more confusing though...

To concatenate video files you could use an additional text file that contains paths to each file you want to merge.

I will be using a file path to the windows videos folder for all examples, you will need to replace this with the actual path. So the txt file should contain something like this:

Code: Select all

file 'C:\Users\[Username]\Videos\DVD\input1.vob'
file 'C:\Users\[Username]\Videos\DVD\input2.vob'


Each file must be separated by line breaks and formated just like I did above.

Save that to where ever you want, but for this example lets say we save it to the Documents folder within windows as "concatenate.txt"

You now need another command that reads that file with the concat function:

Code: Select all

ffmpeg -f concat -safe 0 -i C:\Users\[Username]\Documents\concatenate.txt c:v copy c:a copy C:\Users\[Username]\Videos\DVD\output1+2.mp4


concat is the function, -safe 0 just tells FFMPEG that is safe to read from the input file, now lets put everything together.

First you would need to make multiple concatenate.txt files for each time you concatenate videos. You could do it with just one concatenate text file editing and saving it between runs, but you'd like to do it all at once no? Something like this:

concatenate1.txt:

Code: Select all

file 'C:\Users\[Username]\Videos\DVD3\input1.vob'
file 'C:\Users\[Username]\Videos\DVD3\input2.vob'
concatenate2.txt:

Code: Select all

file 'C:\Users\[Username]\Videos\DVD6\input1.vob'
file 'C:\Users\[Username]\Videos\DVD6\input2.vob'
So now lets say you want to do multiple DVD files at once while concatenating some here and there using the files we just created, it should look something like this:

Code: Select all

ffmpeg -i C:\Users\[Username]\Videos\DVD1\input.vob c:v copy c:a copy C:\Users\[Username]\Videos\DVD1\output.mp4 ^
-i C:\Users\[Username]\Videos\DVD2\input.vob c:v copy c:a copy C:\Users\[Username]\Videos\DVD2\output.mp4 ^
-f concat -safe 0 -i C:\Users\[Username]\Documents\concatenate1.txt c:v copy c:a copy C:\Users\[Username]\Videos\DVD3\output1+2.mp4 ^
-i C:\Users\[Username]\Videos\DVD4\input.vob c:v copy c:a copy C:\Users\[Username]\Videos\DVD4\output.mp4 ^
-i C:\Users\[Username]\Videos\DVD5\input.vob c:v copy c:a copy C:\Users\[Username]\Videos\DVD5\output.mp4 ^
-f concat -safe 0 -i C:\Users\[Username]\Documents\concatenate2.txt c:v copy c:a copy C:\Users\[Username]\Videos\DVD6\output1+2.mp4 ^
-i C:\Users\[Username]\Videos\DVD7\input.vob c:v copy c:a copy C:\Users\[Username]\Videos\DVD7\output.mp4
The carrot symbol (^) represents line breaks when using CMD in windows. If you are using Linux I'm not sure what represents a line break but I'm sure there is something, I like to use line breaks to keep everything clean.

concat documentation:
https://trac.ffmpeg.org/wiki/Concatenate

tommik
Posts: 5
Joined: Tue Mar 06, 2018 5:50 pm

Re: Multiple Inputs

Post by tommik » Fri Mar 16, 2018 9:23 pm

Thank you roderrooder! The merging works like a charm :)

I can't convert more than one video per command, though.
If I use this code 1.mp4 and 2.mp4 are the same videos?! What do I do wrong?

Code: Select all

ffmpeg -i "VTS_01_1.vob" -c copy "1.mp4" ^ -i "VTS_02_1.vob" -c copy "2.mp4"

roderrooder
Posts: 62
Joined: Tue Jan 02, 2018 10:41 am

Re: Multiple Inputs

Post by roderrooder » Sun Mar 18, 2018 12:10 pm

Maybe you have to use the -map flag.

Try:

Code: Select all

ffmpeg -i "VTS_01_1.vob" -map 0:0,0:1 -map 0:1 -c copy "1.mp4" ^
-i "VTS_02_1.vob" -map 1:0,1:1 -map 1:1 -c copy "2.mp4" 
-map 0:0,0:1 should sync channel 0:0 (video) and 0:1 (audio) while mapping the video stream to channel 0:0. -map 0:1 will then map the audio to it's own stream but to the same output as the video.

Then just increment the first digit for each output like I did for the second line, 1:0 & 1:1 instead of 0:0 & 0:1.

So if you did four lines it would look something like this:

Code: Select all

ffmpeg -i "VTS_01_1.vob" -map 0:0,0:1 -map 0:1 -c copy "1.mp4" ^
-i "VTS_02_1.vob" -map 1:0,1:1 -map 1:1 -c copy "2.mp4" ^
-i "VTS_03_1.vob" -map 2:0,2:1 -map 2:1 -c copy "3.mp4" ^
-i "VTS_04_1.vob" -map 3:0,3:1 -map 3:1 -c copy "4.mp4" 
I think, I could be wrong about some of that.

tommik
Posts: 5
Joined: Tue Mar 06, 2018 5:50 pm

Re: Multiple Inputs

Post by tommik » Sun Mar 18, 2018 1:10 pm

Thanks, again! Really appreciate your help.
Doesn't really work, though. I get this error:

Code: Select all

[mp4 @ 00000200122373c0] Could not find tag for codec dvd_nav_packet in stream #0, codec not currently supported in container
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Stream mapping:
  Stream #0:0 -> #0:0 [sync #0:1] (copy)
  Stream #0:1 -> #0:1 (copy)
  Stream #1:0 -> #1:0 [sync #1:1] (copy)
  Stream #1:1 -> #1:1 (copy)
  Stream #2:0 -> #2:0 [sync #2:1] (copy)
  Stream #2:1 -> #2:1 (copy)
  Stream #3:0 -> #3:0 [sync #3:1] (copy)
  Stream #3:1 -> #3:1 (copy)
    Last message repeated 1 times
If it's important, also:

Code: Select all

Input #0, mpeg, from 'VTS_01_1.vob':
  Duration: 00:23:45.60, start: 0.237711, bitrate: 4699 kb/s
    Stream #0:0[0x1bf]: Data: dvd_nav_packet
    Stream #0:1[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, bt470bg, top first), 720x576 [SAR 16:15 DAR 4:3], 25 fps, 25 tbr, 90k tbn, 50 tbc

roderrooder
Posts: 62
Joined: Tue Jan 02, 2018 10:41 am

Re: Multiple Inputs

Post by roderrooder » Mon Mar 19, 2018 5:08 pm

Hmm, any way you could upload a zip of some of your files somewhere so I could troubleshoot it myself?

tommik
Posts: 5
Joined: Tue Mar 06, 2018 5:50 pm

Re: Multiple Inputs

Post by tommik » Mon Mar 19, 2018 5:44 pm

Unfortunately not...

But I don't really get how it's working well when I convert one file per command manually and it doesn't work when I use "^". That makes no sense to me.

roderrooder
Posts: 62
Joined: Tue Jan 02, 2018 10:41 am

Re: Multiple Inputs

Post by roderrooder » Tue Mar 20, 2018 8:48 pm

Does each file contain an audio track?

Also, ^ just represents a line break, when you use it you just need to make sure spacing is correct.

Code: Select all

(code) ^
(code) ^
(code) ^
(code)
There needs to be a space between the last component in the line and then a line break immediately after.

(code)(space)^

Are you using CMD in windows? Or are you in Linux?

Post Reply