Debbie-Leigh Posted May 5, 2008 Share Posted May 5, 2008 Hi, I would like to add a feature to my site that combines two video files together and makes the result available for download. So I've been trying to find somewhere that describes how to do this with code (I use php), but so far haven't been able to find anything. Can anyone tell me how I can do this (either with code or by installing a program on my server that I can call from code to do the combining of the videos) or point me in the right direction to learn how to do it myself? Debbie Quote Link to comment https://forums.phpfreaks.com/topic/104188-how-can-i-combine-two-video-files/ Share on other sites More sharing options...
trq Posted May 5, 2008 Share Posted May 5, 2008 You should be able to do this using ffmpeg. Quote Link to comment https://forums.phpfreaks.com/topic/104188-how-can-i-combine-two-video-files/#findComment-533841 Share on other sites More sharing options...
Debbie-Leigh Posted May 5, 2008 Author Share Posted May 5, 2008 Hi thorpe, I've looked at the documentation of ffmpeg, but I couldn't see any option that allowed more than one input file to be combined into one output file. Could you tell me if you know whether ffmpeg allows more than one input file or is only for doing audio/video file type conversions? Debbie Quote Link to comment https://forums.phpfreaks.com/topic/104188-how-can-i-combine-two-video-files/#findComment-533885 Share on other sites More sharing options...
trq Posted May 5, 2008 Share Posted May 5, 2008 You could concatenate them together. cat orig1.mpg orig2.mpg | ffmpeg -f mpeg -i - -vcodec copy -acodec copy merged.mpg Quote Link to comment https://forums.phpfreaks.com/topic/104188-how-can-i-combine-two-video-files/#findComment-533919 Share on other sites More sharing options...
Debbie-Leigh Posted May 5, 2008 Author Share Posted May 5, 2008 Hi thorpe, Is this a linux command that can be executed from php? Also, from what I've read so far, it may not be as simple as just concatenating files, because video files have headers that need to be deleted for subsequent files and reworked for the first file in the sequence. I don't know how accurate this is or whether it is true for all video/audio files. Is this true or can files just be concatenated, because I would really love it, if it really is that simple. Debbie Quote Link to comment https://forums.phpfreaks.com/topic/104188-how-can-i-combine-two-video-files/#findComment-533947 Share on other sites More sharing options...
trq Posted May 6, 2008 Share Posted May 6, 2008 Is this a linux command that can be executed from php? Yes, providing you have ffmpeg installed. Also, from what I've read so far, it may not be as simple as just concatenating files, because video files have headers that need to be deleted for subsequent files and reworked for the first file in the sequence. I don't know how accurate this is or whether it is true for all video/audio files. I guess it depends on the types of files your using. I just tried the above command with a couple of mpeg movies and it works as expected. Testing it again using avi and all I got was sound. I'm sure however if you have a read through the ffmpeg manual you will find a solution to your problem. Quote Link to comment https://forums.phpfreaks.com/topic/104188-how-can-i-combine-two-video-files/#findComment-534124 Share on other sites More sharing options...
Debbie-Leigh Posted May 6, 2008 Author Share Posted May 6, 2008 Hi thorpe, Could you show me the command you used to combine the two mpegs? The other thing that it seems I have to do, is that I would have to compile ffmpeg myself, both on my development machine (windows) and on my hoster's machine (linux). Two problems here: 1. I've tried compiling source like this before on my windows machine and completely failed, so I have no real idea how to achieve this. 2. I won't be able to compile anything on my hoster's machine, because they don't allow this kind of activity. I would preferably like to download a pre-compiled version of ffmpeg that I can just upload directly to my hosting account, so it is ready to use. Do you know if I could find a pre-compiled version anywhere? Debbie Quote Link to comment https://forums.phpfreaks.com/topic/104188-how-can-i-combine-two-video-files/#findComment-534180 Share on other sites More sharing options...
trq Posted May 6, 2008 Share Posted May 6, 2008 Could you show me the command you used to combine the two mpegs? cat orig1.mpg orig2.mpg | ffmpeg -f mpeg -i - -vcodec copy -acodec copy merged.mpg I've tried compiling source like this before on my windows machine and completely failed, so I have no real idea how to achieve this. I don't use windows so can't be of much help. I won't be able to compile anything on my hoster's machine, because they don't allow this kind of activity. You will need to ask them if they already have or if they can install it for you. I would preferably like to download a pre-compiled version of ffmpeg that I can just upload directly to my hosting account, so it is ready to use. Unfortunately its not that simple. Quote Link to comment https://forums.phpfreaks.com/topic/104188-how-can-i-combine-two-video-files/#findComment-534760 Share on other sites More sharing options...
Debbie-Leigh Posted May 6, 2008 Author Share Posted May 6, 2008 Hi thorpe, Thank you for the code. I guess I'll have to continue looking for something I can use on both platforms. Mencoder has been mentioned on another forum. Would this be something that might do what I need? Debbie Quote Link to comment https://forums.phpfreaks.com/topic/104188-how-can-i-combine-two-video-files/#findComment-534778 Share on other sites More sharing options...
trq Posted May 7, 2008 Share Posted May 7, 2008 I guess I'll have to continue looking for something I can use on both platforms. Um, ffmpeg runs on both Linux and Windows, you just need it installed. Mencoder has been mentioned on another forum. Would this be something that might do what I need? Yes, but so does ffmpeg. Quote Link to comment https://forums.phpfreaks.com/topic/104188-how-can-i-combine-two-video-files/#findComment-534907 Share on other sites More sharing options...
mlin Posted May 22, 2008 Share Posted May 22, 2008 actually, I believe mencoder is dependant on ffmpeg Quote Link to comment https://forums.phpfreaks.com/topic/104188-how-can-i-combine-two-video-files/#findComment-547367 Share on other sites More sharing options...
zq29 Posted May 24, 2008 Share Posted May 24, 2008 Concatenating mpegs works fine, but falls down on most popular codecs with the avi container due to the aforementioned headers. I use 'avimerge' (part of the 'transcode' package) quite regularly to join two DivX files together. avimerge -o output.avi -i input1.avi input2.avi input3.avi EDIT: Just noticed you need to run it on Windows too. Ignore this post! Quote Link to comment https://forums.phpfreaks.com/topic/104188-how-can-i-combine-two-video-files/#findComment-548933 Share on other sites More sharing options...
FrankleeMiDeer Posted June 29, 2010 Share Posted June 29, 2010 Debbie: I used MS products from the mid 80s until 03-10. I am so glad that Windows needed re-installing and the XP CD had a scratch in it. You have no idea how cool it is to think of something you want to do, spend a couple of minutes searching for it and then just DOING it! Plus, the couple of Windows apps that I haven't wanted to give up run just fine on Wine. Take my advice: run towards the light. Quote Link to comment https://forums.phpfreaks.com/topic/104188-how-can-i-combine-two-video-files/#findComment-1078514 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.