FFMPEG mkv到mp4转换在HTML5播放器中缺少音频 [英] FFMPEG mkv to mp4 conversion lacks audio in HTML5 player

查看:710
本文介绍了FFMPEG mkv到mp4转换在HTML5播放器中缺少音频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用ffmpeg通过以下命令行将mkv文件转换为mp4:

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

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

生成的mp4Linux Mint's Xplayer上可以正常播放(视频和音频).但是上传文件1后,它没有声音播放.因此,我上传了另一个mp4文件2,该文件不必转换,它可以同时播放视频和音频.所以file-1发生的一切似乎与我对ffmpeg的使用有关.

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.

我正在使用的播放器称为afterglow.但是HTML5 player用相同的方式处理这两个文件:file-1&文件2

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

有人知道为什么在线播放ffmpeg转换后的文件时无声音吗?是否有其他转换命令可确保转换后的mkv files可以在线播放器播放声音?

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. 输入具有DTS音频.尽管MP4支持该功能,但我猜它不适用于HTML5.您必须转换为AAC.在-c copy之后添加-c:a aac.

您的ffmpeg很旧. FFmpeg AAC编码器进行了改进,缺少您的版本.通过下载最新版本来避免任何其他潜在问题.

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.

添加-movflags +faststart.编码后,这将在文件中移动一些信息,因此可以更快地开始播放.否则必须先下载整个视频,然后才能播放.

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.

示例命令:

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

这篇关于FFMPEG mkv到mp4转换在HTML5播放器中缺少音频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