Mp4片段播放在缓冲卡住在铬浏览器



我面临以下问题,我有一堆。bmp文件和一个。wav文件,我使用以下ffmpeg命令转换为mp4文件。

ffmpeg -i <input>.wav -i bmps/%5d.bmp -vcodec libx264 <output>.mp4

我的目标是使这个。mp4一个单一的。m4s段,可以使用媒体源扩展循环播放。[1]

ffmpeg -loglevel error -y 
-i <output>.mp4 
-vf scale=1280x720 
-hls_segment_type fmp4 
-vcodec libx264 
-acodec aac 
-b:a 128k 
-pix_fmt yuv420p 
-hls_flags independent_segments 
-flags +cgop  
-movflags frag_keyframe+empty_moov 
-hls_time 1000 
-r 25 -g 25 -bf 0 
-ar 44100 
-f hls 
<output>.m3u8

下面是使用mp4info

创建。mp4文件
File:
major brand:      isom
minor version:    200
compatible brand: isom
compatible brand: iso2
compatible brand: avc1
compatible brand: mp41
fast start:       no
Movie:
duration:   10065 (media timescale units)
duration:   10065 (ms)
time scale: 1000
fragments:  no
Found 2 Tracks
Track 1:
flags:        3 ENABLED IN-MOVIE
id:           1
type:         Video
duration: 9960 ms
language: und
media:
sample count: 249
timescale:    12800
duration:     127488 (media timescale units)
duration:     9960 (ms)
bitrate (computed): 1249.046 Kbps
display width:  1280.000000
display height: 720.000000
frame rate (computed): 25.000
Sample Description 0
Coding:       avc1 (H.264)
Codec String: avc1.F4001F
AVC Profile:          244
AVC Profile Compat:   0
AVC Level:            31
AVC NALU Length Size: 4
AVC SPS: [67f4001f919b280a00b742000003000200000300641e30632c]
AVC PPS: [68ebe3c44844]
Width:       1280
Height:      720
Depth:       24
Track 2:
flags:        3 ENABLED IN-MOVIE
id:           2
type:         Audio
duration: 10065 ms
language: und
media:
sample count: 218
timescale:    22050
duration:     222949 (media timescale units)
duration:     10111 (ms)
bitrate (computed): 79.182 Kbps
Sample Description 0
Coding:       mp4a (MPEG-4 Audio)
Codec String: mp4a.40.2
Stream Type: Audio
Object Type: MPEG-4 Audio
Max Bitrate: 79181
Avg Bitrate: 79181
Buffer Size: 0
MPEG-4 Audio Object Type: 2 (AAC Low Complexity)
MPEG-4 Audio Decoder Config:
Sampling Frequency: 22050
Channels: 1
Extension:
Object Type: Spectral Band Replication
SBR Present: no
PS Present:  no
Sampling Frequency: 0
Sample Rate: 22050
Sample Size: 16
Channels:    2

但重复一次后,视频卡住了。到目前为止我所尝试的:

  • 将v:profile更改为high/main/baseline
  • 将音频编解码器从aac切换到libfdk_aac
  • 将音频比特率更改为128k/320k
  • 使用320k的maxrate和minrate

谢谢[1]: https://jsfiddle.net/5cjnz9bf/2/

我们比较了音频流和视频流的长度,发现它们在长度上有一些差异(大约140ms)。我们添加了5帧(25fps ->200ms),并将以下命令附加到ffmpeg,以便在audiostream的末尾添加无声音频填充:

-shortest -af apad

问题解决了。

确保视频流和音频流的长度相同。

最新更新