Joining MP4 files with the command line

Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
Veerstryngh Thynner

Joining MP4 files with the command line

Post by Veerstryngh Thynner »

Hello all,

My platform is KDE Mint (Qiana 17), on a Lenovo laptop. For heavy duty I'm using my desktop (also Qiana 17). Furthermore, the latest version of ffmpeg has been installed on both.

My issue:

Recently, a .mp4 video file had to be split in order to be dispatched to a friend overseas. I found this Konsole command working very nicely indeed:

ffmpeg -i ORIGINALFILE.mp4 -acodec copy -vcodec copy -ss START -t LENGTH OUTFILE.mp4

But now I'm wondering how to restore a feature-length film split up in parts (as often is the case on YouTube, for instance) to its original whole: also with the command line, of course. Nine separate segments to be rejoined, in my case. And codecs and containers are all the same, in this batch (all in .mp4), so encoding won't be necessary, I figure.

I tried this with PiTiVi (v. 0.93, in my system) before. But even three days of rendering (on my desktop) didn't leave anything on show. Avidemux (v. 2.5.4) was also less than helpful. So now I'm hoping for some helpful advice as to what the correct command line might be.

Veerstryngh Thynner
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 5 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
jimallyn
Level 19
Level 19
Posts: 9075
Joined: Thu Jun 05, 2014 7:34 pm
Location: Wenatchee, WA USA

Re: Joining MP4 files with the command line

Post by jimallyn »

I'm not sure, but I think maybe cat will do that. A while back there was some discussion about joining media files with cat, but I don't know for sure that it will do MP4s.
“If the government were coming for your TVs and cars, then you'd be upset. But, as it is, they're only coming for your sons.” - Daniel Berrigan
Veerstryngh Thynner

Re: Joining MP4 files with the command line

Post by Veerstryngh Thynner »

Hi there,

Thanks very much for your reply. Do you happen to remember where that discussion can be found?

Veerstryngh Thynner
Veerstryngh Thynner

Re: Joining MP4 files with the command line

Post by Veerstryngh Thynner »

In the meanwhile, I tried out the cat command myself

I found this tutorial online:

http://www.linuxandlife.com/2012/07/use ... files.html

Accordingly, I tried to join 3 parts out of the total 9:

/home/--/Videos/HITCHCOCK processed/2008 THE 39 STEPS remake 1 to 9/2008 THE 39 STEPS 1 to 9/3 39 $ 3P$ 1.mp4
/home/--/Videos/HITCHCOCK processed/2008 THE 39 STEPS remake 1 to 9/2008 THE 39 STEPS 1 to 9/3 39 $ 3P$ 2.mp4
/home/--/Videos/HITCHCOCK processed/2008 THE 39 STEPS remake 1 to 9/2008 THE 39 STEPS 1 to 9/3 39 $ 3P$ 3.mp4

