Creative COW SIGN IN :: SPONSORS :: ADVERTISING :: ABOUT US :: CONTACT US :: FAQ
Creative COW's LinkedIn GroupCreative COW's Facebook PageCreative COW on TwitterCreative COW's Google+ PageCreative COW on YouTube
FORUMS:listlist (w/ descriptions)archivetagssearchhall of famerecent posts

FFMPEG mp4 videos for Android

COW Forums : FFmpeg

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
Share on Facebook
David GrahamFFMPEG mp4 videos for Android
by on Sep 7, 2011 at 10:41:04 pm

Hi,

I have been trying to get ffmpeg to convert avi video to mp4. All works great on my web browser but will not work on my Android tablet. Can you spot what is wrong? Please see the link for full details. Many thanks

http://ffmpeg.play4gain.com/


Dave


Return to posts index
Reply   Like  

Michael RampeRe: FFMPEG mp4 videos for Android
by on Sep 8, 2011 at 12:11:38 am

[David Graham] "Can you spot what is wrong?"

looks like the profile is not supported.

I read here: http://developer.android.com/guide/appendix/media-formats.html
that baseline profile is the only supported option. Pity.

Michael


Return to posts index
Reply   Like  

David GrahamRe: FFMPEG mp4 videos for Android
by on Sep 8, 2011 at 11:55:52 am

Hi Michael,

Thank you very much for your response. I think you have found the problem. In my second test - H.264 (MPEG-4 AVC). Command line below (hoping it may help others), according to your link is only good for Android 3.0 +

ffmpeg -i jump247-1.avi -s 720x400 -b 384k -vcodec libx264 -flags +loop+mv4 -cmp 256 -partitions
+parti4x4+parti8x8+partp4x4+partp8x8+partb8x8 -subq 7 -trellis 1 -refs 5 -bf 0 -flags2 +mixed_refs
-coder 0 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -qmin 10 -qmax 51
-qdiff 4 -strict experimental -acodec aac H.264-MPEG-4-AVC.mp4

From your link, it looks to me like I could build my video using H.263 as both the encoders and decoders have been included in my ffmpeg build. I am a real novice when it comes to media formats and encoding so can you suggest a command line? I note that H.263 only supports the following sizes: 128x96, 176x144, 352x288, 704x576, and 1408x1152.
I guess a video bitrate between 56 Kbps and 500 Kbps -b (384k worked before).
and a frame rate of 30 because I think that will be the same as the source video.
Audio perhaps: -strict experimental -acodec aac
Other gobbledygook is beyond the scope of my knowledge :)

So I think that I need to start like this:
ffmpeg -i jump247-1.avi -s 352x288 -b 384k -r 30 -vcodec h263 -strict experimental -acodec aac H.264-MPEG-4-AVC.mp4

If I run this I get an error message: "incorrect codec parameters"

It also says "could not find tag, codec not currently supported in container" , any suggestions?

Thanks in advance,

Dave

output below:

ffmpeg version 0.8.2.git, Copyright (c) 2000-2011 the FFmpeg developers
built on Sep 6 2011 14:01:03 with gcc 4.4.4 20100726 (Red Hat 4.4.4-13)
configuration: --enable-libfaac --enable-libx264 --enable-gpl --enable-nonfree --enable-postproc --enable-pthreads --enable-shared --enable-libxvid --enable-x11grab --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libmp3lame --enable-libfaac --enable-decoder=h263 --enable-encoder=h263 --enable-decoder=h264 --enable-encoder=h264 --enable-version3
libavutil 51. 16. 0 / 51. 16. 0
libavcodec 53. 13. 0 / 53. 13. 0
libavformat 53. 11. 0 / 53. 11. 0
libavdevice 53. 3. 0 / 53. 3. 0
libavfilter 2. 37. 0 / 2. 37. 0
libswscale 2. 1. 0 / 2. 1. 0
libpostproc 51. 2. 0 / 51. 2. 0
[avi @ 0x2312780] parser not found for codec pcm_s16le, packets or times may be invalid.
[avi @ 0x2312780] parser not found for codec dvvideo, packets or times may be invalid.
Input #0, avi, from 'jump247-1.avi':
Duration: 00:00:06.63, start: 0.000000, bitrate: 30318 kb/s
Stream #0.0: Video: dvvideo (dvsd / 0x64737664), yuv411p, 720x480 [SAR 32:27 DAR 16:9], 29.97 tbr, 29.97 tbn, 29.97 tbc
Stream #0.1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, 2 channels, s16, 1536 kb/s
File 'H.264-MPEG-4-AVC.mp4' already exists. Overwrite ? [y/N] y
Incompatible pixel format 'yuv411p' for codec 'h263', auto-selecting format 'yuv420p'
[buffer @ 0x2317860] w:720 h:480 pixfmt:yuv411p tb:1/1000000 sar:32/27 sws_param:
[scale @ 0x237e3a0] w:720 h:480 fmt:yuv411p -> w:352 h:288 fmt:yuv420p flags:0x4
[mp4 @ 0x23154c0] track 0: could not find tag, codec not currently supported in container
Output #0, mp4, to 'H.264-MPEG-4-AVC.mp4':
Metadata:
encoder : Lavf53.11.0
Stream #0.0: Video: h263, yuv420p, 352x288 [SAR 16:11 DAR 16:9], q=2-31, 384 kb/s, 90k tbn, 30 tbc
Stream #0.1: Audio: aac (@[0][0][0] / 0x0040), 48000 Hz, 2 channels, s16, 384 kb/s
Stream mapping:
Stream #0.0 -> #0.0 (dvvideo -> h263)
Stream #0.1 -> #0.1 (pcm_s16le -> aac)
Could not write header for output file #0 (incorrect codec parameters ?)


Return to posts index
Reply   Like  


Reuben MartinRe: FFMPEG mp4 videos for Android
by on Nov 1, 2011 at 4:49:28 am

I use this for encoding mp4 for my HTC Evo 4G.(Set for high quality, so somewhat slow...)

ffmpeg -i Source.avi -vcodec libx264 -crf 20 -trellis 2 -threads 8 -flags +loop+mv4+aic -deblockalpha 0 -deblockbeta 0 -cmp +chroma -partitions +parti4x4+parti8x8+partp4x4+partp8x8+partb8x8 -subq 7 -refs 5 -bf 0 -flags2 +mixed_refs-fastpskip -coder 0 -me_method umh -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -qmin 10 -qmax 51 -qdiff 4 -vsync 2 -acodec libfaac -ab 160k -async 1 -f mp4 Output.mp4


Return to posts index
Reply   Like  

David GrahamRe: FFMPEG mp4 videos for Android
by on Nov 1, 2011 at 12:19:43 pm

I have given your solution a try and it does work but still not with my Android device. However from the output when ffmpeg was running, I did notice some errors (marked in orange) that self corrected. You can see the results under test 3 at http://ffmpeg.play4gain.com. I have not compiled my ffmpeg for a number of weeks so I have forgotten how the configuration worked but I am wondering if I am lacking some components that make the difference. Would you mind downloading the avi clip and building the mp4 video under your configuration and letting me have a copy of the mp4 file together with the output from ffmpeg to try. If it works, I can hopefully recompile my ffmpeg source with your configuration and get a result. My avi clip is at http://ffmpeg.play4gain.com/jump247-1.avi

Many thanks in advance,

Dave


Return to posts index
Reply   Like  

Reuben MartinRe: FFMPEG mp4 videos for Android
by on Nov 6, 2011 at 5:57:23 am

http://dl.dropbox.com/u/38727164/jump247-1.mp4

Plays fine on my Evo 4G. Please note: This does not mean it will play equally well on any android device!! This has much less to do with the OS on the device than it has to do with the chip used for hardware decoding of the h264 stream. Not all chips are the same.

This results in a Main Profile encoding. Your device may only support Baseline Profile.

For what it's worth, I use MoboPlayer for playback.

Your source is interlaced with 411 sampling. I used the following:

