Home/News | About | Download | Documentation | Forum | Bug Reports | Contact | Donations | Consulting | Projects | Legal | Security | FATE


ffmpeg (android build) unable to open mp4 file

Who doesn't love them :) But for faster response on your Bug Reports, please visit: http://www.ffmpeg.org/bugreports.html
Forum rules
First of all, please remember that all the developers working on FFmpeg are volunteers, we are not paid for analyzing, debugging, fixing and answering bug reports. While we try our best to create high quality software and be responsive, if you should not get an answer, please consider the above and be aware of the fact that we receive many bug reports and the amount of time it takes to deal with them can be substantial. Nevertheless most issues get resolved, just please understand that there are no guarantees nor promises.

ffmpeg (android build) unable to open mp4 file

Postby jonywalker » Fri Aug 08, 2014 10:32 pm

I wrote a media wrapper using avformat and avcodec to open media container. The app works in multple-platform (android, ios, windows and linux for years. Just recently I converted some movie files from mkv to mp4 using ffmpeg, and found these files could not be opened with avformat_open_input under android.
The cmd line I used looks like following:
ffmpeg -i original-movie.mkv -map 0 -codec:v copy -codec:a copy movie.mp4
The conversion is simple, and the resulting movie.mp4 could be played by all media players, but not by my android app with following code
AVFormatContext * pAVFmtContext = NULL;
av_register_all();
AVDictionary * options = NULL;
avformat_open_input( pAVFmtContext, movie.mp4, NULL, &options ) This first code always fails!
The code has no problem to open all existing mp4 movies files, just not those mp4 files that are converted from mkv by ffmpeg.
I tried with ffmpeg-1.2 2.0 and 2.3, to do conversion, the resulting mp4 files could not be opened by ffmpeg android. I even tried my old version app, which was build with ffmpeg-1.2 without success.
Note: The same app in windows and other platform build has no problem. And in android, it could play all media files, just not those converted by itsself. It is very very very strange!
jonywalker
 
Posts: 3
Joined: Fri Aug 08, 2014 9:01 pm

Re: ffmpeg (android build) unable to open mp4 file

Postby jonywalker » Sat Aug 09, 2014 12:05 am

I found the bug in ffmpeg! If it converts just a piece of 15 mins, the piece could be played. If more than 30 mins, the file could not be opened.
jonywalker
 
Posts: 3
Joined: Fri Aug 08, 2014 9:01 pm

Re: ffmpeg (android build) unable to open mp4 file

Postby jonywalker » Sun Aug 10, 2014 6:36 pm

I am getting close to the real cause of the problem. it must be a problem in file seeking with avio_seek or function point *seek of AVIOContext for the android implementation. The mp4 files I converted are large, more than 8 GB, those require not only sdcard support of large file size, the format exFAT is must. ffmpeg mp4 places the ftyp atom at the first place, then the mdat, where audio and video samples are stored, and finally the moov atom. That is ok since the size of moov container is unknown before the file is closed. The mdat atom is in my case larger than 8 GB, without seek64 the moov atom cannot be parsed. avformat_open_input() fails with error code "Invalid data contained while processing input data". Although i already put the right compiler option to android gcc:

./configure --target-os=android \
--prefix="${PREFIX}" \
--enable-cross-compile \
--extra-libs="-lc -lm -ldl -llog -lgcc -lgnustl_shared" \
--arch=arm \
--cross-prefix="${CROSS_PREFIX}" \
--cc="${CROSS_PREFIX}gcc" \
--nm="${CROSS_PREFIX}nm" \
--sysroot="${PLATFORM}" \
--pkg-config=pkg-config \
--extra-cflags="-O3 -fpic -fexceptions -DANDROID -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 -DHAVE_SYS_UIO_H=1 -Dipv6mr_interface=ipv6mr_ifindex -fasm -Wno-psabi -fno-short-enums -fno-strict-aliasing $OPTIMIZE_CFLAGS" \
...

If ffmpeg avio_seek implementation ignores these flags for android build, the moov box cannot be parsed if mdat is larger than 4 GB! This is true since I don't have the problem if file size is small.
jonywalker
 
Posts: 3
Joined: Fri Aug 08, 2014 9:01 pm


Return to Bugs, bugs, bugs :)

Who is online

Users browsing this forum: No registered users and 1 guest