fluent-ffmpeg/node-fluent-ffmpeg

stream upload to s3

gulshan-dev123789 opened this issue · 0 comments

ffmpegCommand
.outputOptions([
"-f hls",
"-hls_list_size 0",
"-hls_playlist_type vod",
"-hls_flags single_file",

     "-master_pl_name master.m3u8",
     "-c:v:0 libx264",
     "-c:v:1 libx264",
     "-c:v:2 libx264",
     // "-c:v:3 libx264",
     "-c:a:0 aac",
     "-c:a:1 aac",
     "-c:a:2 aac",
     // "-c:a:3 aac",
     "-maxrate:v:0 200k",
     "-maxrate:v:1 400k",
     "-maxrate:v:2 1200k",
     // "-maxrate:v:3 2400k",
     "-bufsize:v:0 400k",
     "-bufsize:v:1 800k",
     "-bufsize:v:2 1200k",
     // "-bufsize:v:3 2400k",
     "-crf:v:0 20",
     "-crf:v:1 20",
     "-crf:v:2 20",
     // "-crf:v:3 20",
     "-b:a:0 128k",
     "-b:a:1 128k",
     "-b:a:2 128k",
     // "-b:a:3 128k",
     "-s:v:0 424x240",
     "-s:v:1 640x360",
     "-s:v:2 1280x720",
     // "-s:v:3 1920x1080",
     "-map 0:v",
     "-map 0:v",
     "-map 0:v",
     // "-map 0:v",
     "-map 0:a",
     "-map 0:a",
     "-map 0:a",
     // "-map 0:a",
  ])
  .output("pipe:transcode/%v.m3u8");

ffmpegCommand.outputOption("-var_stream_map", "v:0,a:0,name:240p v:1,a:1,name:360p v:2,a:2,name:720p").pipe();

// const s3Params = {
// Bucket: process.env.AWS_BUCKET,
// Key: "output-transcode/",
// Body: ffmpegCommand,
// };

// s33.upload(s3Params, async function (err, data) {
// if (err) {
// console.error("Error uploading to S3:", err);
// } else {
// console.log("Upload successful:", data.Location);
// }
// });

try {
const parallelUploads3 = new Upload({
client: s3Client,
params: { Bucket: process.env.AWS_BUCKET, Key: "output-transcode/", Body: ffmpegCommand },
});

  parallelUploads3.on("httpUploadProgress", (progress) => {
     console.log(progress);
  });

  await parallelUploads3.done();

} catch (e) {
console.log(e);
}