Jump to content

Recommended Posts

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

 

Link to comment
https://forums.phpfreaks.com/topic/104188-how-can-i-combine-two-video-files/
Share on other sites

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

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

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.

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

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.

 

 

 

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

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.

  • 3 weeks later...

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!

  • 2 years later...

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.