0

Trying to use '-acodec libopus' in my npm project as I use in the command line like in the following format;

ffmpeg -acodec libopus -i 1.webm 1.wav

This works perfectly! But I would like to make it possible in my NPM project.

How can I set the parameters? This is what I have , but not working. The output file is broken in a way that some of the frames of the audio file are missing. It is like there is sound and then there is not. And vice versa.

var proc = new ffmpeg({
        source: file,
        nolog: false       
    });


format = "opus"; // or could be wav as well!   


    proc.addOptions([
        '-f ' + format,          
        '-acodec libopus',
        '-vn'
    ]);

The purpose is to take audio file from the video file seamlessly.

Without the codec libopus, I get the following errors in the command prompt, so I assume I should handle the same issue in my NPM project as well.

[opus @ 00000000006d4520] LBRR frames is not implemented. Update your FFmpeg version to the newest one from Git. If the problem still occurs, it means that your file has a feature which has not been implemented.


[opus @ 00000000006d4520] Error decoding a SILK frame.

[opus @ 00000000006d4520] Error decoding an Opus frame.

My library is up to date, I just need to use the codec libopus properly. Any suggestions?

 \node-js>ffmpeg -version
 ffmpeg version N-86175-g64ea4d1 Copyright (c) 2000-2017 the FFmpeg 
 developers
 built with gcc 6.3.0 (GCC)

Output in command line;
xtranscribe transcodeWatson: file : ./data/that/2.webm
progress 62.625273103421605%
progress 100.01224534515762%
SAVED - transcodeWatson : .mp3
out of transcode!
fileSizeInBytes  : 16284033
shamaleyte
  • 1,882
  • 3
  • 21
  • 38
  • 1
    "but not working" … what happens? What is the generated command-line? Why is your code specifying some format and `-vn`, while the example line you give in the beginning doesn't have that? Note: In ffmpeg it's important where an option is placed, i.e., whether it's an input or an output option. What is your version of ffmpeg? (Show the output of your `ffmpeg` command when run on command-line.) – slhck Jul 03 '17 at 17:30
  • @slhck, updated the question accordingly. -vn is used for "no video". – shamaleyte Jul 03 '17 at 17:36
  • 1
    Similar to the suggestion I made in [your other question](https://stackoverflow.com/a/44890636/691711), you need to figure out how to tell fluent-ffmpeg that you want it to decode audio with libopus. I'm just not sure how to do that with the API fluent defines. Regular ffmpeg understands it through argument/option order since you say `-acodec libopus` **before** you define you input (or at least that's how I have understood it). – zero298 Jul 03 '17 at 17:44
  • What confused me is: You show a command in the first line. Then, in your code, you add some unrelated options regarding the format and `-vn`. If you want to show an example, you should make sure that they show the same thing. When I ask “What is the generated command-line?” I wanted to see what fluent-ffmpeg actually runs as a process and what that outputs, i.e. the full, uncut command-line output, as if you were running it in a shell. I'm not sure how to do that with fluent-ffmpeg, but when asking questions on Stack Overflow about ffmpeg, please try to always include that. – slhck Jul 03 '17 at 17:49
  • @slhck I think that may be my fault. In his related question, I was providing raw ffmpeg commands since I am unfamiliar with fluent-ffmpeg. To achieve the `-vn` (no video) command, the poster should use the API's: [`noVideo()`](https://github.com/fluent-ffmpeg/node-fluent-ffmpeg#novideo-disable-video-altogether) method. – zero298 Jul 03 '17 at 17:52
  • 1
    @zero298 I see, thanks for the info. Good suggestion, yeah. (I never understood why you'd need such libraries in the first place because they just add complexity to an already complex tool.) – slhck Jul 03 '17 at 17:54

1 Answers1

2

According to the README, you can add input options to the process:

proc.addInputOption('-acodec libopus');

It matters where you place an option in ffmpeg. If you put it before -i, it applies to that particular input. If you put it before an output file name, it applies to that output.

slhck
  • 36,575
  • 28
  • 148
  • 201
  • Awesome! Just like you said it is pretty vital to know what you are doing with those commands. Each parameter has a location . And for input file, that was the way how you set the codec! Works like a charm . Now I need to figure out how to reduce the size of the output audio file seamlessly ! :)) I created another topic for that! https://stackoverflow.com/questions/44891840/fluent-ffmpeg-how-to-reduce-the-size-of-the-output-file-without-losing-any-sound – shamaleyte Jul 03 '17 at 18:21