LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-02-2012, 09:54 PM   #1
GrepAwkSed
LQ Newbie
 
Registered: Mar 2012
Posts: 23

Rep: Reputation: Disabled
How to merge video files with ffmpeg


Hi,

I am trying to merge some video files together. All videos share the same attributes i.e video resolution, bitrates and etc...

I did this with mencoder and it did quite well. I want to know if ffmpeg is capable of doing it as well. I've tried these codes thus far

Code:
cat *.mp4 | ffmpeg -i - -vcodec copy -acodec copy -y out.mp4
Code:
cat *.mp4 | ffmpeg -i pipe:0 -vcodec copy -acodec copy -y out.mp4
But all I get is the first video during playback. Does anyone know if I am missing something in the syntax above?

Thanks for any help or suggestions

PS: I am using ffmpeg version 0.7.8

Last edited by GrepAwkSed; 04-02-2012 at 10:03 PM.
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 04-02-2012, 10:35 PM   #2
strungoutfan78
Member
 
Registered: Mar 2011
Location: San Diego, CA
Distribution: Debian
Posts: 46

Rep: Reputation: 0
As far as I know the syntax in your first example is correct, as I've had to do this once before in the past. However, I'm in the same predicament as you because now its doing the same thing to me. I've resorted to avidemux as it appends files flawlessly, depending on the codec and container.

Sorry that really doesn't answer your question , but I'm really curious about the answer as well.
 
Old 04-02-2012, 10:40 PM   #3
Satyaveer Arya
Senior Member
 
Registered: May 2010
Location: Palm Island
Distribution: RHEL, CentOS, Debian, Oracle Solaris 10
Posts: 1,420

Rep: Reputation: 305Reputation: 305Reputation: 305Reputation: 305
Or you can add them like this for an example:

Code:
# cat orig1.mpg orig2.mpg | ffmpeg -f mpeg -i - -vcodec copy -acodec copy merged.mpg

Last edited by Satyaveer Arya; 04-02-2012 at 10:46 PM.
 
2 members found this post helpful.
Old 04-02-2012, 11:36 PM   #4
GrepAwkSed
LQ Newbie
 
Registered: Mar 2012
Posts: 23

Original Poster
Rep: Reputation: Disabled
@ strungoutfan78

I know what you mean. Ffmpeg is always changing and it sometimes break thigs that worked before.

@ Satyaveer Arya

The code you gave me works surprisingly with mpg files. Don't know why it wouldn't work with mp4 files

I think I stick with mencoder when merging files and use ffmpeg for other tasks. These two programs are powerful yet they seem to have some limitations when doing certain tasks.

Thanks to both of you for the replies.

Last edited by GrepAwkSed; 04-02-2012 at 11:41 PM.
 
Old 04-02-2012, 11:51 PM   #5
Satyaveer Arya
Senior Member
 
Registered: May 2010
Location: Palm Island
Distribution: RHEL, CentOS, Debian, Oracle Solaris 10
Posts: 1,420

Rep: Reputation: 305Reputation: 305Reputation: 305Reputation: 305
What other way you tried to merge the mp4 files?
 
Old 04-03-2012, 12:02 AM   #6
strungoutfan78
Member
 
Registered: Mar 2011
Location: San Diego, CA
Distribution: Debian
Posts: 46

Rep: Reputation: 0
I found something interesting at Stack Overflow (link) after doing a quick Google search. Maybe give it a try and see what happens, as I have no videos to merge at the moment. Pay careful attention to the "newaudio" and "newvideo" portion.

Quick disclaimer: The link is about a year old, so no guarantees it's current.

Quote:
You can put many streams of the same type in the output:

ffmpeg -i test1.avi -i test2.avi -vcodec copy -acodec copy \
-vcodec copy -acodec copy test12.avi -newvideo -newaudio

In addition to the first video and audio streams, the resulting
output file test12.avi will contain the second video and the second
audio stream found in the input streams list.

The "-newvideo", "-newaudio" and "-newsubtitle" options
have to be specified immediately after the name of the output file
to which you want to add them.
 
