简体   繁体   English

FFMPEG mkv 到 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使用以下命令行将mkv文件转换为mp4

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

The resulting mp4 plays fine (video and audio) on Linux Mint's Xplayer .生成的mp4可以在Linux Mint's Xplayer上正常播放(视频和音频)。 But after uploading file-1, it played with no audio.但是上传file-1后,它没有音频播放。 So I uploaded another mp4 file-2, one I didn't have to convert, and it plays both video and audio without a problem.所以我上传了另一个mp4文件 - 2,我不需要转换,它可以毫无问题地播放视频和音频。 So whatever's going on with file-1 seems to be with my use of ffmpeg .所以无论file-1发生了什么似乎都与我对ffmpeg使用有关。

The player I'm using is called afterglow .我正在使用的播放器称为afterglow But the HTML5 player handles these two files the same way: file-1 & file-2但是HTML5 player以相同的方式处理这两个文件:file-1 & file-2

Does anyone know why the ffmpeg converted file is soundless when played online?有谁知道ffmpeg转换后的文件在线播放时为什么ffmpeg Is there a different conversion command that ensures converted mkv files will play with sound by online players?是否有不同的转换命令可以确保转换后的mkv files可以通过在线播放器播放声音?

I see several issues:我看到几个问题:

  1. The input has DTS audio.输入具有 DTS 音频。 Although it is supported in MP4 I guess it doesn't work with HTML5.尽管 MP4 支持它,但我猜它不适用于 HTML5。 You'll have to convert to AAC.您必须转换为AAC。 Add -c:a aac after the -c copy .-c copy之后添加-c:a aac

  2. Your ffmpeg is old.你的ffmpeg是旧的。 The FFmpeg AAC encoder had improvements that your version is missing. FFmpeg AAC 编码器的改进之处在于您的版本缺失。 Avoid any other potential issues by downloading a recent version .通过下载最新版本避免任何其他潜在问题。

  3. Add -movflags +faststart .添加-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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM