Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

14
LINES

< > BotCompany Repo | #1007048 // audioCopyToMP3 - convert an audio file

JavaX fragment (include)

import javax.sound.sampled.AudioFileFormat;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException;
import javazoom.spi.mpeg.sampled.file.MpegFileFormatType;

static void audioCopyToMP3(File inputFile, File outputFile, AudioFormat outputFormat) ctex {
  AudioInputStream sourceStream = AudioSystem.getAudioInputStream(inputFile);
  AudioInputStream stream = AudioSystem.getAudioInputStream(outputFormat, sourceStream);
  int nWrittenBytes = AudioSystem.write(stream, MpegFileFormatType.MP3, outputFile);
  sourceStream.close();
  stream.close();
}

Author comment

Began life as a copy of #1006990

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1007048
Snippet name: audioCopyToMP3 - convert an audio file
Eternal ID of this version: #1007048/2
Text MD5: f31132582aaeea0733c03e305b4ebec8
Author: stefan
Category: javax / audio
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-02-26 14:28:53
Source code size: 687 bytes / 14 lines
Pitched / IR pitched: No / No
Views / Downloads: 319 / 359
Version history: 1 change(s)
Referenced in: [show references]