Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

dduke

macrumors newbie
Original poster
Aug 24, 2010
5
0
Is there a way, either through coding or command line, to take two QuickTime movies and combine them into one.

I know that this can be done manually through QuickTime player, but we need to be able to do this using code or command line.

Thx for your help.
 

chown33

Moderator
Staff member
Aug 9, 2009
10,706
8,346
A sea of green
I googled these search terms:
quicktime command line

The results look promising.

If those results are unsatisfactory, please provide a more detailed explanation.
 

dduke

macrumors newbie
Original poster
Aug 24, 2010
5
0
@chown33

Thx for your reply.

We have tried you query multiple times and have not found a solution.

To be more specific, we are trying to implement a system for reducing the time that it takes to make a large movie by making pieces of the final product on multiple machines. Lets say we have 100,000 frames that we want to turn into a movie. We send a job out to 10 machines to 10 different ranges:

1 - 10,000
10,001 - 20,000
20,001 - 30,000
etc....

Now that we have the ten slices, we need to merge them together into one QuickTime movie encoded with the animation codec.

This must be done from the command line, or through coding as the process has to be automatic.

Does anyone know of a solution, or could at least point us to a place that does. We have exhausted Google with every variation of 'quicktime command line'.
 

subsonix

macrumors 68040
Feb 2, 2008
3,551
79
I would look into QTKit and Quicktime frameworks, loading the files, combining the buffers and saving to a new file can most certainly be done there I'd say.
 

chown33

Moderator
Staff member
Aug 9, 2009
10,706
8,346
A sea of green
Will any of these meet your requirements or not?
http://www.macupdate.com/info.php/id/22667/addmovie
http://www.macupdate.com/info.php/id/17601/qtcoffee
http://www.macupdate.com/info.php/id/24283/moviecat-plugin

The first is more recently updated, but seems to require an activation code.

It looks like at least one of them may work, but since you haven't said anything about trying anything you might have found, you may have to try them first.

It's also possible that ImageMagick will work, but it seems more still-image oriented than movie-oriented, so that's just a wild guess.

If these don't meet your requirements, please provide more detail. Specifically:
  1. What price are you willing to pay, or must it be free?
  2. What is your command-line experience?
  3. What is your experience in making or modifying scripts (in any scripting language)? If it's non-zero, what language?
  4. What tools are you using to assemble the 10k frames into movies?
  5. Do the fragments to be assembled have audio or not?
  6. Summarize some of the tools you've evaluated and rejected (e.g. MovieStitch).

#3 doesn't need to be your personal experience, but someone else in your work group. I'm asking in order to have some idea of whether a close-but-not-exact script would be acceptable or not.

#4 is to know what your tools are, so we know what can be done with what you already have.


I found the above tools by visiting http://www.macupdate.com and searching it with terms like:
join movies
combine movies
movie command line
quicktime command
http://www.macupdate.com/
 

HiRez

macrumors 603
Jan 6, 2004
6,250
2,576
Western US
You're basically describing a distributed render farm. What you probably want to do is have the client machines render self-contained single frames in an appropriate losslessly-compressed format such as .tif or .png, then send all the frames back to a central server which stitches the frames together and encodes it as a QuickTime movie. Theoretically you could have each client make its own QuickTime but it might be easier to use individual frames. This can certainly be done through code using the QuickTime API, however one of the functions of the AppleScriptable QuickTime Player app is to read in a series of numbered still frames, which can then be saved out as a QuickTime movie with any encoding that QuickTime supports. So you might be able to achieve it with little more than some AppleScripting. But the hard part will be coordinating between all the clients and the server, making sure all the frames get rendered and are valid, etc.
 

dduke

macrumors newbie
Original poster
Aug 24, 2010
5
0
@chown
Yes those links are great I will have to investigate them. We have only tried solutions for PC but we have access to a mac.