ffmpeg -i jump247-1.avi -deinterlace -vcodec libx264 -pix_fmt yuv420p -crf 20 -trellis 2 -threads 8 -flags +loop+mv4+aic -deblockalpha 0 -deblockbeta 0 -cmp +chroma -partitions +parti4x4+parti8x8+partp4x4+partp8x8+partb8x8 -subq 7 -refs 5 -bf 0 -flags2 +mixed_refs-fastpskip -coder 0 -me_method umh -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -qmin 10 -qmax 51 -qdiff 4 -vsync 2 -acodec libfaac -ab 160k -async 1 -f mp4 Test.mp4
ffmpeg version 0.7.6, Copyright (c) 2000-2011 the FFmpeg developers
built on Oct 20 2011 00:10:40 with gcc 4.5.3
configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --enable-shared --cc=x86_64-pc-linux-gnu-gcc --disable-static --enable-gpl --enable-version3 --enable-postproc --enable-avfilter --disable-stripping --disable-debug --disable-doc --enable-libmp3lame --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-libfaac --enable-nonfree --enable-libdc1394 --disable-indev=v4l --disable-indev=oss --enable-x11grab --disable-outdev=oss --enable-frei0r --enable-libfreetype --enable-pthreads --enable-libopencore-amrwb --enable-libopencore-amrnb --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libvpx --enable-libopenjpeg --disable-altivec --disable-avx --cpu=host --enable-hardcoded-tables
libavutil 50. 43. 0 / 50. 43. 0
libavcodec 52.122. 0 / 52.122. 0
libavformat 52.110. 0 / 52.110. 0
libavdevice 52. 5. 0 / 52. 5. 0
libavfilter 1. 80. 0 / 1. 80. 0
libswscale 0. 14. 1 / 0. 14. 1
libpostproc 51. 2. 0 / 51. 2. 0
Input #0, avi, from 'jump247-1.avi':
Duration: 00:00:06.63, start: 0.000000, bitrate: 30318 kb/s
Stream #0.0: Video: dvvideo, yuv411p, 720x480 [PAR 32:27 DAR 16:9], 29.97 tbr, 29.97 tbn, 29.97 tbc
Stream #0.1: Audio: pcm_s16le, 48000 Hz, 2 channels, s16, 1536 kb/s
[buffer @ 0xca7720] w:720 h:480 pixfmt:yuv411p tb:1/1000000 sar:32/27 sws_param:
[buffersink @ 0xca7d50] auto-inserting filter 'auto-inserted scaler 0' between the filter 'src' and the filter 'out'
[scale @ 0xcaf7f0] w:720 h:480 fmt:yuv411p -> w:720 h:480 fmt:yuv420p flags:0x4
[libx264 @ 0xca9560] using SAR=32/27
[libx264 @ 0xca9560] using cpu capabilities: MMX2 SSE2Fast FastShuffle SSEMisalign LZCNT
[libx264 @ 0xca9560] profile Main, level 3.0
[libx264 @ 0xca9560] 264 - core 118 - H.264/MPEG-4 AVC codec - Copyleft 2003-2011 - http://www.videolan.org/x264.html - options: cabac=0 ref=5 deblock=1:0:0 analyse=0x1:0x131 me=umh subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=2 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=0 chroma_qp_offset=-2 threads=8 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=20.0 qcomp=0.50 qpmin=10 qpmax=51 qpstep=4 ip_ratio=1.41 aq=1:1.00
Output #0, mp4, to 'Test.mp4':
Metadata:
encoder : Lavf52.110.0
Stream #0.0: Video: libx264, yuv420p, 720x480 [PAR 32:27 DAR 16:9], q=10-51, 200 kb/s, 30k tbn, 29.97 tbc
Stream #0.1: Audio: libfaac, 48000 Hz, 2 channels, s16, 160 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Press [q] to stop, [?] for help
frame= 199 fps= 52 q=-1.0 Lsize= 1931kB time=00:00:06.63 bitrate=2382.0kbits/s
video:1795kB audio:130kB global headers:0kB muxing overhead 0.269304%
frame I:69 Avg QP:22.70 size: 9326
[libx264 @ 0xca9560] frame P:130 Avg QP:24.15 size: 9187
[libx264 @ 0xca9560] mb I I16..4: 74.7% 0.0% 25.3%
[libx264 @ 0xca9560] mb P I16..4: 16.3% 0.0% 8.4% P16..4: 59.3% 14.4% 0.7% 0.1% 0.0% skip: 0.9%
[libx264 @ 0xca9560] coded y,uvDC,uvAC intra: 27.9% 94.8% 35.1% inter: 17.3% 91.9% 2.8%
[libx264 @ 0xca9560] i16 v,h,dc,p: 31% 12% 11% 47%
[libx264 @ 0xca9560] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 11% 35% 6% 6% 6% 4% 5% 2%
[libx264 @ 0xca9560] i8c dc,h,v,p: 53% 17% 22% 9%
[libx264 @ 0xca9560] Weighted P-Frames: Y:10.8% UV:4.6%
[libx264 @ 0xca9560] ref P L0: 65.1% 14.0% 11.7% 4.3% 2.8% 1.9% 0.1%
[libx264 @ 0xca9560] kb/s:2214.23


