android-arm64 ffmpeg prints "out of range intra chroma pred mode" errors when copying h264 sequences and generates bad containers
#1,611 opened on Mar 25, 2021
Repository metrics
- Stars
- (6,985 stars)
- PR merge metrics
- (No merged PRs in 30d)
Description
I've got a raw h264 sequence that I want to copy into an mp4 container. When I do so, it prints a lot of error messages, and while it produces an mp4 container, playing it back with ffplay or VLC shows a video that has a lot of artifacts and smearing. When I copy the same stream into a container using ffmpeg 4.2.4 on Ubuntu Linux 20.04, it does not display any errors and the resulting container plays perfectly. I don't have any other platforms readily available that I can test the bytedeco/javacv version of ffmpeg on, so I'm not sure if other architectures have the same issue or if it's just android-arm64.
I'm running this on an arm64-v8a Android device and have tested both the latest version (4.3.2-1.5.5) and the closest available version to Ubuntu's ffmpeg (4.2.2-1.5.3), and both of them have the same results. I've tried both the GPL and non-GPL versions of the library and they have the same results.
The command I'm running looks like this:
ffmpeg -y -i input.h264 -c copy output.mp4
This is the output from ffmpeg in Ubuntu (good):
ffmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)
configuration: --prefix=/usr --extra-version=1ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
Input #0, h264, from '20210325_120264.h264':
[20210325_120264.h264.zip](https://github.com/bytedeco/javacv/files/6207240/20210325_120264.h264.zip)
Duration: N/A, bitrate: N/A
Stream #0:0: Video: h264 (Baseline), yuv420p(tv, progressive), 640x480 [SAR 1:1 DAR 4:3], 29.97 fps, 29.97 tbr, 1200k tbn, 59.94 tbc
Output #0, mp4, to 'test.mp4':
Metadata:
encoder : Lavf58.29.100
Stream #0:0: Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv, progressive), 640x480 [SAR 1:1 DAR 4:3], q=2-31, 29.97 fps, 29.97 tbr, 1200k tbn, 1200k tbc
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[mp4 @ 0x5637346ecac0] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
frame= 293 fps=0.0 q=-1.0 Lsize= 8952kB time=00:00:09.74 bitrate=7521.7kbits/s speed= 848x
video:8948kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.043119%
This is the output from ffmpeg in Android (bad):
ffmpeg version 4.3.2 Copyright (c) 2000-2021 the FFmpeg developers
built with Android (4751641 based on r328903) clang version 7.0.2 (https://android.googlesource.com/toolchain/clang 003100370607242ddd5815e4a043907ea9004281) (https://android.googlesource.com/toolchain/llvm 1d739ffb0366421d383e04ff80ec2ee591315116) (based on LLVM 7.0.2svn)
configuration: --prefix=.. --disable-iconv --disable-opencl --disable-sdl2 --disable-bzlib --disable-lzma --disable-linux-perf --enable-shared --enable-version3 --enable-runtime-cpudetect --enable-zlib --enable-libmp3lame --enable-libspeex --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-openssl --enable-libopenh264 --enable-libvpx --enable-libfreetype --enable-libopus --enable-jni --enable-mediacodec --enable-pthreads --enable-cross-compile --cross-prefix=/root/android-ndk//toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64//bin/aarch64-linux-android- --ar=/root/android-ndk//toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64//bin/aarch64-linux-android-ar --ranlib=/root/android-ndk//toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64//bin/aarch64-linux-android-ranlib --cc='/root/android-ndk//toolchains/llvm/prebuilt/linux-x86_64/bin/clang --gcc-toolchain=/root/android-ndk//toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/ --sysroot=/root/android-ndk//platforms/android-21/arch-arm64/ -isystem /root/android-ndk//sources/cxx-stl/llvm-libc++//include/ -isystem /root/android-ndk//sources/cxx-stl/llvm-libc++//../llvm-libc++abi/include/ -isystem /root/android-ndk//sources/android/support/include/ -isystem /root/android-ndk//sources/cxx-stl/llvm-libc++//libs/arm64-v8a/include/ -isystem /root/android-ndk//sysroot/usr/include/ -isystem /root/android-ndk//sysroot/usr/include/aarch64-linux-android/ -isystem /root/android-ndk//platforms/android-21/arch-arm64//usr/include/ -isystem /root/android-ndk//sources/android/cpufeatures/ -D__ANDROID_API__=21 -DANDROID -fPIC -ffunction-sections -funwind-tables -fstack-protector-strong -target aarch64-none-linux-android -march=armv8-a -z text -Wno-unused-command-line-argument -Wno-unknown-warning-option -Wno-ignored-optimization-argument -L/root/android-ndk//sources/cxx-stl/llvm-libc++//libs/arm64-v8a/ -L/root/android-ndk//platforms/android-21/arch-arm64//usr/lib/ -Wl,--no-undefined -nostdlib++' --strip=/root/android-ndk//toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64//bin/aarch64-linux-android-strip --sysroot=/root/android-ndk//platforms/android-21/arch-arm64/ --target-os=android --arch=aarch64 --extra-cflags='-I../include/ --gcc-toolchain=/root/android-ndk//toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/ --sysroot=/root/android-ndk//platforms/android-21/arch-arm64/ -isystem /root/android-ndk//sources/cxx-stl/llvm-libc++//include/ -isystem /root/android-ndk//sources/cxx-stl/llvm-libc++//../llvm-libc++abi/include/ -isystem /root/android-ndk//sources/android/support/include/ -isystem /root/android-ndk//sources/cxx-stl/llvm-libc++//libs/arm64-v8a/include/ -isystem /root/android-ndk//sysroot/usr/include/ -isystem /root/android-ndk//sysroot/usr/include/aarch64-linux-android/ -isystem /root/android-ndk//platforms/android-21/arch-arm64//usr/include/ -isystem /root/android-ndk//sources/android/cpufeatures/ -D__ANDROID_API__=21 -DANDROID -fPIC -ffunction-sections -funwind-tables -fstack-protector-strong -target aarch64-none-linux-android -march=armv8-a -z text -Wno-unused-command-line-argument -Wno-unknown-warning-option -Wno-ignored-optimization-argument -L/root/android-ndk//sources/cxx-stl/llvm-libc++//libs/arm64-v8a/ -L/root/android-ndk//platforms/android-21/arch-arm64//usr/lib/ -Wl,--no-undefined -nostdlib++' --extra-ldflags='-L../lib/ --gcc-toolchain=/root/android-ndk//toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/ --sysroot=/root/android-ndk//platforms/android-21/arch-arm64/ -isystem /root/android-ndk//sources/cxx-stl/llvm-libc++//include/ -isystem /root/android-ndk//sources/cxx-stl/llvm-libc++//../llvm-libc++abi/include/ -isystem /root/android-ndk//sources/android/support/include/ -isystem /root/android-ndk//sources/cxx-stl/llvm-libc++//libs/arm64-v8a/include/ -isystem /root/android-ndk//sysroot/usr/include/ -isystem /root/android-ndk//sysroot/usr/include/aarch64-linux-android/ -isystem /root/android-ndk//pla
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
[h264 @ 0xb400007b2b4bb650] out of range intra chroma pred mode
[h264 @ 0xb400007b2b4bb650] error while decoding MB 11 25
[h264 @ 0xb400007b2b4bb650] concealing 238 DC, 238 AC, 238 MV errors in I frame
[h264 @ 0xb400007b2b4bb650] negative number of zero coeffs at 10 26
[h264 @ 0xb400007b2b4bb650] error while decoding MB 10 26
[h264 @ 0xb400007b2b4bb650] concealing 199 DC, 199 AC, 199 MV errors in P frame
[h264 @ 0xb400007b2b4bb650] out of range intra chroma pred mode
[h264 @ 0xb400007b2b4bb650] error while decoding MB 5 13
[h264 @ 0xb400007b2b4bb650] concealing 724 DC, 724 AC, 724 MV errors in P frame
[h264 @ 0xb400007b2b4bb650] cbp too large (52) at 33 17
[h264 @ 0xb400007b2b4bb650] error while decoding MB 33 17
[h264 @ 0xb400007b2b4bb650] concealing 536 DC, 536 AC, 536 MV errors in P frame
[h264 @ 0xb400007b2b4bb650] cbp too large (60) at 22 17
[h264 @ 0xb400007b2b4bb650] error while decoding MB 22 17
[h264 @ 0xb400007b2b4bb650] concealing 547 DC, 547 AC, 547 MV errors in P frame
[h264 @ 0xb400007b2b4bb650] out of range intra chroma pred mode
[h264 @ 0xb400007b2b4bb650] error while decoding MB 38 4
[h264 @ 0xb400007b2b4bb650] concealing 1051 DC, 1051 AC, 1051 MV errors in P frame
Input #0, h264, from '/data/user/0/com.hatchbed.xxx/cache/video5689097143496556499.h264':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: h264 (Baseline), yuv420p(tv, progressive), 640x480 [SAR 1:1 DAR 4:3], 29.97 fps, 29.97 tbr, 1200k tbn, 59.94 tbc
Output #0, mp4, to '/data/user/0/com.hatchbed.xxx/cache/container86747856162007517.mp4':
Metadata:
encoder : Lavf58.45.100
Stream #0:0: Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv, progressive), 640x480 [SAR 1:1 DAR 4:3], q=2-31, 29.97 fps, 29.97 tbr, 1200k tbn, 1200k tbc
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[mp4 @ 0xb400007b3b4b96e0] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
frame= 293 fps=0.0 q=-1.0 Lsize= 8952kB time=00:00:09.74 bitrate=7521.4kbits/s speed= 536x
video:8948kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.043121%
In addition, using ffplay to play the container generated on Android produces a lot of similar errors:
ffplay 20210325_120264.mp4
ffplay version 4.2.4-1ubuntu0.1 Copyright (c) 2003-2020 the FFmpeg developers
built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)
configuration: --prefix=/usr --extra-version=1ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
[h264 @ 0x7fde1c002a00] out of range intra chroma pred mode f=0/0
[h264 @ 0x7fde1c002a00] error while decoding MB 11 25
[h264 @ 0x7fde1c002a00] concealing 238 DC, 238 AC, 238 MV errors in I frame
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '20210325_120264.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.45.100
Duration: 00:00:09.78, start: 0.000000, bitrate: 7495 kb/s
Stream #0:0(und): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv), 640x480 [SAR 1:1 DAR 4:3], 7492 kb/s, 29.95 fps, 29.97 tbr, 1200k tbn, 59.94 tbc (default)
Metadata:
handler_name : VideoHandler
[h264 @ 0x7fde1c007fc0] out of range intra chroma pred mode
[h264 @ 0x7fde1c007fc0] error while decoding MB 11 25
[h264 @ 0x7fde1c007fc0] concealing 238 DC, 238 AC, 238 MV errors in I frame
[h264 @ 0x7fde1c0a2580] out of range intra chroma pred mode
[h264 @ 0x7fde1c0a2580] error while decoding MB 5 13
[h264 @ 0x7fde1c0a2580] concealing 724 DC, 724 AC, 724 MV errors in P frame
[h264 @ 0x7fde1c045740] negative number of zero coeffs at 10 26
[h264 @ 0x7fde1c045740] error while decoding MB 10 26
[h264 @ 0x7fde1c0f7940] out of range intra chroma pred mode
[h264 @ 0x7fde1c045740] concealing 199 DC, 199 AC, 199 MV errors in P frame
[h264 @ 0x7fde1c0f7940] error while decoding MB 38 4
ffplay on the container I created in Ubuntu does not have any errors:
ffplay version 4.2.4-1ubuntu0.1 Copyright (c) 2003-2020 the FFmpeg developers
built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)
configuration: --prefix=/usr --extra-version=1ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '20210325_120264_manual.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.29.100
Duration: 00:00:09.78, start: 0.000000, bitrate: 7495 kb/s
Stream #0:0(und): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv), 640x480 [SAR 1:1 DAR 4:3], 7492 kb/s, 29.95 fps, 29.97 tbr, 1200k tbn, 59.94 tbc (default)
Metadata:
handler_name : VideoHandler
3.96 M-V: 0.000 fd= 0 aq= 0KB vq= 928KB sq= 0B f=0/0
I've also attached a sample .h264 file. Any idea why the Android version of ffmpeg is producing bad containers? Thanks! 20210325_120264.h264.zip