Converting Video For Android Using FFMPEG
Solution 1:
The MP4 created by ffmpeg has the moov header at the tail. That is why you are getting this error message. ffmpeg can put the moov header in front (suitable for streaming).
Simply run:
ffmpeg -i <input> -c:v libx264 -c:a aac -movflags +faststart output.mp4
Also refer to Post processing in ffmpeg to move 'moov atom' in MP4 files (qt-faststart)
Solution 2:
libfaac is not supported anymore, You can use this configuration:
ffmpeg -i <input> -s 480x320 -vcodec mpeg4 -acodec aac -strict -2 -ac 1 -ar 16000 -r 13 -ab 32000 -aspect 3:2 <output>
Solution 3:
The solution that worked for me was:
ffmpeg -i <INPUT_VIDEO> -c:v libx264 -profile:v baseline -c:a libvo_aacenc -ar 44100 -ac 2 -b:a 128k -movflags faststart output.mp4
I'm using Ubuntu 16.04.1 LTS
Solution 4:
The solution that worked for me was:
ffmpeg -y -i input_file.mp4 -s 352x288 -b:v 384k -flags +loop+mv4 -cmp 256 -partitions +parti4x4+parti8x8+partp4x4+partp8x8 -subq 6 -trellis 0 -refs 5 -bf 0 -coder 0 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -qmin 10 -qmax 51 -qdiff 4 -c:a aac -ac 1 -ar 16000 -r 13 -ab 32000 -aspect 3:2 -strict experimental output_file.3gp
I converted to 3gp. It works in API 16 or higher, using VideoView.
Solution 5:
What I did here was to record a video with my Android device and see what it has configured with FFMPEG:
C:\Users\muradgui\Documents\SmartTrust\Software\ffmpeg-20170418-6108805-win64-static\bin>ffmpeg -i android.mp4
ffmpeg version N-85588-g6108805 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 6.3.0 (GCC)
configuration: --enable-gpl --enable-version3 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avis
e-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --e
m --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpe
-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enabl
--enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-zlib
libavutil 55. 61.100 / 55. 61.100
libavcodec 57. 93.100 / 57. 93.100
libavformat 57. 72.101 / 57. 72.101
libavdevice 57. 7.100 / 57. 7.100
libavfilter 6. 84.101 / 6. 84.101
libswscale 4. 7.101 / 4. 7.101
libswresample 2. 8.100 / 2. 8.100
libpostproc 54. 6.100 / 54. 6.100
[h264 @ 00000000003184e0] no frame!
[aac @ 000000000050c900] Input buffer exhausted before END element found
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'android.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2018-03-08T17:30:26.000000Z
com.android.version: 6.0.1
Duration: 00:00:00.86, start: 0.000000, bitrate: 2160 kb/s
Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p, 720x1280, 2107 kb/s, 31.72 fps, 29.97 tbr, 90k tbn, 180k tbc (default)
Metadata:
creation_time : 2018-03-08T17:30:26.000000Z
handler_name : VideoHandle
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 56 kb/s (default)
Metadata:
creation_time : 2018-03-08T17:30:26.000000Z
handler_name : SoundHandle
At least one output file must be specified
I'm not very technical but this is what drew my attention mostly:
Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p, 720x1280, 2107 kb/s, 31.72 fps, 29.97 tbr, 90k tbn, 180k tbc (default)
I used the following commands to successfully convert my video so that it can be played on my Android:
ffmpeg -i out.avi -vcodec h264 -s 720x1280 test3.mp4
I suspect my problem was that the resolution of my original video was too much for my device. This is what it was earlier:
C:\Users\muradgui\Documents\SmartTrust\Software\ffmpeg-20170418-6108805-win64-static\bin>ffmpeg -i out.avi
ffmpeg version N-85588-g6108805 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 6.3.0 (GCC)
configuration: --enable-gpl --enable-version3 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-zma --enable-zlib
libavutil 55. 61.100 / 55. 61.100
libavcodec 57. 93.100 / 57. 93.100
libavformat 57. 72.101 / 57. 72.101
libavdevice 57. 7.100 / 57. 7.100
libavfilter 6. 84.101 / 6. 84.101
libswscale 4. 7.101 / 4. 7.101
libswresample 2. 8.100 / 2. 8.100
libpostproc 54. 6.100 / 54. 6.100
Input #0, avi, from 'out.avi':
Metadata:
encoder : Lavf57.72.101
Duration: 00:00:10.00, start: 0.000000, bitrate: 4788 kb/s
Stream #0:0: Video: mpeg4 (Simple Profile) (FMP4 / 0x34504D46), yuv420p, 2250x4000 [SAR 1:1 DAR 9:16], 4596 kb/s, 25 fps, 25 tbr, 25 tbn, 25 tbc
Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 44100 Hz, stereo, s16p, 192 kb/s
Which has a 2250x4000 resolution (it was an image from the same device I transformed into a video with this article https://superuser.com/questions/617392/ffmpeg-image-sequence-with-various-durations).
I tried simply resizing the image without changing the codec to h264 but that didn't yield very good image. h264 did it for me :)
Hope this helps!! <3
Post a Comment for "Converting Video For Android Using FFMPEG"