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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
04-02-2012, 09:54 PM
|
#1
|
|
LQ Newbie
Registered: Mar 2012
Posts: 23
Rep: 
|
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.
|
|
|
|
04-02-2012, 10:35 PM
|
#2
|
|
Member
Registered: Mar 2011
Location: San Diego, CA
Distribution: Debian
Posts: 46
Rep:
|
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.
|
|
|
|
04-02-2012, 10:40 PM
|
#3
|
|
Senior Member
Registered: May 2010
Location: Dehradun, Uttarakhand, India
Distribution: RHEL, CentOS, Fedora, Ubuntu, Debian
Posts: 1,346
|
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.
|
|
|
1 members found this post helpful.
|
04-02-2012, 11:36 PM
|
#4
|
|
LQ Newbie
Registered: Mar 2012
Posts: 23
Original Poster
Rep: 
|
@ 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.
|
|
|
|
04-02-2012, 11:51 PM
|
#5
|
|
Senior Member
Registered: May 2010
Location: Dehradun, Uttarakhand, India
Distribution: RHEL, CentOS, Fedora, Ubuntu, Debian
Posts: 1,346
|
What other way you tried to merge the mp4 files?
|
|
|
|
04-03-2012, 12:02 AM
|
#6
|
|
Member
Registered: Mar 2011
Location: San Diego, CA
Distribution: Debian
Posts: 46
Rep:
|
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.
|
|
|
|
|
04-03-2012, 12:02 AM
|
#7
|
|
LQ Newbie
Registered: Mar 2012
Posts: 23
Original Poster
Rep: 
|
Quote:
Originally Posted by Satyaveer Arya
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.
|
|
|
|
04-03-2012, 12:11 AM
|
#8
|
|
LQ Newbie
Registered: Mar 2012
Posts: 23
Original Poster
Rep: 
|
@ strungoutfan78
Didn't work
|
|
|
|
04-03-2012, 12:14 AM
|
#9
|
|
Member
Registered: Mar 2011
Location: San Diego, CA
Distribution: Debian
Posts: 46
Rep:
|
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.
|
|
|
|
04-03-2012, 12:48 AM
|
#10
|
|
LQ Newbie
Registered: Mar 2012
Posts: 23
Original Poster
Rep: 
|
@ 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
|
|
|
|
04-04-2012, 02:20 AM
|
#12
|
|
LQ Newbie
Registered: Mar 2012
Posts: 23
Original Poster
Rep: 
|
Quote:
Originally Posted by Satyaveer Arya
|
Just tried MP4Box and it worked like a charm. Thanks
|
|
|
|
04-04-2012, 02:33 AM
|
#13
|
|
Senior Member
Registered: May 2010
Location: Dehradun, Uttarakhand, India
Distribution: RHEL, CentOS, Fedora, Ubuntu, Debian
Posts: 1,346
|
Good to know that the things worked out for you. Have a nice day! 
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 01:38 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|