Things that we have tried are the obvious ffmpeg, mencoder, and other pretty hacky things that aren't worth mentioning.

  1. At this point, I'm sure my company could spend money if it needed to. I don't have a solid number but we do have resources.
  2. I would call myself a novice command-liner :D
  3. I am a very experienced programmer. Languages I can use include java, j-script, vb.net, c#, python, c++, actionscript, aescript, vbscript. I'm probably leaving some out but that's all off the top of my head.
  4. We are using ffmpeg and a tool that comes with Royal Render 6(our render farm manager)
  5. The assembled fragments do not have audio, but the final product could depending on what project we are working on
  6. Tools we have evaluated are ffmpeg, mencoder, avimerge (don't even know why we tried that one), and some other windows based stuff. Haven't explored mac options but it looks like we are gonna have to go that route.

Thx for your reply and hopefully continued help

@HiRez

We are using a distributed render farm to make frames almost exactly as you described. We need to create uncompressed movies which can get very large (100,000+ frames at 5mb each = A LARGE MOVIE :D). We are trying to find a way to decrease the amount of time that it takes to create an uncompressed movie by having multiple chunks of frames encoded on the farm and stitched together at the end. We have already implemented the part where we encode all the pieces. Now we just need a solution for combining them into one uncompressed movie for delivery to clients.

Thanks to you also.
 

chown33

Moderator
Staff member
Aug 9, 2009
10,706
8,346
A sea of green
@chown
Yes those links are great I will have to investigate them. We have only tried solutions for PC but we have access to a mac.

If PCs are your primary machines, then you're kinda asking in the wrong place. This is a Mac Programming forum, not a PC movie-production forum. That doesn't mean people won't be willing to help, just that you're basically asking a bunch of Mac programmers, who may not be all that informed about PC movie-production products. The answers we provide are more likely to involve Macs and programming.

Hearing that you're using a commercial render-farm manager, I'm a little surprised it can't handle (or direct) the final sequencing. Maybe that's just my ignorance of the field.

Your list of languages looks good. I was hoping for AppleScript or bash (shell), but I don't think you'll get lost at the first command-line.

At this point, I think the next step is for you to tell us how the evaluation of the 3 suggested programs went. If you've paid for QuickTime Pro on a Mac, some other possibilities arise, such as AppleScripting the QuickTime Player app.
 

dduke

macrumors newbie
Original poster
Aug 24, 2010
5
0
@chown

We have only tried solutions for pc, but we do have access to a mac, so a mac solution would be acceptable. I think we have Quicktime pro for mac, but if we don't we can purchase it.

Problems with what we tried:
ffmpeg can only concatenate avi's. Any other format is corrupted
mencoder had the same problem.

Those were the two main programs that we tried for over a month. I even tried to recode some of the libraries but that was pretty much a waste of time.

I'm sure that if AppleScript can merge multiple movies into one, then I won't have a problem picking it up. If so, do you have any suggestions of where to get go the procedure for what we need to do? I know that I could just google it but I was hoping you guys could give me a head start by pointing me in the right direction.
 

Peter Maurer

macrumors member
Oct 9, 2008
71
25
Try saving this as an AppleScript application (i.e., a droplet):

Code:
on open theMovieFiles
	tell application "Finder"
		set theSortedMovieFiles to sort theMovieFiles by name
	end tell
	tell application id "com.apple.quicktimeplayer"
		activate
		make new document
		repeat with aMovieFile in theSortedMovieFiles
			open (aMovieFile as alias)
			tell document 1
				rewind
				select all
				copy
				select none
			end tell
			close document 1 saving no
			tell document 1
				add
				select none
			end tell
		end repeat
		tell document 1
			rewind
		end tell
	end tell
end open

This script concatenates separate movie files into one QuickTime movie, and it requires QuickTime Player 7, as well as QuickTime Pro--I think. (I haven't worked on a Mac without QuickTime Pro in years, so I can't test.) Alternatively, you could do basically the same thing with QTKit (plus the underlying QuickTime framework for more sophisticated manipulations, if needed).

That alternative approach is way more complicated, though (working with the QuickTime framework can be very tricky), so I'd recommend staying with the script if it does everything you need. The fact that you can make this a part of more complex scripts (e.g., for saving the resulting movie) or even Automator actions might come in handy, too.
 

ytk

macrumors 6502
Jul 8, 2010
252
5
I've used a Ruby Gem called rmov for exactly this purpose. It's basically a wrapper around the C QuickTime API, and it works quite well for combining movies, modifying, adding, or deleting tracks, and so on.

http://rmov.rubyforge.org/

You didn't mention Ruby as one of the languages you are familiar with, but if you are an experienced programmer you should have no trouble figuring out what you need to do from the examples provided. Or even better, you can use the opportunity to learn Ruby, which is in my opinion the single handiest programming language available on the Mac.
 

dduke

macrumors newbie
Original poster
Aug 24, 2010
5
0
@Peter Maurer
That looks like it will work perfectly, thx!

@ytk
No I don't know ruby at all, but like you said I'm sure it wouldn't take long to pick up. I'll look at the samples you provided and see if there is a way to implement them in our production pipeline.
 

felix.brabant

macrumors newbie
Apr 6, 2011
1
0
Try saving this as an AppleScript application (i.e., a droplet):

Code:
on open theMovieFiles
	tell application "Finder"
		set theSortedMovieFiles to sort theMovieFiles by name
	end tell
	tell application id "com.apple.quicktimeplayer"
		activate
		make new document
		repeat with aMovieFile in theSortedMovieFiles
			open (aMovieFile as alias)
			tell document 1
				rewind
				select all
				copy
				select none
			end tell
			close document 1 saving no
			tell document 1
				add
				select none
			end tell
		end repeat
		tell document 1
			rewind
		end tell
	end tell
end open

Hi Peter and everyone !

I've been looking for this for days ! Thanks a lot.

I'm not a pro in AppleScript and I'm getting to know and discover Automator, and I'm amazed by the really great tools we can creat with them.

I was wondering if you could help me with something. Is it possible for that script to remember the file name of the first file and than save the new file in the same location as OriginalName_Merge.mov or something like that ?

That would be wonderful :)

