Closed GoogleCodeExporter closed 8 years ago
Do NOT use AV_PIX_FMT_YUV422P9LE. Instead please try to use AV_PIX_FMT_YUV420P.
And please post your questions on the mailing list next time if possible, thank
you.
Original comment by samuel.a...@gmail.com
on 23 Nov 2014 at 1:28
Hi Samual
Alright,I will make sure I use mailing list from now onwards .
AV_PIX_FMT_YUV420P did the trick . Looks like I need to go back to basics . BTW
recording worked but no sound was there. Any Ideas ?
Thanks
Arvind
Original comment by dass.arv...@gmail.com
on 23 Nov 2014 at 7:47
To get sound, we have to record audio from somewhere. There's a sample for
Android here for that:
https://github.com/bytedeco/javacv/blob/master/samples/RecordActivity.java
But nothing for Java SE yet. If you'd like to provide a sample that works with
Java Sound:
https://docs.oracle.com/javase/tutorial/sound/capturing.html
It would be very welcome. Let me know! Thanks
Original comment by samuel.a...@gmail.com
on 23 Nov 2014 at 12:47
There are wonderful people on the internet, I found this recording code . Will
work more on this,
package com.volcare.audiosys;
import javax.sound.sampled.*;
import java.io.*;
/**
* A sample program is to demonstrate how to record sound in Java
* author: www.codejava.net
*/
public class JavaSoundRecorder {
// record duration, in milliseconds
static final long RECORD_TIME = 10000; // 1 minute
// path of the wav file
File wavFile = new File("/home/arvind/RecordAudio.wav");
// format of audio file
AudioFileFormat.Type fileType = AudioFileFormat.Type.WAVE;
// the line from which audio data is captured
TargetDataLine line;
/**
* Defines an audio format
*/
AudioFormat getAudioFormat() {
float sampleRate = 16000;
int sampleSizeInBits = 8;
int channels = 2;
boolean signed = true;
boolean bigEndian = true;
AudioFormat format = new AudioFormat(sampleRate, sampleSizeInBits,
channels, signed, bigEndian);
return format;
}
/**
* Captures the sound and record into a WAV file
*/
void start() {
try {
AudioFormat format = getAudioFormat();
DataLine.Info info = new DataLine.Info(TargetDataLine.class, format);
// checks if system supports the data line
if (!AudioSystem.isLineSupported(info)) {
System.out.println("Line not supported");
System.exit(0);
}
line = (TargetDataLine) AudioSystem.getLine(info);
line.open(format);
line.start(); // start capturing
System.out.println("Start capturing...");
AudioInputStream ais = new AudioInputStream(line);
System.out.println("Start recording...");
// start recording
AudioSystem.write(ais, fileType, wavFile);
} catch (LineUnavailableException ex) {
ex.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
/**
* Closes the target data line to finish capturing and recording
*/
void finish() {
line.stop();
line.close();
System.out.println("Finished");
}
/**
* Entry to run the program
*/
public static void main(String[] args) {
final JavaSoundRecorder recorder = new JavaSoundRecorder();
// creates a new thread that waits for a specified
// of time before stopping
Thread stopper = new Thread(new Runnable() {
public void run() {
try {
Thread.sleep(RECORD_TIME);
} catch (InterruptedException ex) {
ex.printStackTrace();
}
recorder.finish();
}
});
stopper.start();
// start recording
recorder.start();
}
}
Original comment by dass.arv...@gmail.com
on 24 Nov 2014 at 12:48
Original issue reported on code.google.com by
dass.arv...@gmail.com
on 22 Nov 2014 at 7:31