Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mp3 to pcm command crash on iOS #596

Closed
dukewuzhao opened this issue Oct 14, 2022 · 5 comments
Closed

mp3 to pcm command crash on iOS #596

dukewuzhao opened this issue Oct 14, 2022 · 5 comments
Assignees
Labels
apple Affect Apple platforms bug Something isn't working fixed-in-v6.0 flutter Affect flutter platform severity: low v4.5.1 Affects v4.5.1 release v5.1 Affects v5.1 release

Comments

@dukewuzhao
Copy link

my code:

      final String ffmpegCommand = '-hide_banner -y -i "$path" -f s16le -ar 44100 -af pan=stereo|c0=FL -ac 1 -acodec pcm_s16le "$newPath"';
      FFmpegSession session = await FFmpegKit.execute(ffmpegCommand);
      final state = FFmpegKitConfig.sessionStateToString(await session.getState());
      final returnCode = await session.getReturnCode();
      final failStackTrace = await session.getFailStackTrace();
      final output = await session.getOutput();
      print("FFmpeg process exited with state ${state} and rc ${returnCode}");
      if (state == SessionState.failed || !ReturnCode.isSuccess(returnCode)) {
        print("Command failed. Please check output for the details$output");
        print("转码失败");
        return Future.value({"code":false});
      }else{
        print("转码成功");
        final file = File(newPath);
        List<int> doubleList = file.readAsBytesSync().buffer.asInt16List();
        //print("pcm数据---$doubleList");
        file.delete();
        return Future.value({"code":true,"sampleRate":44100,"data":doubleList,"mDataLen":doubleList.length});
      }

Platform: iOS
Version:ffmpeg_kit_flutter_audio: 4.5.1-LTS
Source branch: main

crash log
Loading ffmpeg-kit.
Loaded ffmpeg-kit-audio-arm64-4.5.1-lts-20220114
flutter: Loaded ffmpeg-kit-flutter-ios-audio-arm64-4.5.1-lts.
Input #0, mp3, from '/var/mobile/Containers/Data/Application/7CED271E-5BAD-4EEE-A814-19282368D3E8/Documents/music/当阳常志此心丹.mp3':
Metadata:
artist : null
Duration: 00:01:59.82, start: 0.025057, bitrate: 128 kb/s
Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp, 128 kb/s
Metadata:
encoder : LAME3.98r
Side data:
replaygain: track gain - -5.700000, track peak - unknown, album gain - unknown, album peak - unknown,
[mp3float @ 0x101eb2ef0] The "sub_text_format" option is deprecated: Deprecated, does nothing
Stream mapping:
Stream #0:0 -> #0:0 (mp3 (mp3float) -> pcm_s16be (native))
Press [q] to stop, [?] for help
Output #0, s16be, to '/var/mobile/Containers/Data/Application/7CED271E-5BAD-4EEE-A814-19282368D3E8/Documents/music/当阳常志此心丹.pcm':
Metadata:
artist : null
encoder : Lavf59.10.100
Stream #0:0: Audio: pcm_s16be, 16000 Hz, mono, s16, 256 kb/s
Metadata:
encoder : Lavc59.15.102 pcm_s16be
Side data:
replaygain: track gain - -5.700000, track peak - unknown, album gain - unknown, album peak - unknown,
size= 0kB time=00:00:00.00 bitrate=N/A speed= 0x
size= 3743kB time=00:01:59.77 bitrate= 256.0kbits/s speed= 460x
video:0kB audio:3743kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString appendString:]: nil argument'
*** First throw call stack:
(0x1905d8d78 0x1a923d734 0x1906e35d0 0x19067ec20 0x19055c530 0x101682d74 0x100fe4620 0x100fe1064 0x108bf195c 0x108742130 0x108abeafc 0x1089ec214 0x1089eff6c 0x1905ee168 0x190572144 0x19056c8f0 0x19054afa0 0x19055e6b8 0x1ac5f8374 0x192ec3e88 0x192c455ec 0x100f9963c 0x101219ce4)
libc++abi: terminating with uncaught exception of type NSException

  • thread Log callbacks for FFprobe includes the executionId of a previous async FFmpeg execution #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x00000001c7fd3b78 libsystem_kernel.dylib__pthread_kill + 8 libsystem_kernel.dylib__pthread_kill:
    -> 0x1c7fd3b78 <+8>: b.lo 0x1c7fd3b98 ; <+40>
    0x1c7fd3b7c <+12>: pacibsp
    0x1c7fd3b80 <+16>: stp x29, x30, [sp, #-0x10]!
    0x1c7fd3b84 <+20>: mov x29, sp
    Target 0: (Runner) stopped.
    Lost connection to device.

image

What's the reason

@tanersener
Copy link
Collaborator

Thanks for creating this issue. That exception is not normal. Can you try with the latest LTS version we have: 5.1.0 ?

@tanersener tanersener added needs-analysis We don't know that this is. It must be investigated further flutter Affect flutter platform labels Oct 14, 2022
@dukewuzhao
Copy link
Author

crash log:
Input #0, mp3, from '/var/mobile/Containers/Data/Application/A7096AE5-7176-492A-B5E3-61A428602719/Documents/music/当阳常志此心丹.mp3':
Metadata:
artist : null
Duration: 00:01:59.82, start: 0.025057, bitrate: 128 kb/s
Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp, 128 kb/s
Metadata:
encoder : LAME3.98r
Side data:
replaygain: track gain - -5.700000, track peak - unknown, album gain - unknown, album peak - unknown,
Stream mapping:
Stream #0:0 -> #0:0 (mp3 (mp3float) -> pcm_s16be (native))
Press [q] to stop, [?] for help
Output #0, s16be, to '/var/mobile/Containers/Data/Application/A7096AE5-7176-492A-B5E3-61A428602719/Documents/music/当阳常志此心丹.pcm':
Metadata:
artist : null
encoder : Lavf59.27.100
Stream #0:0: Audio: pcm_s16be, 16000 Hz, mono, s16, 256 kb/s
Metadata:
encoder : Lavc59.37.100 pcm_s16be
Side data:
replaygain: track gain - -5.700000, track peak - unknown, album gain - unknown, album peak - unknown,
size= 0kB time=00:00:00.00 bitrate=N/A speed= 0x
size= 3743kB time=00:01:59.77 bitrate= 256.0kbits/s speed= 481x
video:0kB audio:3743kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
size=N/A time=00:01:59.77 bitrate=N/A speed= 480x
video:0kB audio:3743kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

Platform: iOS
Version:ffmpeg_kit_flutter_full: 5.1.0-LTS
Source branch: main

It's still crashing, it's still in the same place, but it's just this piece of music that crashes, the others are ok, I'm a little confused, this is the crashing music
当阳常志此心丹.mp3.zip

@tanersener tanersener self-assigned this Oct 18, 2022
@tanersener tanersener added apple Affect Apple platforms v4.5.1 Affects v4.5.1 release v5.1 Affects v5.1 release bug Something isn't working severity: low and removed needs-analysis We don't know that this is. It must be investigated further labels Oct 18, 2022
@tanersener
Copy link
Collaborator

tanersener commented Oct 18, 2022

Thanks for the example file. I managed to reproduce the issue.

It seems like we cannot properly read some of the fields inside that file. I'm not 100 % sure, but I suspect some ID3 tags have an encoding that we cannot process. When that happens we generate null log messages. That's why you have this issue.

The crash comes from the iOS library. I pushed a commit on the development branch to prevent it.

Unfortunately, it's not very easy to use this fix on flutter. You need to build the iOS library from the development branch and replace the original ffmpeg-kit iOS dependency of the flutter plugin with it. Or wait until we publish a new release.

@tanersener
Copy link
Collaborator

I manually modified the ID3 tags and cleared the artist tag of that file. After that, tested in ffmpeg-kit again. This time the file didn't receive any errors. That proves my theory. The encoding of ID3 tags is the issue for that file.

@tanersener
Copy link
Collaborator

Fixed in flutter v6.0.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apple Affect Apple platforms bug Something isn't working fixed-in-v6.0 flutter Affect flutter platform severity: low v4.5.1 Affects v4.5.1 release v5.1 Affects v5.1 release
Projects
No open projects
Development

No branches or pull requests

2 participants