简体   繁体   中英

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. I would like the output to be playable on several devices, including Roku and iOS. This link states that Apple supports H264 High profile, level 4.1 and MP3 audio.

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. However, on the iPhone the video appears but the audio stream does not play. Is there an issue with the mp3 settings?

From 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

The document you reference is for HTTP Live Streaming, which uses a transport stream format, not an ISO mp4 format. Either way I have found many issues with mp3+video in ios. My recommendation is to use AAC (-acodec fdk-aac) instead of 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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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