iOS AVPlayer won't play audio files from FFMPEG

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

iOS AVPlayer won't play audio files from FFMPEG

Marcus P
Before requesting audio data iOS AVPlayer requests byte range 0-1 from
FFMPEG.

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
Stopped"

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
<https://developer.apple.com/documentation/avfoundation/averror/2330596-serverincorrectlyconfigured?changes=_4_1>
as:

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

And summarised nicely in this StackOverflow post
<https://stackoverflow.com/a/42244954/3693688>:

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/1.0.0.18C61 (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
<https://github.com/dev-manager-uk/ios-ffmpeg>:

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?
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: iOS AVPlayer won't play audio files from FFMPEG

Carl Eugen Hoyos-2
Am Sa., 16. Jan. 2021 um 18:57 Uhr schrieb Marcus P <[hidden email]>:

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

Unrelated:
You are not sending valid wav files like this.

[...]

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

If I understand your request correctly, you are not asking for a
change of a return type (you could probably do that yourself)
but for the implementation of byte range requests.
I don't think this is possible at all with FFmpeg.

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: iOS AVPlayer won't play audio files from FFMPEG

Marcus P
 Thanks for your help Carl.

How can I improve our ffmpeg request to send valid wav files?

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

Unrelated:
You are not sending valid wav files like this.

On Sun, Jan 17, 2021 at 9:34 PM Carl Eugen Hoyos <[hidden email]> wrote:

> Am Sa., 16. Jan. 2021 um 18:57 Uhr schrieb Marcus P <[hidden email]
> >:
>
> > ffmpeg -i "/path/to/audio/track.mp3" -vn -strict -2 -acodec pcm_u8 -f
> > wav -listen 1 -seekable 1 http://localhost:8090/restream.wav
>
> Unrelated:
> You are not sending valid wav files like this.
>
> [...]
>
> > Can we solve this by making changes to FFMPEG to return 206?
>
> If I understand your request correctly, you are not asking for a
> change of a return type (you could probably do that yourself)
> but for the implementation of byte range requests.
> I don't think this is possible at all with FFmpeg.
>
> Carl Eugen
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".