I made a video playback function using
VideoView and ʻExoPlayer` on Android, but for some reason the video does not play well. ..
I can play it on that version or device without any problems, but for some reason it doesn’t play well on this version or device.
For some reason, blackness appears, the display is corrupted, playback fails and nothing is displayed.
In such a case, it is good to look at the log and doubt whether the implementation is suspicious, but I would like to introduce another approach.
Is the video supported on the Android platform?
Not all video formats are supported on Android.
There are some videos that cannot be played, such as mov files.
The following guidelines are available on the official website.
|[Supported media formats||Android developer||Android Developers](https://developer.android.com/guide/topics/media/media-formats?hl=ja)|
It’s also important to check the guidelines to see if the video format is properly supported in the first place.
If you don’t do this, you will never know the cause and you will get stuck.
(It was quite tricky, such as the feeling of encounter and the occurrence of the phenomenon.)
How to check the video format
brew install ffmpeg
The command to check the video format is as follows.
ffmpeg -i [Input file name]
For example, download the following video and check it.
~ ffmpeg -i /Users/Hitoshi/Downloads/dizzy.mp4 ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers built with Apple clang version 11.0.3 (clang-118.104.22.168) configuration: --prefix=/usr/local/Cellar/ffmpeg/4.3.1 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack 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 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 7.100 / 5. 7.100 libswresample 3. 7.100 / 3. 7.100 libpostproc 55. 7.100 / 55. 7.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/Hitoshi/Downloads/dizzy.mp4': Metadata: major_brand : mp42 minor_version : 0 compatible_brands: isomavc1mp42 creation_time : 2009-10-25T14:18:33.000000Z Duration: 00:00:25.00, start: 0.000000, bitrate: 510 kb/s Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 93 kb/s (default) Metadata: creation_time : 2009-10-25T14:18:33.000000Z handler_name : (C) 2007 Google Inc. v08.13.2007. Stream #0:1(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 480x360 [SAR 1:1 DAR 4:3], 413 kb/s, 30 fps, 30 tbr, 30k tbn, 60 tbc (default) Metadata: creation_time : 2009-10-25T14:18:33.000000Z handler_name : (C) 2007 Google Inc. v08.13.2007. At least one output file must be specified
When you roughly unravel the inside, the voice first
Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 93 kb/s (default)
Since the format is like “AAC-LC”, you can see that it is a format supported by Android.
Also, the video
Stream #0:1(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 480x360 [SAR 1:1 DAR 4:3], 413 kb/s, 30 fps, 30 tbr, 30k tbn, 60 tbc (default)
Since the format is like “H.264 AVC Baseline Profile (BP)”, you can see that this is also a supported format.
You can also know the resolution and frame rate, so compare this information to determine if it is supported.
It may be a bit muddy, but you can isolate the problem with an approach to whether the video format was supported.
If it is not supported, the implementation seems to be okay, if it is supported, the implementation seems to be problematic, and so on.
When the video does not play well on Android, there is a possibility that the video format is not supported in some cases, and I briefly introduced how to check the video format using FFmpeg.