[FFmpeg-user] iOS AVPlayer won't play audio files from FFMPEG

Marcus P norfolk840 at gmail.com
Sat Jan 16 19:33:53 EET 2021

Before requesting audio data iOS AVPlayer requests byte range 0-1 from

FFMPEG gives a 200 response, but AVPlayer requires a 206 response.

This results in the request failing and audio can't be played.

Can we change FFMPEG http to return a 206 response?

*Expected behavior*: Play tracks when streaming through ffmpeg

*Current behavior*: When trying to stream with ffmpeg we get "Operation

Sample FFMPEG command:

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

Player Log:

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

This error is defined by Apple

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

And summarised nicely in this StackOverflow post

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.

Network Log:

GET /file.wav HTTP/1.1Host: localhost:1234X-Playback-Session-Id:
F72F1139-6F4C-4A22-B334-407672045A86Range: bytes=0-1Accept:
*/*User-Agent: AppleCoreMedia/ (iPhone; U; CPU OS 14_3 like
Mac OS X; en_us)Accept-Language: en-usAccept-Encoding:
identityConnection: keep-alive
HTTP/1.1 200 OKContent-Type: application/octet-streamTransfer-Encoding: chunked

Reproduce using this sample app

This can also be reproduced using standard ffmpeg and adding URL to local
or remote ffmpeg URL

Can we solve this by making changes to FFMPEG to return 206?

More information about the ffmpeg-user mailing list