I am using the fluent-ffmpeg library with node.js to transcode videos originally in a flash movie format to the mp3 format with multiple resolutions, 1080p, etc.. Once the tran
You don't seem to be saving the output of the transcoding anywhere.
.flv
file) using output to your local filesystem.Provide your new file's contents to putObject
. According to the putObject documentation, the Body
parameter accepts:
Body
— (Buffer
,Typed Array
,Blob
,String
,ReadableStream
) Object data.
Here's some revised sample code:
// Generate a filename for the `.flv` version
var flvFileName = fileName.substring(0, fileName.length - path.extname(fileName).length) + '.flv';
// Perform transcoding, save new video to new file name
var format = ffmpeg(data)
.size('854x480')
.videoCodec('libx264')
.format('flv')
.toFormat('mp4');
.output(flvFileName)
.on('end', function () {
// Provide `ReadableStream` of new video as `Body` for `pubObject`
var params = {
Body: fs.createReadStream(flvFileName)
Bucket: process.env.TRANSCODED_BUCKET,
Key: flvFileName
};
s3.putObject(params, function (err, data) {
});
})
Note: You may be able to create an output stream from fluent-ffmpeg
and upload that stream to AWS S3, if you prefer, but this will complicate the logic and error handling.