FFMPEG mkv to mp4 conversion lacks audio in HTML5 player

时光总嘲笑我的痴心妄想 提交于 2020-05-11 07:47:34

问题


I used ffmpeg to convert an mkv file to mp4 using this command line:

ffmpeg -i input.mkv -c copy file-1.mp4

The resulting mp4 plays fine (video and audio) on Linux Mint's Xplayer. But after uploading file-1, it played with no audio. So I uploaded another mp4 file-2, one I didn't have to convert, and it plays both video and audio without a problem. So whatever's going on with file-1 seems to be with my use of ffmpeg.

The player I'm using is called afterglow. But the HTML5 player handles these two files the same way: file-1 & file-2

Does anyone know why the ffmpeg converted file is soundless when played online? Is there a different conversion command that ensures converted mkv files will play with sound by online players?


回答1:


I see several issues:

  1. The input has DTS audio. Although it is supported in MP4 I guess it doesn't work with HTML5. You'll have to convert to AAC. Add -c:a aac after the -c copy.

  2. Your ffmpeg is old. The FFmpeg AAC encoder had improvements that your version is missing. Avoid any other potential issues by downloading a recent version.

  3. Add -movflags +faststart. This will move some info in the file after encoding so it can begin playback quicker; otherwise it will have to download the whole video before playing.

Example command:

ffmpeg -i input.mkv -c copy -c:a aac -movflags +faststart output.mp4


来源:https://stackoverflow.com/questions/46456692/ffmpeg-mkv-to-mp4-conversion-lacks-audio-in-html5-player

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!