Ffmpeg - Convert Wav to OGG on Android (wrong metadata on some devices)

708 views Asked by At

I have in the app Wav file and I want to convert it to the OGG format.

I'm using ffmpeg library for it and this command:

ffmpeg -i /storage/emulated/0/Test.wav -c:a libvorbis -q:a 5 /storage/emulated/0/Test.ogg

But I have problem play correctly the generated OGG file on some Android devices. If I open this file in standard MediaPlayer then I get the wrong file duration, seeking is also not working very well BUT the file is played whole and correctly. This happens for example on Huawei M2 with Android 5.1 but on Samsung Galaxy S5 (with Android 5.1) the generated file is OK and playing is also OK.

Do you have some idea where can be a problem?

Full output from ffmpeg:

ffmpeg version n2.6.2 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.9 (GCC) 20140827 (prerelease)
  configuration: --target-os=linux --cross-prefix=/home/chrono/ffmpeg-android/toolchain-android/bin/arm-linux-androideabi- --arch=arm --enable-runtime-cpudetect --sysroot=/home/chrono/ffmpeg-android/toolchain-android/sysroot --enable-pic --enable-libx264 --enable-libass --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libtheora --enable-libfdk-aac --enable-nonfree --enable-fontconfig --enable-pthreads --disable-debug --disable-ffserver --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-ffprobe --enable-gpl --enable-yasm --disable-doc --disable-shared --enable-static --pkg-config=/home/chrono/ffmpeg-android/ffmpeg-pkg-config --prefix=/home/chrono/ffmpeg-android/build/armeabi-v7a --extra-cflags='-I/home/chrono/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp' --extra-ldflags='-L/home/chrono/ffmpeg-android/toolchain-android/lib -Wl,-z,relro -Wl,-z,now -pie -Wl,--fix-cortex-a8' --extra-libs='-lpng -lexpat -lm' --extra-cxxflags=
  libavutil      54. 20.100 / 54. 20.100
  libavcodec     56. 26.100 / 56. 26.100
  libavformat    56. 25.101 / 56. 25.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 11.102 /  5. 11.102
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Guessed Channel Layout for  Input Stream #0.0 : stereo
 Input #0, wav, from '/storage/emulated/0/IAMDJ/MyLoops/mix folder/Test.wav':
   Metadata:
     encoder         : Lavf56.25.101
   Duration: 00:00:16.01, bitrate: 1411 kb/s
     Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 2 channels, s16, 1411 kb/s
 Output #0, ogg, to '/storage/emulated/0/Test.ogg':
   Metadata:
     encoder         : Lavf56.25.101
     Stream #0:0: Audio: vorbis (libvorbis), 44100 Hz, stereo, fltp
  Metadata:
      encoder         : Lavc56.26.100 libvorbis
Stream mapping:
Stream #0:0 -> #0:0 (pcm_s16le (native) -> vorbis (libvorbis))
Press [q] to stop, [?] for help
size=       4kB time=00:00:01.00 bitrate=  35.0kbits/s    
size=      27kB time=00:00:02.01 bitrate= 107.8kbits/s    
size=      48kB time=00:00:03.04 bitrate= 129.3kbits/s    
size=      70kB time=00:00:04.06 bitrate= 140.3kbits/s    
size=      91kB time=00:00:05.14 bitrate= 144.9kbits/s    
size=     113kB time=00:00:06.15 bitrate= 149.7kbits/s    
video:0kB audio:344kB subtitle:0kB other streams:0kB global headers:4kB muxing overhead: 1.994279%

Edit: here is the result file: Test.ogg

Edit 2: Maybe there can be a problem with standard MediaPlayer but another Ogg file is played correctly.

0

There are 0 answers