JKi*_*rtz 29 iphone android ffmpeg h.264 html5-video
从理论上讲,IOS和ANDROID都会播放h.264文件,但我无法找出对它们进行编码的设置,因此它们实际上可以跨平台工作.有人知道如何使用一个文件对Android和IOS进行编码吗?
ps我知道关于html5视频和后备源的所有内容,我只是不想为每个下来的派克设备编码和托管新视频.
mpo*_*isf 52
这是我们在生产环境中用于转码为MPEG-4 h.264的ffmpeg命令行.我们已经在几个Android设备以及iOS上测试了输出.您可以将此作为起点,只需调整帧大小/帧速率和qfactor等内容.
ffmpeg -y
-i #{input_file}
-s 432x320
-b 384k
-vcodec libx264
-flags +loop+mv4
-cmp 256
-partitions +parti4x4+parti8x8+partp4x4+partp8x8
-subq 6
-trellis 0
-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
-acodec libfaac
-ac 1
-ar 16000
-r 13
-ab 32000
-aspect 3:2
#{output_file}
Run Code Online (Sandbox Code Playgroud)
影响Android兼容性的一些重要选项是:
-coder 0 Uses CAVLAC rather than CABAC entropy encoding (CABAC not supported on Android)
-trellis 0 Should be shut off, requires CABAC
-bf 0 Turns off B-frames, not supported on Android or other h.264 Baseline Profile devices
-subq 6 Determines what algorithms are used for subpixel motion searching. 7 applies to B-frames, not supported on Android.
-refs 5 Determines how many frames are referenced prior to the current frame. Increasing this number could affect compatibility
Run Code Online (Sandbox Code Playgroud)
在使用此ffmpeg配方对视频进行编码后,我们还通过qt-faststart传递视频.此步骤重新播放视频以进行流式传输.我们通过HTTP将其流式传输到Android应用中的嵌入式VideoView.没有问题流式传输到我们知道的任何Android设备.
更新2013-06-17:我只想添加一条说明,最好坚持使用H.264编码的"基线"配置文件,以便在所有Android设备上实现最大兼容性.上面的命令行没有明确指定H.264配置文件,但ffmpeg确实有一个-profile 命令行标志,如果您使用它的预设,它会很有用.你可能不应该搞砸-profile.我使用"主要"而不是"基线"配置文件(通过Handbrake)为我的ASUS Transformer 300平板电脑(Android 4.2)编码了视频."主要"配置文件存在音频与播放时视频不同步的问题.
我用它制作了一个带有嵌入视频的 Android 和 iOS 应用程序。视频在两个版本中均播放。(Android 示例)(iOS 示例)
该答案是对解释某些参数的已接受答案的补充。
ffmpeg
-y # Overwrite output files without asking.
-i input_filename # input file name
-s 432x320 # size of output file
-b:v 384k # bitrate for video
-vcodec libx264 # use H.264 video codec
-flags +loop+mv4 # use loop filter and four motion vector by macroblock
-cmp 256 # ??? Full pel motion estimation compare function
-partitions +parti4x4+parti8x8+partp4x4+partp8x8 #???
-subq 6 # determines algorythms for subpixel motion searching and partition decision
-trellis 0 # optimal rounding choices
-refs 5 # number of frames referenced prior to current frame
-bf 0 # turn of B-frames, something to do with H.264 and Baseline Profile
-flags2 +mixed_refs # ??? gave me an error so I just deleted it
-coder 0 # turn of the CABAC entropy encoder
-me_range 16 # max range of the motion search
-g 250 # GOP length (250 is the recommended default)
-keyint_min 25 # Minimum GOP length (25 is the recommended default)
-sc_threshold 40 # adjusts sensitivity of x264's scenecut detection (default is 40)
-i_qfactor 0.71 # Qscale difference between I-frames and P-frames (0.71 is the recommended default)
-qmin 10 -qmax 51 # min and max quantizer (10 and 51 are the recommended defaults)
-qdiff 4 # max QP step (4 is recommended default)
-c:a aac # Set the audio codec to use AAC
-ac 1 # number of audio channels
-ar 16000 # audio sampling frequency
-r 13 # frames per second
-ab 32000 # audio bitrate
-aspect 3:2 # sample aspect ratio
output_filename # name of the output file
Run Code Online (Sandbox Code Playgroud)
如果您可以填写一些我不确定的详细信息,请随意编辑。
这里又是剪切粘贴格式的。(我还必须添加-strict -2参数才能aac在我的计算机上工作。)
ffmpeg -y -i input_file.avi -s 432x320 -b:v 384k -vcodec libx264 -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 -2 output_file.mp4
Run Code Online (Sandbox Code Playgroud)
我在以下链接中找到了大部分信息:
| 归档时间: |
|
| 查看次数: |
16444 次 |
| 最近记录: |