Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

start and end time #12

Closed
loretoparisi opened this issue Nov 9, 2018 · 3 comments
Closed

start and end time #12

loretoparisi opened this issue Nov 9, 2018 · 3 comments

Comments

@loretoparisi
Copy link

loretoparisi commented Nov 9, 2018

Assumed that as you suggests that media server can stream from a specific frame position as for here #6
it's not clear to me how to handle this on the client side. I mean I have start and end times in seconds. Of course I have the mp3 file info from ffprobe so I should calcolate by my self the frames and cut the audio file before then passing it to the mediaserver?
In that case it's just a cut with ffmpeg but it would prefer to do this in streaming without cutting the file.

Since you are using the method getRange like

var range = getRange(req, total);

I assume I could send you a req.headers.range to support this, right? If so could you make an example of the range, it seems it's like a bytes range separated with a -, so it's to me like

setHeader('range:'+ start_bytes+'-'+end_bytes)

Thank you.

@loretoparisi
Copy link
Author

loretoparisi commented Nov 9, 2018

So I get these info with ffprobe like

ffprobe -i /root/audio/12380187.mp3 -show_frames -show_entries frame=pkt_pos -of default=noprint_wrappers=1:nokey=1 -hide_banner -loglevel panic -read_intervals 20%+#1
480279

where 20 is my start position in seconds that turns out to be 480279 in bytes.
In this way I have passed the header like bytes=120515-240260 and I get a range array of

[ 120515, 240260, 4724126 ]

where the last bytes is of course the file length. Having this settings I have these headers:

{
 "Content-Length": 4724126,
  "Content-Type": "audio/mpeg",
  "Access-Control-Allow-Origin": "*",
  "Access-Control-Allow-Methods": "POST, GET, OPTIONS",
  "Access-Control-Allow-Headers": "POST, GET, OPTIONS",
  "Accept-Ranges": "bytes",
  "Content-Range": "bytes 120515-240260/4724126"
}

Problem is that it does not work then i.e. it does not stream any contents so what is wrong here?

@loretoparisi
Copy link
Author

[UPDATE]
I think this maybe due to a severe issue on Google's Chrome so I have asked to SF in Content-Range working in Safari but not in Chrome and in Streaming audio in Node.js with Content-Range.

My latest attempt was using the suggested Access-Control-Allow-Headers header set to Range

{ 'Content-Length': 5751405,
  'Content-Type': 'audio/mpeg',
  'Access-Control-Allow-Origin': '*',
  'Access-Control-Allow-Methods': 'POST, GET, OPTIONS',
  'Access-Control-Allow-Headers': 'Range',
  Expires: 0,
  Pragma: 'no-cache',
  'Cache-Control': 'no-cache, no-store, must-revalidate',
  'Accept-Ranges': 'bytes',
  'Content-Range': 'bytes 120429-240237/5751405' }

as referred in mozilla/pdf.js#3150 and in mozilla/pdf.js#4530 (comment)

@obastemur
Copy link
Owner

Thanks for the update. Closing it for now then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants