Skip to content

Instantly share code, notes, and snippets.

@BigWillie
Last active December 22, 2015 01:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BigWillie/6393759 to your computer and use it in GitHub Desktop.
Save BigWillie/6393759 to your computer and use it in GitHub Desktop.
Dream code for video conversion
convertVideo('videoFilename.mp4').to( {
filename: 'newVideoFilename.3gp'
service: 'Amazon Elastic Transcoder',
frameRate :"auto",
resolution :"auto",
aspectRatio :"16:9",
interlaced : false,
compression: '90%'
} ).save();
// Service - choose which third party, or library you wish to pump this through
// It uses whatever the new file extension (eg .3gp) is to decide what codec's to use internally. You can specify framerate, res.. etc... defaults are 'auto'
// would be cool if there was some way to add a wildcard that converts across a spread for different device types automatically...
// or a way that you can specify a default config for all video conversion. The same could also be applied to Audio.
@gr2m
Copy link

gr2m commented Aug 30, 2013

how about:

convert('/path/to/videoFilename.mp4').to('newVideoFilename.3gp').using({
  service: 'Amazon Elastic Transcoder',
  aspectRatio :"16:9",
  interlaced : false,
  compression: '90%'
}).save()

could be combined with the dreamcode over here:
https://gist.github.com/gr2m/5463605

I like the .save() method at the end

@BigWillie
Copy link
Author

That looks awesome :) And maybe give the option to pass a path/location as an argument within save( ). If left blank - it assumes the same path as the original file.

@gr2m
Copy link

gr2m commented Sep 2, 2013

That's interesting, now I see that you made the dream code with Node.js in mind, right? I did it as working code that runs right in the browser, meaning that /path/to/videoFilename.mp4 must be accessible via the web. And save() would open the download dialog of the browser. An optional filename could be passed, but it's already passed to the .to() method.

And I liked your .save() better than my download method from my convert gist. So instead of

download( convert( $('.invoice') ).to( 'invoice.pdf' ) )

I'd rather do

convert( $('.invoice') ).to( 'invoice.pdf' ).save()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment