What i am trying to do is convert video into mp4 format that will play in Android.

I've gone through http://developer.android.com/guide/appendix/media-formats.html

I am setting the following options

-vcodec libx264 -vprofile baseline -acodec libfaac -ar 44100 -ac 1 -ab 128k yet I get the error message "Sorry, This Video is not valid for streaming to this device"

I Played the video in android browser using videoJS http://video-js.zencoder.com/oceans-clip.mp4 and it WORKS fine.

I download the video oceans-clip.mp4 and tried to convert using minimalist options

-y -i working.mp4 -vprofile baseline pleasework.mp4

yet I get the same error message.

The following is the FFMPEG info dump of the video files

Working.mp4

Array
(
    [0] => ffmpeg version N-40229-g24e3f44-syslint Copyright (c) 2000-2012 the FFmpeg developers
    [1] =>   built on Apr 29 2012 22:01:41 with gcc 4.1.2 20080704 (Red Hat 4.1.2-52)
    [2] =>   configuration: --prefix=/usr/local/cpffmpeg --enable-shared --enable-nonfree --enable-gpl --enable-pthreads --enable-libopencore-amrnb --enable-decoder=liba52 --enable-libopencore-amrwb --enable-libfaac --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --extra-cflags=-I/usr/local/cpffmpeg/include/ --extra-ldflags=-L/usr/local/cpffmpeg/lib --enable-version3 --extra-version=syslint
    [3] =>   libavutil      51. 48.100 / 51. 48.100
    [4] =>   libavcodec     54. 17.101 / 54. 17.101
    [5] =>   libavformat    54.  3.100 / 54.  3.100
    [6] =>   libavdevice    53.  4.100 / 53.  4.100
    [7] =>   libavfilter     2. 72.100 /  2. 72.100
    [8] =>   libswscale      2.  1.100 /  2.  1.100
    [9] =>   libswresample   0. 11.100 /  0. 11.100
    [10] =>   libpostproc    52.  0.100 / 52.  0.100
    [11] => Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'working.mp4':
    [12] =>   Metadata:
    [13] =>     major_brand     : isom
    [14] =>     minor_version   : 1
    [15] =>     compatible_brands: isomavc1
    [16] =>     creation_time   : 2010-05-18 04:24:00
    [17] =>   Duration: 00:00:46.54, start: 0.000000, bitrate: 3342 kb/s
    [18] =>     Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 640x264 [SAR 132:133 DAR 320:133], 3195 kb/s, SAR 127:128 DAR 635:264, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc
    [19] =>     Metadata:
    [20] =>       creation_time   : 2010-05-18 04:24:00
    [21] =>       handler_name    : GPAC ISO Video Handler
    [22] =>     Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, s16, 144 kb/s
    [23] =>     Metadata:
    [24] =>       creation_time   : 2010-05-18 04:24:01
    [25] =>       handler_name    : GPAC ISO Audio Handler
    [26] => At least one output file must be specified
)

Not Working.mp4

Array
(
    [0] => ffmpeg version N-40229-g24e3f44-syslint Copyright (c) 2000-2012 the FFmpeg developers
    [1] =>   built on Apr 29 2012 22:01:41 with gcc 4.1.2 20080704 (Red Hat 4.1.2-52)
    [2] =>   configuration: --prefix=/usr/local/cpffmpeg --enable-shared --enable-nonfree --enable-gpl --enable-pthreads --enable-libopencore-amrnb --enable-decoder=liba52 --enable-libopencore-amrwb --enable-libfaac --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --extra-cflags=-I/usr/local/cpffmpeg/include/ --extra-ldflags=-L/usr/local/cpffmpeg/lib --enable-version3 --extra-version=syslint
    [3] =>   libavutil      51. 48.100 / 51. 48.100
    [4] =>   libavcodec     54. 17.101 / 54. 17.101
    [5] =>   libavformat    54.  3.100 / 54.  3.100
    [6] =>   libavdevice    53.  4.100 / 53.  4.100
    [7] =>   libavfilter     2. 72.100 /  2. 72.100
    [8] =>   libswscale      2.  1.100 /  2.  1.100
    [9] =>   libswresample   0. 11.100 /  0. 11.100
    [10] =>   libpostproc    52.  0.100 / 52.  0.100
    [11] => Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'pleasework.mp4':
    [12] =>   Metadata:
    [13] =>     major_brand     : isom
    [14] =>     minor_version   : 512
    [15] =>     compatible_brands: isomiso2avc1mp41
    [16] =>     creation_time   : 2010-05-18 04:24:00
    [17] =>     encoder         : Lavf54.3.100
    [18] =>   Duration: 00:00:46.54, start: 0.000000, bitrate: 1843 kb/s
    [19] =>     Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 640x264 [SAR 127:128 DAR 635:264], 1715 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc
    [20] =>     Metadata:
    [21] =>       creation_time   : 2010-05-18 04:24:00
    [22] =>       handler_name    : VideoHandler
    [23] =>     Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, s16, 124 kb/s
    [24] =>     Metadata:
    [25] =>       creation_time   : 2010-05-18 04:24:00
    [26] =>       handler_name    : SoundHandler
    [27] => At least one output file must be specified
)

The metadata looks almost the same yet it doesn't seem to play in android. Any help appreciated.

share|improve this question
up vote 18 down vote accepted

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)

share|improve this answer
5  
Or use the -movflags faststart option in ffmpeg. – LordNeckbeard Jan 5 '13 at 21:08
    
thanks, was not aware of this option. – rajneesh Jan 6 '13 at 3:48
    
@LordNeckbeard: Your comment worked for me but it made my video flicker when played full-screen on an Android tablet. It's fine everywhere else (iOS, Mac, PC). – dashmug Jan 16 '13 at 0:45
    
@dashmug I don't have an andriod tablet to test with, but I doubt the issue is due to -movflags faststart option and I don't know your ffmpeg command and the complete console output. – LordNeckbeard Jan 16 '13 at 19:00
1  
@LordNeckbeard: It's working now. It's not due to the -movflags faststart option. I added -vprofile baseline and it's good. Thanks. – dashmug Jan 18 '13 at 1:50

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>  
share|improve this answer
    
@user1079877 Works Fine , Thanks – swapnil7 May 17 '16 at 3:55
    
Video is compressed successfully. It is playing in android and iPhone but it is not playing in browser. Please help me. – Ankita Shah Sep 23 '16 at 10:19
    
This topic is about Android itself not browser. HTML5 has many implementation for different browers. – user1079877 Sep 24 '16 at 19:14
    
This will output MPEG-4 Part 2 video instead of H.264. – LordNeckbeard Dec 28 '16 at 23:47

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

share|improve this answer

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.

share|improve this answer

protected by tchrist Sep 24 '15 at 1:04

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.