ffmpeg mp4 html5,FFMPEG mkv to mp4 conversion lacks audio in HTML5 player

问题

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值