'Mp4 segments playback in buffer gets stuck in Chromium browsers
I'm facing the following issue, Ive got a bunch of .bmp files and a .wav file that I convert to a mp4-file using the following ffmpeg command.
ffmpeg -i <input>.wav -i bmps/%5d.bmp -vcodec libx264 <output>.mp4
My goal is to make this .mp4 a single .m4s segment that can be played in loop using the Media Source Extension. [Like in this Example.][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
Here is the of the .mp4 file using mp4info
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
But after one repetition the Video gets stuck. What I tried so far:
- Change v:profile to high/main/baseline
- Switch audio codec from aac to libfdk_aac
- Change the audio bitrate to 128k/320k
- Use maxrate and minrate of 320k
Thanks [1]: https://jsfiddle.net/5cjnz9bf/2/
Solution 1:[1]
We compared the length of the audiostream and videostream and figured out that there are some differences in length (around 140ms). We added 5 Frames (25fps -> 200ms) and appended the following commands to ffmpeg in order to add a silent audio padding at the end of the audiostream:
-shortest -af apad
This solved the issue.
Make sure the length of the videostream and audiostream are the same.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | leetbacoon |
