fluent-ffmpeg / node-fluent-ffmpeg

A fluent API to FFMPEG (http://www.ffmpeg.org)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Undefined constant filter error when creating Dash

HMT2002 opened this issue · comments

Version information

  • fluent-ffmpeg version: 2.1.2
  • ffmpeg version: @ffmpeg-installer/ffmpeg 1.0.20
  • OS: windows

Code to reproduce

  const filePath = destination + originalname;
  const filenameWithoutExt = originalname.split('.')[0];
  const outputFolder = destination + filenameWithoutExt + 'Dash';
  const outputResult = outputFolder + '/init.mpd';
  fs.access(outputFolder, (error) => {
    if (error) {
      fs.mkdir(outputFolder, (error) => {
        if (error) {
          console.log(error);
        } else {
          console.log('New Directory created successfully !!');
        }
      });
    } else {
      console.log('Given Directory already exists !!');
    }
  });

  await new ffmpeg()
    .addInput(filePath)
    .outputOptions([
      '-preset veryfast',
      '-c:v libx264',
      '-c:a aac',
      '-c:s srt',
      '-crf 28',
      '-f dash',
      '-map 0:v:0',
      '-map 0:a:0',
      '-ar 44100',

      '-b:v:0 750k -filter:v:0 scale=-2:480',
      '-b:v:1 1000k -filter:v:1 scale=-2:720',
      '-b:v:2 1500k -filter:v:2 scale=-2:1080',

      '-use_timeline 1',
      '-single_file 0',
      '-use_template 1',
      '-seg_duration 10',
      '-bf 1',
      '-keyint_min 120',
      '-g 120',
      '-sc_threshold 0',
      '-b_strategy 0',
      '-ar:a:1 22050',
      '-init_seg_name init_$RepresentationID$.m4s',
      '-media_seg_name chunk_$RepresentationID$_$Number%05d$.m4s',
    ])
    // .outputOption('-adaptation_sets', 'id=0,streams=v id=1,streams=a')
    .output(outputResult)
    .on('start', function (commandLine) {
      console.log('Spawned Ffmpeg with command: ' + commandLine);
    })
    .on('error', function (err, stdout, stderr) {
      console.error('An error occurred: ' + err.message, err, stderr);
    })
    .on('progress', function (progress) {
      console.log('Processing: ' + progress.percent + '% done');
      console.log(progress);
      /*percent = progress.percent;
      res.write('<h1>' + percent + '</h1>');*/
    })
    .run();

(note: if the problem only happens with some inputs, include a link to such an input file)

Expected results

This is the code I use to create a DASH streaming folder, I want to create 3 version 360p, 480p and 1080p.

Observed results

The code didn't work and crashed. It said "Undefined constant or missing '(' in 'b:v:11000k-filter:v:1scale=-2:720'". The console log out a command "ffmpeg -i grDiQwA.mkv -y -preset veryfast -c:v libx264 -c:a aac -c:s srt -crf 28 -f dash -map 0:v:0 -map 0:a:0 -ar 44100 -b:v:0 750k -filter:v:0 scale=-2:480 -b:v:1 1000k -filter:v:1 scale=-2:720 -b:v:2 1500k -filter:v:2 scale=-2:720 -use_timeline 1 -single_file 0 -use_template 1 -seg_duration 10 -bf 1 -keyint_min 120 -g 120 -sc_threshold 0 -b_strategy 0 -ar:a:1 22050 -init_seg_name init_$RepresentationID$.m4s -media_seg_name chunk_$RepresentationID$_$Number%05d$.m4s grDiQwADash/init.mpd" which is the input file and path, I tried it with installed ffmpeg (2023-07-02-git-50f34172e0-full_build-www.gyan.dev) and it worked, but it only give me 1 resolution 480p . Can anybody help me please? Why does fluent-ffmpeg execute differently from ffmpeg? Is there anything to do with the options and params? Have anyone succeed to create a dash with similar options?

Checklist

  • I have read the FAQ
  • I tried the same with command line ffmpeg and it works correctly (hint: if the problem also happens this way, this is an ffmpeg problem and you're not reporting it to the right place)
  • I have included full stderr/stdout output from ffmpeg