Wowza Community

ffmpeg transcode MP4 from WowzaStreamRecorder error


My project need to store the recorded stream within Google Cloud Storage (1st bucket) and then transcode again to normalize them to the format we need (2nd bucket).

The first path is fine. Recorded files is uploaded to store correctly. When the uploading is finish, it will trigger Google Cloud Function and try to convert the file and then problem occur.

The output file is corrupted. It’s almost 0 byte. However, the MP4 file from the other source in not corrupted, FLV from Wowza Recorder as well. Only MP4 from Wowza Recorder

This Node.js code below is google cloud function I use

const storage = require('@google-cloud/storage')();
const ffmpegPath = require('@ffmpeg-installer/ffmpeg').path;
const ffmpeg = require('fluent-ffmpeg');
const transcodedBucket = storage.bucket('MY-TRANSCODED-BUCKET');
const uploadBucket = storage.bucket('MY-UPLOAD-BUCKET');
exports.transcodeVideo = function transcodeVideo(event, callback) {
  const file =;

  const remoteWriteStream = transcodedBucket.file('transcoded-' +
      metadata: {
        metadata: file.metadata,
        contentType: 'video/mp4',
  const remoteReadStream = uploadBucket.file(;
  // Transcode
    .outputOptions('-c:v copy')
    .outputOptions('-c:a aac')
    .outputOptions('-b:a 160k')
    .outputOptions('-f mp4')
    .outputOptions('-preset fast')
    .outputOptions('-movflags frag_keyframe+empty_moov')
    .on('start', (cmdLine) => {
      console.log('Started ffmpeg with command:', cmdLine);
    .on('end', () => {
      console.log('Successfully re-encoded video.');
    .on('progress', function(progress) {
      console.log('Processing: @' + progress.currentFps + ' fps');
    .on('error', (err, stdout, stderr) => {
      console.error('An error occured during encoding', err.message);
      console.error('stdout:', stdout);
      console.error('stderr:', stderr);
    .pipe(remoteWriteStream, { end: true });

FYI: to be more specific,


The code above is not working (input is a read stream) but the below one is (input is directly file)