Old 04-03-2012, 12:02 AM   #7
GrepAwkSed
LQ Newbie
 
Registered: Mar 2012
Posts: 23

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Satyaveer Arya View Post
What other way you tried to merge the mp4 files?
I did use mencoder to merge the mp4 files and it did the job quite well.

To test the code you gave me I converted two mp4 files to mpg files and then use ffmpeg to merge the mpgs files together and it work.

The only bad thing is I have to convert the mp4 files to mpg files before using the ffmpeg command to merge them.

With mencoder I don't have to do that. They are both great commands and I use them both exclusively when working with media files, but each have their ways of doing things that don't work the same way.

Last edited by GrepAwkSed; 04-03-2012 at 12:04 AM.
 
Old 04-03-2012, 12:11 AM   #8
GrepAwkSed
LQ Newbie
 
Registered: Mar 2012
Posts: 23

Original Poster
Rep: Reputation: Disabled
@ strungoutfan78

Didn't work
 
Old 04-03-2012, 12:14 AM   #9
strungoutfan78
Member
 
Registered: Mar 2011
Location: San Diego, CA
Distribution: Debian
Posts: 46

Rep: Reputation: 0
Well, I tried to edit my last post rather than add a new one, but LQ is being obstinate right now, so here it goes.

Again, I know this only provides a workaround rather than a solution, but have you tried using MP4Box?
Should be available in the repos, at least it's in the Debian repos. It's written specifically for handling mp4 files in a similar fashion to what you may be familiar with using mencoder or ffmpeg. The syntax gets a little clunky, but it works.
 
Old 04-03-2012, 12:48 AM   #10
GrepAwkSed
LQ Newbie
 
Registered: Mar 2012
Posts: 23

Original Poster
Rep: Reputation: Disabled
@ strungoutfan78

I heard of MP4Box but don't use it as much. I use mostly ffmpeg and mecoder and to some degree HandBrake.

Anyway, I've already merge the mp4 files with mencoder and it did a good job.

Have a good night all
 
Old 04-03-2012, 01:31 AM   #11
Satyaveer Arya
Senior Member
 
Registered: May 2010
Location: Palm Island
Distribution: RHEL, CentOS, Debian, Oracle Solaris 10
Posts: 1,420

Rep: Reputation: 305Reputation: 305Reputation: 305Reputation: 305
GrepAwkSed,

MP4Box is also good to merge two mp4 files directly but for that first you have to install GPAC. You can download the GPAC from here: http://gpac.wp.mines-telecom.fr/downloads/

And check this link also: http://www.molotovbliss.com/combine-...box-and-ffmpeg

Good Luck!
 
1 members found this post helpful.
Old 04-04-2012, 02:20 AM   #12
GrepAwkSed
LQ Newbie
 
Registered: Mar 2012
Posts: 23

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Satyaveer Arya View Post
GrepAwkSed,

MP4Box is also good to merge two mp4 files directly but for that first you have to install GPAC. You can download the GPAC from here: http://gpac.wp.mines-telecom.fr/downloads/

And check this link also: http://www.molotovbliss.com/combine-...box-and-ffmpeg

Good Luck!
Just tried MP4Box and it worked like a charm. Thanks
 
Old 04-04-2012, 02:33 AM   #13
Satyaveer Arya
Senior Member
 
Registered: May 2010
Location: Palm Island
Distribution: RHEL, CentOS, Debian, Oracle Solaris 10
Posts: 1,420

Rep: Reputation: 305Reputation: 305Reputation: 305Reputation: 305
Good to know that the things worked out for you. Have a nice day!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] how do i merge mp4 video files using ffmpeg ? dEnDrOn Linux - Software 2 02-04-2012 06:17 AM
using ffmpeg to convert video files acamus Linux - Newbie 2 01-04-2011 08:41 PM
LXer: Converting video & audio files using ffmpeg in GNU/Linux LXer Syndicated Linux News 0 05-30-2009 04:31 AM
Script to automatically convert video files using ffmpeg jroyce Linux - Software 3 01-04-2008 11:17 PM
splitting video files with ffmpeg triXlife Linux - Software 0 12-27-2005 07:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration