tanersener / flutter-ffmpeg

FFmpeg plugin for Flutter. Not maintained anymore. Superseded by FFmpegKit.
GNU Lesser General Public License v3.0
645 stars 132 forks source link

How to convert mp4 file to mp3 file? #338

Closed michalkubizna closed 3 years ago

michalkubizna commented 3 years ago

I am executing this line of code:

executeAsyncFFmpeg("-i $audioSampleFile.mp4 $audioOutputFile.mp3").

Whenever I do that it prints this error message:

tanersener commented 3 years ago

That single line doesn't tell anything. Why don't you share full console output?

michalkubizna commented 3 years ago

Sure. Performing hot reload... Syncing files to device sdk gphone arm64... Reloaded 1 of 1466 libraries in 360ms. I/flutter (10630): File: '/data/user/0/com.terrant/app_flutter/audio.mp3' D/flutter-ffmpeg(10630): Running FFmpeg with arguments: [-i, /data/user/0/com.terrant/app_flutter/traffic.mp4, /data/user/0/com.terrant/app_flutter/audio.mp3]. I/mobile-ffmpeg(10630): ffmpeg version v4.4-dev-416 I/mobile-ffmpeg(10630): Copyright (c) 2000-2020 the FFmpeg developers I/mobile-ffmpeg(10630): I/mobile-ffmpeg(10630): built with Android (6454773 based on r365631c2) clang version 9.0.8 (https://android.googlesource.com/toolchain/llvm-project 98c855489587874b2a325e7a516b99d838599c6f) (based on LLVM 9.0.8svn) I/mobile-ffmpeg(10630): configuration: --cross-prefix=aarch64-linux-android- --sysroot=/files/android-sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/linux-x86_64/sysroot --prefix=/home/taner/Projects/mobile-ffmpeg/prebuilt/android-arm64/ffmpeg --pkg-config=/usr/bin/pkg-config --enable-version3 --arch=aarch64 --cpu=armv8-a --cc=aarch64-linux-android24-clang --cxx=aarch64-linux-android24-clang++ --extra-libs='-L/home/taner/Projects/mobile-ffmpeg/prebuilt/android-arm64/cpu-features/lib -lndk_compat' --target-os=android --enable-neon --enable-asm --enable-inline-asm --enable-cross-compile --enable-pic --enable-jni --enable-optimizations --enable-swscale --enable-shared --enable-v4l2-m2m --disable-outdev=fbdev --disable-indev=fbdev --enable-small --disable-openssl --disable-xmm-clobber-test --disable-debug --enable-lto --disable-neon-clobber-test --disable-programs --disable-postproc --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --disable-sndio --disable-schannel --disable-securetransport --disable-xlib --disable-cuda --disable-cuvid --disable-nvenc --disable-vaapi --disable-vdpau --disable-videotoolbox --disable-audiotoolbox --disable-appkit --disable-alsa --disable-cuda --disable-cuvid --disable-nvenc --disable-vaapi --disable-vdpau --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-gmp --enable-gnutls --enable-libmp3lame --enable-libass --enable-iconv --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libxml2 --enable-libopencore-amrnb --enable-libshine --enable-libspeex --enable-libwavpack --enable-libkvazaar --enable-libx264 --enable-gpl --enable-libxvid --enable-gpl --enable-libx265 --enable-gpl --enable-libvidstab --enable-gpl --enable-libilbc --enable-libopus --enable-libsnappy --enable-libsoxr --enable-libaom --enable-libtwolame --disable-sdl2 --enable-libvo-amrwbenc --enable-zlib --enable-mediacodec I/mobile-ffmpeg(10630): libavutil 56. 55.100 / 56. 55.100 I/mobile-ffmpeg(10630): libavcodec 58. 96.100 / 58. 96.100 I/mobile-ffmpeg(10630): libavformat 58. 48.100 / 58. 48.100 I/mobile-ffmpeg(10630): libavdevice 58. 11.101 / 58. 11.101 I/mobile-ffmpeg(10630): libavfilter 7. 87.100 / 7. 87.100 I/mobile-ffmpeg(10630): libswscale 5. 8.100 / 5. 8.100 I/mobile-ffmpeg(10630): libswresample 3. 8.100 / 3. 8.100 I/mobile-ffmpeg(10630): Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/data/user/0/com.terrant/app_flutter/traffic.mp4': I/mobile-ffmpeg(10630): Metadata: I/mobile-ffmpeg(10630): major_brand : I/mobile-ffmpeg(10630): qt
I/mobile-ffmpeg(10630): I/mobile-ffmpeg(10630): minor_version : I/mobile-ffmpeg(10630): 0 I/mobile-ffmpeg(10630): I/mobile-ffmpeg(10630): compatible_brands: I/mobile-ffmpeg(10630): qt
I/mobile-ffmpeg(10630): I/mobile-ffmpeg(10630): creation_time : I/mobile-ffmpeg(10630): 2021-09-06T14:35:31.000000Z I/mobile-ffmpeg(10630): I/mobile-ffmpeg(10630): Duration: D/flutter-ffmpeg(10630): FFmpeg exited with rc: 1 I/mobile-ffmpeg(10630): 00:00:13.26 I/mobile-ffmpeg(10630): , start: I/mobile-ffmpeg(10630): 0.000000 I/mobile-ffmpeg(10630): , bitrate: I/mobile-ffmpeg(10630): 2321 kb/s I/mobile-ffmpeg(10630): I/mobile-ffmpeg(10630): Stream #0:0 I/mobile-ffmpeg(10630): (und) I/mobile-ffmpeg(10630): : Video: h264 (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], 2318 kb/s I/mobile-ffmpeg(10630): , I/mobile-ffmpeg(10630): 23.98 fps, I/mobile-ffmpeg(10630): 23.98 tbr, I/mobile-ffmpeg(10630): 24k tbn, I/mobile-ffmpeg(10630): 48k tbc I/mobile-ffmpeg(10630): (default) I/mobile-ffmpeg(10630): I/mobile-ffmpeg(10630): Metadata: I/mobile-ffmpeg(10630): creation_time : I/mobile-ffmpeg(10630): 2021-09-06T14:35:31.000000Z I/mobile-ffmpeg(10630): I/mobile-ffmpeg(10630): handler_name : I/mobile-ffmpeg(10630): Core Media Video I/mobile-ffmpeg(10630): I/mobile-ffmpeg(10630): encoder : I/mobile-ffmpeg(10630): H.264 I/mobile-ffmpeg(10630): I/mobile-ffmpeg(10630): Output #0, mp3, to '/data/user/0/com.terrant/app_flutter/audio.mp3': E/mobile-ffmpeg(10630): Output file #0 does not contain any stream

tanersener commented 3 years ago

It seems like your file doesn't include an audio stream. It includes only the following h264 video stream inside.

Video: h264 (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], 2318 kb/s
tanersener commented 3 years ago

I mean your input file (.mp4) doesn't include any audio. There is no data to convert. Creating an empty output file doesn't change anything. Your problem is in the input.

michalkubizna commented 3 years ago

Thank you so much. That worked.