Skip to content

Commit a9c2c7d

Browse files
committed
* record: request float32 input sample format for Opus/Vorbis/MP3 by default
int16 is the sample format used by default, and some precision could be lost during int16->float32 conversion.
1 parent 9d93fed commit a9c2c7d

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/exe/record.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,15 @@ static int rec_check(struct cmd_rec *r)
279279
if (!(r->aenc = cmd_oext_aenc(ext, 0)))
280280
return _ffargs_err(&x->cmd, 1, "Specified output file format is not supported: \"%S\"", &ext);
281281

282+
if (!r->aformat) {
283+
switch (r->aenc) {
284+
case PHI_AC_MP3:
285+
case PHI_AC_OPUS:
286+
case PHI_AC_VORBIS:
287+
r->aformat = PHI_PCM_FLOAT32;
288+
}
289+
}
290+
282291
if (r->buffer)
283292
x->timer_int_msec = ffmin(r->buffer / 2, x->timer_int_msec);
284293
return 0;

src/jni/record.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,13 @@ Java_com_github_stsaz_phiola_Phiola_recStart(JNIEnv *env, jobject thiz, jstring
119119
break;
120120

121121
case AF_MP3:
122-
c.mp3.quality = (uint)q + 1; break;
122+
c.iaudio.format.format = PHI_PCM_FLOAT32;
123+
c.mp3.quality = (uint)q + 1;
124+
break;
123125

124126
case AF_OPUS:
125127
case AF_OPUS_VOICE:
128+
c.iaudio.format.format = PHI_PCM_FLOAT32;
126129
c.opus.bitrate = q;
127130
c.opus.mode = !!(fmt == AF_OPUS_VOICE);
128131
break;

0 commit comments

Comments
 (0)