在请求音频数据之前,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
+"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商店中有关播客的指南),因此我不希望很快出现
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句