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

convert pcm to mp3 exception #249

Open
nn200433 opened this issue Dec 7, 2023 · 0 comments
Open

convert pcm to mp3 exception #249

nn200433 opened this issue Dec 7, 2023 · 0 comments

Comments

@nn200433
Copy link

nn200433 commented Dec 7, 2023

convert pcm to mp3:

ffmpeg -f s16be -ac 2 -ar 16000 -acodec pcm_s16le -i 16k.pcm new_mp3.mp3

console log:

10:00:20.713 [main] DEBUG ws.schild.jave.process.ProcessWrapper - About to execute C:\Users\abc\AppData\Local\Temp\jave\ffmpeg-amd64-3.3.1.exe -f s16be -acodec pcm_s16le -i E:\下载\audio\8k16bit.pcm -vn -ac 2 -ar 16000 -f mp3 -y C:\Users\abc\AppData\Local\Temp\audio\657127348b283a58b81f0a60.mp3 -hide_banner
10:00:20.847 [main] DEBUG ws.schild.jave.process.ProcessWrapper - About to execute C:\Users\abc\AppData\Local\Temp\jave\ffmpeg-amd64-3.3.1.exe -i E:\下载\audio\8k16bit.pcm -hide_banner
10:00:23.621 [main] DEBUG ws.schild.jave.MultimediaObject - Output line: E:\下载\audio\8k16bit.pcm: Invalid data found when processing input
10:00:23.632 [main] ERROR cn.abc.ffmpeg.audio.service.impl.MP3ConvertServiceImpl - ---> pcm 转 mp3 异常

probable cause:

No input parameters

C:\Users\abc>ffmpeg -i E:\下载\audio\8k16bit.pcm
ffmpeg version 4.2.3 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9.3.1 (GCC) 20200523
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
E:\下载\audio\8k16bit.pcm: Invalid data found when processing input

With input parameters

C:\Users\abc>ffmpeg -f s16be -acodec pcm_s16le -i E:\下载\audio\8k16bit.pcm
ffmpeg version 4.2.3 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9.3.1 (GCC) 20200523
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
[s16be @ 0000017d05708d00] Estimating duration from bitrate, this may be inaccurate
Guessed Channel Layout for Input Stream #0.0 : mono
Input #0, s16be, from 'E:\下载\audio\8k16bit.pcm':
  Duration: 00:00:01.27, bitrate: 705 kb/s
    Stream #0:0: Audio: pcm_s16le, 44100 Hz, mono, s16, 705 kb/s
At least one output file must be specified

pcm file download link : pcm test audio file

I think there needs to be an input parameter in the method(ws.schild.jave.MultimediaObject#getInfo).

  /**
   * Returns a set informations about a multimedia file, if its format is supported for decoding.
   *
   * @return A set of informations about the file and its contents.
   * @throws InputFormatException If the format of the source file cannot be recognized and decoded.
   * @throws EncoderException If a problem occurs calling the underlying ffmpeg executable.
   */
  public MultimediaInfo getInfo() throws InputFormatException, EncoderException {
    if (isURL() || inputFile.canRead()) {
      ProcessWrapper ffmpeg = locator.createExecutor();
      
      // prescription: Add input file other parameters
      
      ffmpeg.addArgument("-i");
      ffmpeg.addArgument(toString());
      
      try {
        ffmpeg.execute();
      } catch (IOException e) {
        throw new EncoderException(e);
      }
      try {
        RBufferedReader reader =
            new RBufferedReader(new InputStreamReader(ffmpeg.getErrorStream()));
        if (isURL()) {
          return parseMultimediaInfo(inputURL.toString(), reader);
        } else {
          return parseMultimediaInfo(inputFile.getAbsolutePath(), reader);
        }
      } finally {
        ffmpeg.destroy();
      }
    } else {
      throw new EncoderException("Input file not found <" + inputFile.getAbsolutePath() + ">");
    }
  }
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

No branches or pull requests

1 participant