fluent-ffmpeg / node-fluent-ffmpeg

A fluent API to FFMPEG (http://www.ffmpeg.org)
MIT License
7.64k stars 874 forks source link

Feature to piping data from ffmpeg to cloud like azure blob storage if multiple chunks are created as in dash container format #1184

Open coolb0y opened 2 years ago

coolb0y commented 2 years ago

Version information

Code to reproduce


    const inoutStream = new Transform({
     transform(chunk, encoding, callback) {
       this.push(chunk);
       callback();
     },
  });

var proc = ffmpeg({
        source: sourcefn,
        cwd: targetdir
    });

    proc
      .output(targetfn)
        .format('dash')
        .videoCodec('libx264')
        .audioCodec('aac')
        .audioChannels(2)
        .audioFrequency(44100)
        .outputOptions([

            '-preset medium',
            '-keyint_min 60',
            '-g 60',
            '-sc_threshold 0',
            '-profile:v main',
            '-use_template 1',
            '-use_timeline 1',
            '-b_strategy 0',
            '-bf 1',
            '-map 0:a',
            '-b:a 96k',

        ]);
proc
.run();
       const containerClient = blobServiceClient.getContainerClient(containerName1);;
     const blockBlobClient = containerClient.getBlockBlobClient(blobName);

       await blockBlobClient.uploadStream(inoutStream,
         uploadOptions.bufferSize, uploadOptions.maxBuffers,
          { blobHTTPHeaders: { blobContentType: "video/mpd" } });

Expected results

All the chunks created are transferred to azure blob storage as they are stored in localhost directory . They are stored in localhost like this . https://drive.google.com/file/d/1m1yDmfow265wRQ5cZrEVkSQaXeejXMwh/view?usp=sharing

Observed results

I see only one file mpd file (on azure cloud ) having lots of content written in it which should not be in mpd file . I assume that is because of output data is written to same file . But only problem is that other than .mpd container file other file which ends with .m4s are binary those data is also text file in 1.mpd which is uploaded to azure blob storage. https://drive.google.com/file/d/1ghOgyRSEZyqRPmYCc-YmJhPU2ipSsdlL/view?usp=sharing

NOTE : Is there any way I can tap to individual .m4s file while they are being written to disk so that I can pass them to azure storage individually ?

Checklist

sam-ayo commented 9 months ago

Hey, I'm also encountering this problem. The current workaround for this is to first output to local storage and then upload to Azure Blob Storage. I don't like this approach, as there should be a way to pipe the output directly to Azure. I was wondering if you found a solution to this?