HTML5 lagging videos MP4

2019-01-27 10:57发布

问题:

I have a problem, When i upload a video to my website And play the video in my HTML5 player(video.js) They are lagging, But it's weird because not all mp4 files are lagging on the site only some videos, But when i download them from my server and play them on my computer it's playing normal.

Why are some video's lagging? Does someone have a explanation for it?

回答1:

If the problem is bandwidth, then depending on format, source bit rate, framesize etc you'll want to re-encode to a more optimal size for your intended purpose

ffmpeg -i "my.mp4" -f mp4 -vcodec mpeg4 -b 512k -r 30 -s 640x360 -acodec libfaac -ar 32000 -ab 128k -ac 2 -threads 8 -movflags faststart "my_reduced.mp4"

-b = video bit rate (lower value = smaller size of the video file... however it reduces the quality of video.

-s = resolution of the video, optimize it to match desired output (but remember to maintain the correct aspect ration)

-movflags = relocates metadata to the start of the file reducing buffering time