Add bits per second for audio.
This commit is contained in:
parent
d1fffb477f
commit
0896a04d02
@ -39,7 +39,9 @@ public class AudioFormat {
|
|||||||
public int getSamplesPerSecond() {
|
public int getSamplesPerSecond() {
|
||||||
return byteBuffer.getInt(4);
|
return byteBuffer.getInt(4);
|
||||||
}
|
}
|
||||||
// 8 - nAvgBytesPerSec(uint)
|
public int getAvgBytesPerSec() {
|
||||||
|
return byteBuffer.getInt(8);
|
||||||
|
}
|
||||||
// 12 - nBlockAlign
|
// 12 - nBlockAlign
|
||||||
// public int getBlockAlign() {
|
// public int getBlockAlign() {
|
||||||
// return byteBuffer.getShort(12);
|
// return byteBuffer.getShort(12);
|
||||||
|
@ -272,10 +272,13 @@ public class AviExtractor implements Extractor {
|
|||||||
final TrackOutput trackOutput = output.track(streamId, C.TRACK_TYPE_AUDIO);
|
final TrackOutput trackOutput = output.track(streamId, C.TRACK_TYPE_AUDIO);
|
||||||
final String mimeType = audioFormat.getMimeType();
|
final String mimeType = audioFormat.getMimeType();
|
||||||
builder.setSampleMimeType(mimeType);
|
builder.setSampleMimeType(mimeType);
|
||||||
//builder.setCodecs(audioFormat.getCodec());
|
|
||||||
builder.setChannelCount(audioFormat.getChannels());
|
builder.setChannelCount(audioFormat.getChannels());
|
||||||
builder.setSampleRate(audioFormat.getSamplesPerSecond());
|
builder.setSampleRate(audioFormat.getSamplesPerSecond());
|
||||||
if (audioFormat.getFormatTag() == AudioFormat.WAVE_FORMAT_PCM) {
|
final int bytesPerSecond = audioFormat.getAvgBytesPerSec();
|
||||||
|
if (bytesPerSecond != 0) {
|
||||||
|
builder.setAverageBitrate(bytesPerSecond * 8);
|
||||||
|
}
|
||||||
|
if (MimeTypes.AUDIO_RAW.equals(mimeType)) {
|
||||||
final short bps = audioFormat.getBitsPerSample();
|
final short bps = audioFormat.getBitsPerSample();
|
||||||
if (bps == 8) {
|
if (bps == 8) {
|
||||||
builder.setPcmEncoding(C.ENCODING_PCM_8BIT);
|
builder.setPcmEncoding(C.ENCODING_PCM_8BIT);
|
||||||
|
@ -22,5 +22,6 @@ public class AudioFormatTest {
|
|||||||
Assert.assertEquals(0, audioFormat.getBitsPerSample()); //Not meaningful for AAC
|
Assert.assertEquals(0, audioFormat.getBitsPerSample()); //Not meaningful for AAC
|
||||||
Assert.assertArrayEquals(CODEC_PRIVATE, audioFormat.getCodecData());
|
Assert.assertArrayEquals(CODEC_PRIVATE, audioFormat.getCodecData());
|
||||||
Assert.assertEquals(MimeTypes.AUDIO_AAC, audioFormat.getMimeType());
|
Assert.assertEquals(MimeTypes.AUDIO_AAC, audioFormat.getMimeType());
|
||||||
|
Assert.assertEquals(20034, audioFormat.getAvgBytesPerSec());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user