Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Prevent numbers in scientific notation from being passed to ffmpeg #1131

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

srubin
Copy link

@srubin srubin commented May 27, 2021

Calling seekInput, duration, or seekOutput with a number that is represented in js in scientific notation leads to a ffmpeg error:

import ffmpegPath from 'ffmpeg-static';
import ffmpeg from 'fluent-ffmpeg';

ffmpeg.setFfmpegPath(ffmpegPath);

ffmpeg('in.wav')
  .output('out.wav')
  .duration(1e-7)
  .on('error', function(err, stdout, stderr) {
    console.log('An error happened: ' + err.message);
    console.log('ffmpeg standard output:\n' + stdout);
    console.log('ffmpeg standard error:\n' + stderr);
  })
  .run()

results in:

An error happened: ffmpeg exited with code 1: Invalid duration specification for t: 1e-7

ffmpeg standard output:

ffmpeg standard error:
ffmpeg version 4.3.2-tessus  https://evermeet.cx/ffmpeg/  Copyright (c) 2000-2021 the FFmpeg developers
  built with Apple clang version 11.0.0 (clang-1100.0.33.17)
  configuration: --cc=/usr/bin/clang --prefix=/opt/ffmpeg --extra-version=tessus --enable-avisynth --enable-fontconfig --enable-gpl --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libmysofa --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvmaf --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-version3 --pkg-config-flags=--static --disable-ffplay
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
Guessed Channel Layout for Input Stream #0.0 : mono
Input #0, wav, from 'in.wav':
  Metadata:
    originator_reference: aayHNh!eFSVk
    date            : 2021-02-24
    creation_time   : 15:32:33
    time_reference  : 0
    umid            : 0x060A2B340101010501010F1013000000FB1F13F1E785800019E086DAD77A81D0
  Duration: 00:00:03.73, bitrate: 716 kb/s
    Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, mono, s16, 705 kb/s
Invalid duration specification for t: 1e-7

To prevent this, this PR formats numbers in decimal notation before adding them as ffmpeg arguments.

@srubin srubin changed the title Prevent numbers in scientific notation from being passed to ffmpeg fix: Prevent numbers in scientific notation from being passed to ffmpeg May 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant