Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PNG thumbnails from AWS S3, #36

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ Use the approach with the library promise
console.log(e.msg);
}
```
Can be used an url to video:
```js
var process = new ffmpeg('https://videos_bacucket.s3.amazonaws.com/testl.mp4');
```

## The video object

Each time you create a new instance, this library provides a new object to retrieve the information of the video, the ffmpeg configuration and all methods to make the necessary conversions:
Expand Down Expand Up @@ -119,6 +124,7 @@ Params:
, keep_aspect_ratio : true // Mantain the original aspect ratio
, padding_color : 'black' // Padding color
, file_name : null // File name
, png_frame : false // PNG frame instead of JPG
}
```
* __callback__: *(optional)* If specified at the end of the process will be returned list of paths of frames created:
Expand Down
5 changes: 3 additions & 2 deletions lib/ffmpeg.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,9 @@ var ffmpeg = function (/* inputFilepath, settings, callback */) {
// Get the input filepath
var inputFilepath = args[0];
// Check if file exist
if (!fs.existsSync(inputFilepath))
throw errors.renderError('fileinput_not_exist');
if (!/^http/.test(inputFilepath.toLowerCase()) && !fs.existsSync(inputFilepath)){
throw errors.renderError('fileinput_not_exist');
}

// New instance of the base configuration
var settings = new configs();
Expand Down
12 changes: 10 additions & 2 deletions lib/video.js
Original file line number Diff line number Diff line change
Expand Up @@ -553,9 +553,12 @@ module.exports = function (filePath, settings, infoConfiguration, infoFile) {
var deferred = typeof callback != 'function' ? when.defer() : { promise : null };
// Deal with input paths that have spaces in them, by quoting them
for (i=0; i<inputs.length; i++) {
inputs[i] = '\'' + inputs[i] + '\'';
if (/\s/.test(inputs[i])) {
inputs[i] = '\'' + inputs[i] + '\'';
}
}
// Create a copy of the commands list

// Create a copy of the commands list
var finalCommands = ['ffmpeg -i']
.concat(inputs.map(utils.addQuotes).join(' -i '))
.concat(commands.join(' '))
Expand Down Expand Up @@ -655,6 +658,7 @@ module.exports = function (filePath, settings, infoConfiguration, infoFile) {
, keep_aspect_ratio : true // Mantain the original aspect ratio
, padding_color : 'black' // Padding color
, file_name : null // File name
, png_frame : false // PNG frame instead of JPG
};

// Scan all arguments
Expand Down Expand Up @@ -808,6 +812,10 @@ module.exports = function (filePath, settings, infoConfiguration, infoFile) {
this.addCommand('-vsync', 0);
this.addFilterComplex('select=not(mod(t\\,' + parseInt((this.metadata.duration.seconds / 100) * settings.every_n_percentage) + '))');
}
if (settings.png_frame) {
this.addCommand('-vcodec ', 'png');
settings.file_name = settings.file_name.replace('.jpg','.png')
}

// Add destination file path to the command list
setOutput([destinationFolder,settings.file_name].join('/'));
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ffmpeg",
"description": "Utility for managing video streams using ffmpeg",
"version": "0.0.4",
"version": "0.0.5",
"author": {
"name": "Damiano Ciarla",
"email": "[email protected]"
Expand Down