简体   繁体   English

使用FFMPEG编码iOS兼容的h264音频流

[英]Encode iOS compatible h264 audio stream with FFMPEG

I am using FFMPEG with Python to encode a low bit rate version of videos that I import. 我正在使用FFMPEG和Python来编码我导入的低比特率视频版本。 I would like the output to be playable on several devices, including Roku and iOS. 我希望输出可以在几个设备上播放,包括Roku和iOS。 This link states that Apple supports H264 High profile, level 4.1 and MP3 audio. 链接指出Apple支持H264 High Profile,4.1级和MP3音频。

ffmpeg -preset veryslow -y -profile:v high -level 4.0 -movflags +faststart -codec:a libmp3lame -qscale:a 2 -s 1280x720 out.mp4

The resulting videos play fine in an HTML5 browser on a computer. 生成的视频在计算机上的HTML5浏览器中播放得很好。 However, on the iPhone the video appears but the audio stream does not play. 但是,在iPhone上会显示视频,但音频流不会播放。 Is there an issue with the mp3 settings? mp3设置有问题吗?

From ffprobe: 来自ffprobe:

[STREAM]
index=1
codec_name=mp3
codec_long_name=MP3 (MPEG audio layer 3)
profile=unknown
codec_type=audio
codec_time_base=1/44100
codec_tag_string=mp4a
codec_tag=0x6134706d
sample_fmt=s16p
sample_rate=44100
channels=1
channel_layout=mono
bits_per_sample=0
id=N/A
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/44100
start_pts=-1105
start_time=-0.025057
duration_ts=2321489
duration=52.641474
bit_rate=94949
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=2016
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=1
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
TAG:language=und
TAG:handler_name=SoundHandler
[/STREAM]

I tried using AAC, but did not get good results with the native FFMPEG encoder 我尝试使用AAC,但没有使用原生FFMPEG编码器获得良好的结果

The document you reference is for HTTP Live Streaming, which uses a transport stream format, not an ISO mp4 format. 您引用的文档适用于HTTP Live Streaming,它使用传输流格式,而不是ISO mp4格式。 Either way I have found many issues with mp3+video in ios. 无论哪种方式,我都发现了许多与ios中的mp3 +视频有关的问题。 My recommendation is to use AAC (-acodec fdk-aac) instead of mp3. 我的建议是使用AAC(-acodec fdk-aac)而不是mp3。 It is just as universally supported, and will provide you with better audio at lower bitrates. 它受到普遍支持,并将以较低的比特率为您提供更好的音频。 If that is not an option, try to specify all audio settings on the command line (-channles -samplerate, etc) 如果这不是一个选项,请尝试在命令行上指定所有音频设置(-channles -samplerate等)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM