jimu-decompiled/sources/com/hw/videoprocessor/util/PcmToWavUtil.java
2025-05-13 19:24:51 +02:00

53 lines
2.0 KiB
Java

package com.hw.videoprocessor.util;
import android.media.AudioRecord;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
/* loaded from: classes.dex */
public class PcmToWavUtil {
private int a;
private int b;
private int c;
private int d;
private int e;
public PcmToWavUtil(int i, int i2, int i3, int i4) {
this.b = 8000;
this.c = 12;
this.d = 2;
this.e = 2;
this.b = i;
this.c = i2;
this.d = i3;
this.e = i4;
this.a = AudioRecord.getMinBufferSize(this.b, this.c, this.e);
}
public void a(String str, String str2) {
int i = this.b;
long j = i;
int i2 = this.d;
long j2 = ((i * 16) * i2) / 8;
byte[] bArr = new byte[this.a];
try {
FileInputStream fileInputStream = new FileInputStream(str);
FileOutputStream fileOutputStream = new FileOutputStream(str2);
long size = fileInputStream.getChannel().size();
a(fileOutputStream, size, size + 36, j, i2, j2);
while (fileInputStream.read(bArr) != -1) {
fileOutputStream.write(bArr);
}
fileInputStream.close();
fileOutputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
private void a(FileOutputStream fileOutputStream, long j, long j2, long j3, int i, long j4) throws IOException {
fileOutputStream.write(new byte[]{82, 73, 70, 70, (byte) (j2 & 255), (byte) ((j2 >> 8) & 255), (byte) ((j2 >> 16) & 255), (byte) ((j2 >> 24) & 255), 87, 65, 86, 69, 102, 109, 116, 32, 16, 0, 0, 0, 1, 0, (byte) i, 0, (byte) (j3 & 255), (byte) ((j3 >> 8) & 255), (byte) ((j3 >> 16) & 255), (byte) ((j3 >> 24) & 255), (byte) (j4 & 255), (byte) ((j4 >> 8) & 255), (byte) ((j4 >> 16) & 255), (byte) ((j4 >> 24) & 255), 4, 0, 16, 0, 100, 97, 116, 97, (byte) (j & 255), (byte) ((j >> 8) & 255), (byte) ((j >> 16) & 255), (byte) ((j >> 24) & 255)}, 0, 44);
}
}