Return to posts index
Reply   Like  


Reuben MartinRe: FFMPEG mp4 videos for Android
by on Nov 6, 2011 at 6:00:09 am

http://dl.dropbox.com/u/38727164/jump247-1.mp4

Plays fine on my Evo 4G. Please note: This does not mean it will play equally well on any android device!! This has much less to do with the OS on the device than it has to do with the chip used for hardware decoding of the h264 stream. Not all chips are the same.

This results in a Main Profile encoding. Your device may only support Baseline Profile.

For what it's worth, I use MoboPlayer for playback.

Your source is interlaced with 411 sampling. I used the following:

ffmpeg -i jump247-1.avi -deinterlace -vcodec libx264 -pix_fmt yuv420p -crf 20 -trellis 2 -threads 8 -flags +loop+mv4+aic -deblockalpha 0 -deblockbeta 0 -cmp +chroma -partitions +parti4x4+parti8x8+partp4x4+partp8x8+partb8x8 -subq 7 -refs 5 -bf 0 -flags2 +mixed_refs-fastpskip -coder 0 -me_method umh -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -qmin 10 -qmax 51 -qdiff 4 -vsync 2 -acodec libfaac -ab 160k -async 1 -f mp4 Test.mp4
ffmpeg version 0.7.6, Copyright (c) 2000-2011 the FFmpeg developers
built on Oct 20 2011 00:10:40 with gcc 4.5.3
configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --enable-shared --cc=x86_64-pc-linux-gnu-gcc --disable-static --enable-gpl --enable-version3 --enable-postproc --enable-avfilter --disable-stripping --disable-debug --disable-doc --enable-libmp3lame --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-libfaac --enable-nonfree --enable-libdc1394 --disable-indev=v4l --disable-indev=oss --enable-x11grab --disable-outdev=oss --enable-frei0r --enable-libfreetype --enable-pthreads --enable-libopencore-amrwb --enable-libopencore-amrnb --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libvpx --enable-libopenjpeg --disable-altivec --disable-avx --cpu=host --enable-hardcoded-tables
libavutil 50. 43. 0 / 50. 43. 0
libavcodec 52.122. 0 / 52.122. 0
libavformat 52.110. 0 / 52.110. 0
libavdevice 52. 5. 0 / 52. 5. 0
libavfilter 1. 80. 0 / 1. 80. 0
libswscale 0. 14. 1 / 0. 14. 1
libpostproc 51. 2. 0 / 51. 2. 0
Input #0, avi, from 'jump247-1.avi':
Duration: 00:00:06.63, start: 0.000000, bitrate: 30318 kb/s
Stream #0.0: Video: dvvideo, yuv411p, 720x480 [PAR 32:27 DAR 16:9], 29.97 tbr, 29.97 tbn, 29.97 tbc
Stream #0.1: Audio: pcm_s16le, 48000 Hz, 2 channels, s16, 1536 kb/s
[buffer @ 0xca7720] w:720 h:480 pixfmt:yuv411p tb:1/1000000 sar:32/27 sws_param:
[buffersink @ 0xca7d50] auto-inserting filter 'auto-inserted scaler 0' between the filter 'src' and the filter 'out'
[scale @ 0xcaf7f0] w:720 h:480 fmt:yuv411p -> w:720 h:480 fmt:yuv420p flags:0x4
[libx264 @ 0xca9560] using SAR=32/27
[libx264 @ 0xca9560] using cpu capabilities: MMX2 SSE2Fast FastShuffle SSEMisalign LZCNT
[libx264 @ 0xca9560] profile Main, level 3.0
[libx264 @ 0xca9560] 264 - core 118 - H.264/MPEG-4 AVC codec - Copyleft 2003-2011 - http://www.videolan.org/x264.html - options: cabac=0 ref=5 deblock=1:0:0 analyse=0x1:0x131 me=umh subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=2 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=0 chroma_qp_offset=-2 threads=8 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=20.0 qcomp=0.50 qpmin=10 qpmax=51 qpstep=4 ip_ratio=1.41 aq=1:1.00
Output #0, mp4, to 'Test.mp4':
Metadata:
encoder : Lavf52.110.0
Stream #0.0: Video: libx264, yuv420p, 720x480 [PAR 32:27 DAR 16:9], q=10-51, 200 kb/s, 30k tbn, 29.97 tbc
Stream #0.1: Audio: libfaac, 48000 Hz, 2 channels, s16, 160 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Press [q] to stop, [?] for help
frame= 199 fps= 52 q=-1.0 Lsize= 1931kB time=00:00:06.63 bitrate=2382.0kbits/s
video:1795kB audio:130kB global headers:0kB muxing overhead 0.269304%
frame I:69 Avg QP:22.70 size: 9326
[libx264 @ 0xca9560] frame P:130 Avg QP:24.15 size: 9187
[libx264 @ 0xca9560] mb I I16..4: 74.7% 0.0% 25.3%
[libx264 @ 0xca9560] mb P I16..4: 16.3% 0.0% 8.4% P16..4: 59.3% 14.4% 0.7% 0.1% 0.0% skip: 0.9%
[libx264 @ 0xca9560] coded y,uvDC,uvAC intra: 27.9% 94.8% 35.1% inter: 17.3% 91.9% 2.8%
[libx264 @ 0xca9560] i16 v,h,dc,p: 31% 12% 11% 47%
[libx264 @ 0xca9560] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 11% 35% 6% 6% 6% 4% 5% 2%
[libx264 @ 0xca9560] i8c dc,h,v,p: 53% 17% 22% 9%
[libx264 @ 0xca9560] Weighted P-Frames: Y:10.8% UV:4.6%
[libx264 @ 0xca9560] ref P L0: 65.1% 14.0% 11.7% 4.3% 2.8% 1.9% 0.1%
[libx264 @ 0xca9560] kb/s:2214.23


Return to posts index
Reply   Like  

David GrahamRe: FFMPEG mp4 videos for Android
by on Dec 28, 2011 at 4:18:57 pm

Sorry that I have taken so long to reply, I was hoping to contribute something more useful so I have been trying some stuff first. I fear your samples didn't work for what I wanted but I appreciate your time making them available to me. In the end I succeeded using handbrake with web optimise (I think this sets up the moov atom) and also with Winff. With ffmpeg you need to run qt-faststart to get the moov atom in the right place. However this worked for what I wanted but I think that there are a lot of possible variations for different platforms. However even after lots of tries I could not get it to work on the Linux command line as I had wanted but I have learnt a lot from poking around. I have given up now but I suspect it is all in the ffmpeg compilation - maybe I needed to use an older version for what I wanted.

Here is a list of links that I found useful:

http://www.broken-links.com/2010/07/30/encoding-video-for-android/
https://help.ubuntu.com/community/AndroidVideoEncoding
http://ffmpeg.org/ffmpeg.html
http://developer.android.com/guide/appendix/media-formats.html
http://h264.code-shop.com/trac/wiki/Encoding
https://sites.google.com/site/linuxencoding/x264-ffmpeg-mapping
http://can.homeunix.org/sw/psp/ffmpeg_psp/
http://ffmpeg.arrozcru.org/autobuilds/
http://ubuntuforums.org/showpost.php?p=10671718&postcount=1606
http://androidcommunity.com/forums/f41/new-updated-video-encoder-for-g1-618...
http://www.penguin.cz/~utx/amr
http://www.linuxquestions.org/questions/linux-mobile-81/android-g1-and-vide...
https://help.ubuntu.com/community/iPodVideoEncoding
http://linux.justinhartman.com/FFmpeg,_FFmpeg-PHP,_Lame,_Libogg,_Libvorbis,...
http://ffmpeg.org/
http://ubuntuforums.org/showthread.php?t=786095
http://www.linuxfromscratch.org/blfs/view/6.3/multimedia/xvid.html
http://en.wikibooks.org/wiki/FFMPEG_An_Intermediate_Guide
http://flowplayer.org/demos/scripting/fallback.html
http://www.catswhocode.com/blog/19-ffmpeg-commands-for-all-needs


Return to posts index
Reply   Like  

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
Share on Facebook


FORUMSTUTORIALSFEATURESVIDEOSPODCASTSEVENTSSERVICESNEWSLETTERNEWSBLOGS

Creative COW LinkedIn Group Creative COW Facebook Page Creative COW on Twitter
© 2014 CreativeCOW.net All rights are reserved. - Privacy Policy

[Top]