Félix
 

mishamazor

macrumors newbie
Dec 23, 2007
14
6
Lion version?

This works great under Snow Leopard and not at all in Lion. Can someone please update it for the new OS?

Thx,
Misha
 

jasone6

macrumors member
Jan 9, 2008
94
0
Try saving this as an AppleScript application (i.e., a droplet):
This script concatenates separate movie files into one QuickTime movie...

This is really awesome… Thank you, Peter!

I was able to get it to work quickly… the only piece I'm still trying to figure out is what (if anything) can/should be done while saving the resulting file. e.g., the QT property inspector shows that the combined file still has many "pieces"—and I'm not sure if that matters or not.

Thanks again! :)
 

foidulus

macrumors 6502a
Jan 15, 2007
904
1
This is really awesome… Thank you, Peter!

I was able to get it to work quickly… the only piece I'm still trying to figure out is what (if anything) can/should be done while saving the resulting file. e.g., the QT property inspector shows that the combined file still has many "pieces"—and I'm not sure if that matters or not.

Thanks again! :)

The movie is almost certainly a "reference" movie, (ie if you look at the file itself it's only probably a couple of k), it just points to a bunch of other movies. You have to do an export to get it into a format where it can be used on other machines.
 

proboscisjoe

macrumors member
May 12, 2008
41
0
Would a shell script do the trick?

@dduke

If your individual frame files are named such that they can be sorted in the finder alphabetically/numerically, then you can probably use a shell script to run the ls command to list the contents of the folder (in order by file name) containing your files, then feed the result of that listing into the cat command to read and output the contents of the files, then direct the result of cat to be fed into a file with an extension matching the file type that you want.

For instance:

Code:
#!/bin/sh

cat $(ls /path/to/frames) > /path/to/complete/file/nameOfFile.mpg

...or something like that. It's not an actual program, but it should satisfy your interests.

I have only used such a command myself when the source file type matched the destination type.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.