mpv-android / mpv-android

#mpv-android @ libera.chat
MIT License
1.81k stars 226 forks source link

Can't use FFmpeg input and internal sample formats at s64p with audio resampling #875

Closed romain8991 closed 2 months ago

romain8991 commented 2 months ago

Android version:

14

My device:

Oppo Find X5 Pro

mpv-android version:

2023-11-30

Version of mpv-android that introduced the problem :

Unknown

Description:

While using the following ffmpeg command lines, my lavfi filters chain (including audio resampling) is broken and cease to operate (resulting in a crash of the app, while playing audio files), at s64p input and internal sample formats (despite this sample format supposed to be usable, according to mpv's af=format=format=help, on my Windows computer):

af=lavfi=[aresample=in_sample_fmt=s64p:resampler=swr:cutoff=1:out_sample_rate=48000:internal_sample_fmt=s64p:dither_method=triangular:out_sample_fmt=s32] softvol=no ao=opensles loop-playlist=inf

Log output:

02-29 22:18:58.678 3142 3251 V mpv : [cplayer:v] Setting option 'af' = 'lavfi=[aresample=in_sample_fmt=s64p:resampler=swr:cutoff=1:out_sample_rate=48000:internal_sample_fmt=s64p:dither_method=triangular:out_sample_fmt=s32]' (flags = 4) 02-29 22:18:58.678 3142 3251 V mpv : [cplayer:v] Setting option 'ao' = 'opensles' (flags = 4) 02-29 22:18:58.787 3142 3251 V mpv : [af:v] [lavfi] 44100Hz stereo 2ch s16 02-29 22:18:58.787 3142 3251 V mpv : [ffmpeg:error] Unsupported sample format 02-29 22:18:58.787 3142 3251 V mpv : [ffmpeg:fatal] Assertion 0 failed at src/libswresample/resample.c:232

Additional information:

This issue occurs on the latest version of mpv aswell on my Windows computer and with the very same settings (apart from the audio output used of course, being wasapi in this case).

romain8991 commented 2 months ago

Also, I did further testing with the mpv's audio-format and audio-samplerate commands, to check if planar formats (such as s16p or s32p) are actually recognized, on my computer and Android phone, and they all seems to be supported by mpv (because my mpv audio output sample formats matched my choices on my computer, according to the log output on it, and my phone didn't crash using them):

Log output (with mpv's audio-format and audio-samplerate commands):

02-29 23:20:39.688 7668 9534 V mpv : [af:v] [in] 96000Hz stereo 2ch s32 02-29 23:20:39.688 7668 9534 V mpv : [af:v] [userspeed] 96000Hz stereo 2ch s32 02-29 23:20:39.688 7668 9534 V mpv : [af:v] [userspeed] (disabled) 02-29 23:20:39.688 7668 9534 V mpv : [af:v] [convert] 96000Hz stereo 2ch s32 02-29 23:20:39.688 7668 9534 V mpv : [ao:v] Trying audio driver 'opensles' 02-29 23:20:39.688 7668 9534 V mpv : [ao/opensles:v] requested format: 48000 Hz, stereo channels, s32p 02-29 23:20:39.688 7668 9534 V mpv : [ao/opensles:v] device buffer: 12000 samples. 02-29 23:20:39.688 7668 9534 V mpv : [ao/opensles:v] using soft-buffer of 12000 samples. 02-29 23:20:39.688 7668 9534 V mpv : [cplayer:info] AO: [opensles] 48000Hz stereo 2ch s32 02-29 23:20:39.688 7668 9534 V mpv : [cplayer:v] AO: Description: OpenSL ES audio output 02-29 23:20:39.688 7668 9534 V mpv : [autoconvert:v] inserting resampler 02-29 23:20:39.688 7668 9534 V mpv : [swresample:v] format change, reinitializing resampler 02-29 23:20:39.688 7668 9534 V mpv : [swresample:v] 96000Hz stereo s32 -> 48000Hz stereo s32 02-29 23:20:39.688 7668 9534 V mpv : [af:v] [out] 48000Hz stereo 2ch s32 02-29 23:20:39.688 7668 9534 V mpv : [cplayer:v] audio ready 02-29 23:20:39.688 7668 9534 V mpv : [cplayer:v] starting audio playback

So, I think it's somehow related to FFmpeg audio filters or their implementation in mpv (especially, regarding planar formats used with audio resampling).

sfan5 commented 2 months ago

If ffmpeg says it's unsupported then it's clearly not an mpv or mpv-android problem.