问题
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:
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.
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.
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