And this is the read-out:

]> cat /home/--/Videos/HITCHCOCK processed/2008 THE 39 STEPS remake 1 to 9/2008 THE 39 STEPS 1 to 9/3 39 $ 3P$ 1.mp4 /home/--/Videos/HITCHCOCK processed/2008 THE 39 STEPS remake 1 to 9/2008 THE 39 STEPS 1 to 9/3 39 $ 3P$ 2.mp4 /home/--/Videos/HITCHCOCK processed/2008 THE 39 STEPS remake 1 to 9/2008 THE 39 STEPS 1 to 9/3 39 $ 3P$ 3.mp4
cat: /home/--/Videos/HITCHCOCK: No such file or directory
cat: processed/2008: No such file or directory
cat: THE: No such file or directory
cat: 39: No such file or directory
cat: STEPS: No such file or directory
cat: remake: No such file or directory
cat: 1: No such file or directory
cat: to: No such file or directory
cat: 9/2008: No such file or directory
cat: THE: No such file or directory
cat: 39: No such file or directory
cat: STEPS: No such file or directory
cat: 1: No such file or directory
cat: to: No such file or directory
cat: 9/3: No such file or directory
cat: 39: No such file or directory
cat: $: No such file or directory
cat: 3P$: No such file or directory
cat: 1.mp4: No such file or directory
cat: /home/peter/Videos/HITCHCOCK: No such file or directory
cat: processed/2008: No such file or directory
cat: THE: No such file or directory
cat: 39: No such file or directory
cat: STEPS: No such file or directory
cat: remake: No such file or directory
cat: 1: No such file or directory
cat: to: No such file or directory
cat: 9/2008: No such file or directory
cat: THE: No such file or directory
cat: 39: No such file or directory
cat: STEPS: No such file or directory
cat: 1: No such file or directory
cat: to: No such file or directory
cat: 9/3: No such file or directory
cat: 39: No such file or directory
cat: $: No such file or directory
cat: 3P$: No such file or directory
cat: 2.mp4: No such file or directory
cat: /home/--/Videos/HITCHCOCK: No such file or directory
cat: processed/2008: No such file or directory
cat: THE: No such file or directory
cat: 39: No such file or directory
cat: STEPS: No such file or directory
cat: remake: No such file or directory
cat: 1: No such file or directory
cat: to: No such file or directory
cat: 9/2008: No such file or directory
cat: THE: No such file or directory
cat: 39: No such file or directory
cat: STEPS: No such file or directory
cat: 1: No such file or directory
cat: to: No such file or directory
cat: 9/3: No such file or directory
cat: 39: No such file or directory
cat: $: No such file or directory
cat: 3P$: No such file or directory
cat: 3.mp4: No such file or directory


Next I tried was locating the files above with the command cd, in preparation of another effort. The read-out of that below:

> cd /home/--/videos/HITCHCOCK processed/2008 THE 39 STEPS remake 1 to 9/2008 THE 39 STEPS 1 to 9/
bash: cd: /home/--/videos/HITCHCOCK: No such file or directory


Although those files aforementioned are definitely in my system, Konsole is still unable to find them. Secondly, I'm not really well-versed as to the command line: I obviously got the syntax wrong, first time round - as the first readout clearly shows.

I'd really appreciate it if someone could put me on the right track. What is the proper command syntax here?

Thanks very much.

Veerstryngh Thynner
User avatar
jimallyn
Level 19
Level 19
Posts: 9075
Joined: Thu Jun 05, 2014 7:34 pm
Location: Wenatchee, WA USA

Re: Joining MP4 files with the command line

Post by jimallyn »

The first problem I can see is that you can't directly use file names with spaces in them when you are in terminal. Many terminal commands can be given a number of arguments (items to work with) and ordinarily you separate them with spaces. So the terminal sees "2008 THE 39 STEPS remake 1 to 9/2008 THE 39 STEPS 1 to 9/3 39" as a list of things to process. So, first it looks for "2008", then "THE" , then "39", and so on. The usual way around this is to "escape" the spaces, which means to preface them with a backslash. " " becomes "\ ". (Without the quotes.) Try using:

2008\ THE\ 39\ STEPS\ remake\ 1\ to\ 9/2008\ THE\ 39\ STEPS\ 1\ to\ 9/3\ 39

and so on. I think you can also put the string in quotes, maybe even single quotes or double quotes:

'2008 THE 39 STEPS remake 1 to 9/2008 THE 39 STEPS 1 to 9/3 39 Or: "2008 THE 39 STEPS remake 1 to 9/2008 THE 39 STEPS 1 to 9/3 39

but I'm not positive of that. I usually use the backslash method of escaping the spaces. When computers used to be terminal mode only, most people got in the habit of never putting spaces in file names. I still don't use spaces in file names. I usually use CamelCase, where the first letter of each word is capitalized.
“If the government were coming for your TVs and cars, then you'd be upset. But, as it is, they're only coming for your sons.” - Daniel Berrigan
Locked

Return to “Sound”