AVPlayer无法播放FFMPEG的音频文件

马库斯

在请求音频数据之前,AVPlayer向FFMPEG请求字节范围0-1。

FFMPEG给出200响应,但AVPlayer要求206响应。

这将导致请求失败,并且无法播放音频。

预期行为:通过ffmpeg流播放曲目

当前行为:尝试使用ffmpeg流式传输时,我们收到“操作已停止”

样本FFMPEG命令:

ffmpeg -i "/path/to/audio/track.mp3" -vn -strict -2 -acodec pcm_u8 -f wav -listen 1 -seekable 1 http://localhost:8090/restream.wav

玩家记录:

Error Domain=AVFoundationErrorDomain Code=-11850 "Operation Stopped" UserInfo={NSLocalizedFailureReason=The server is not correctly configured., NSLocalizedDescription=Operation Stopped, NSUnderlyingError=0x600003bcc4b0 {Error Domain=NSOSStatusErrorDomain Code=-12939 "(null)"}}
!av_interleaved_write_frame(): Broken pipe

!Connection to tcp://localhost:8090 failed: Connection refused

!Connection to tcp://localhost:8090 failed: Connection refused

!Connection to tcp://localhost:8090 failed: Connection refused

!Error writing trailer of http://localhost:8090/restream.wav: Broken pipe

Apple将此错误定义为:

+"The HTTP server sending the media resource is not configured as expected. This might mean that the server does not support byte range requests."

并在此StackOverflow帖子中总结得很好

when AVPlayerItem receive a video URL , it do the following task:

    Send a bytes request HTTP Request, and range = 0 -1
    If the response code is 206 and return 1 bytes data, It do the 3th task, if not, AVErrorServerIncorrectlyConfigured error occurred.
    continue send other HTTP Request, to download segment of All duration. and the response of VideoData code must be 206

In my situation , when send range[0-1] HTTP request, the server side give me a 200 OK response, So error occurred.

网络日志:

GET /file.wav HTTP/1.1
Host: localhost:1234
X-Playback-Session-Id: F72F1139-6F4C-4A22-B334-407672045A86
Range: bytes=0-1
Accept: */*
User-Agent: AppleCoreMedia/1.0.0.18C61 (iPhone; U; CPU OS 14_3 like Mac OS X; en_us)
Accept-Language: en-us
Accept-Encoding: identity
Connection: keep-alive

HTTP/1.1 200 OK
Content-Type: application/octet-stream
Transfer-Encoding: chunked

使用此示例应用程序进行重现

也可以使用标准ffmpeg将URL复制到本地或远程ffmpeg URL中来复制

我们可以通过更改FFMPEG或AVPlayer来解决此问题吗?

马库斯

我在ffmpeg电子邮件列表上问了这个问题,看来这是不可能的:

如果我正确理解了您的请求,那么您不是要更改返回类型(您可以自己做),而是要执行字节范围请求。我认为FFmpeg根本不可能做到这一点。

另外,也无法使AVPlayer忽略字节范围请求:

这是一种苹果标准,媒体提供商需要使用范围标头来支持http 1.1(例如,请查看iTunes商店中有关播客的指南),因此我不希望很快出现

问答:有没有办法阻止avplayer发送范围http标头字段

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

无法识别播放哪个音频文件

来自分类Dev

音频文件无法在reactjs中播放

来自分类Dev

无法识别播放哪个音频文件

来自分类Dev

AVPlayer:在 Swift 中播放“即时”转码音频文件

来自分类Dev

无法在Vue Web应用中播放音频文件

来自分类Dev

颤动的声音无法播放音频文件

来自分类Dev

在函数中使用音频文件时无法播放

来自分类Dev

无法从sdcard Android播放音频文件

来自分类Dev

单击div时无法播放音频文件

来自分类Dev

无法在 IE11 上播放 aac 音频文件

来自分类Dev

FFmpeg跳过音频文件

来自分类Dev

在Python中播放远程音频文件?

来自分类Dev

星号,如何播放音频文件

来自分类Dev

如何播放AMR音频文件?

来自分类Dev

使用Swift播放随机音频文件

来自分类Dev

从目录快速播放音频文件

来自分类Dev

如何同时播放多个音频文件

来自分类Dev

依次播放多个音频文件

来自分类Dev

用golang播放音频文件

来自分类Dev

悬停播放音频文件

来自分类Dev

如何播放音频文件?

来自分类Dev

如何循环播放我的音频文件?

来自分类Dev

用力宝播放音频文件

来自分类Dev

Android播放音频文件(.wav)

来自分类Dev

Smartface:如何播放音频文件?

来自分类Dev

如何播放音频文件?

来自分类Dev

使用AVAudioPlayer播放多个音频文件

来自分类Dev

显示和播放音频文件

来自分类Dev

音频文件以错误的速度播放