Encoding video for Android

孤街浪徒 提交于 2020-01-03 00:34:08

问题


How do I properly encode video for Android? I've seen the supported media formats but I don't really know where to start with producing a video with those settings.

I'm not yet streaming these videos. These are just for local playback.

What's the correct process for encoding videos to maximize compatibility across Android devices?


回答1:


Here's the line that I use to convert videos suitable for Android. I've had good luck playing it on all devices running Android >= 4. Note that this matched the "high quality" parameters in the recommended video encodings.

avconv -i source.mp4 -vcodec libx264 -profile:v baseline -b 500k -r 30 -vf "setsar=1:1" -acodec libvo_aacenc -ac 2 -ar 44100 -ab 128k converted.mp4

The setsar filter I use sets the sample aspect ratio to 1:1, which I've found to be helpful if you're also using any of the transpose or scale options.

For example, to rotate the video clockwise, use this:

avconv ... -vf "transpose=dir=clock, setsar=1:1" ...

One thing to keep in mind is that some devices don't support playing videos with a resolution larger than a screen. That is, a phone with a screen size of 400x800 may have a hard time playing your video that's 800x600.

To rotate counterclockwise and scale your video such that its width is 400:

avconv ... -vf "transpose=dir=cclock, scale=400:trunc(ow/a/2)*2, setsar=1:1" ...

To rotate clockwise and scale your video such that its height is 400, use this:

avconv ... -vf "transpose=dir=clock, scale=trunc(oh*a/2)*2:400, setsar=1:1" ...

I hope this helps! It's been a lot of trial and error for me.

For what it's worth, here's the avconv I'm using:

avconv version 0.8.6-4:0.8.6-0ubuntu0.12.04.1, Copyright (c) 2000-2013 the Libav developers
  built on Apr  2 2013 17:02:36 with gcc 4.6.3

And I've installed this libav-tools package and this libavcodec-extra-53 package.



来源:https://stackoverflow.com/questions/19160199/encoding-video-for-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!