Mp3 fragments on s3

I need a solution to play the mp3 segment. I have several 1000 audio files that are currently stored on Amazon S3 and would like users to be able to play them, however I would like to limit the playback length to 30 seconds or so in the middle of the recording.

I am not sure that I need to create a completely new file (fragment), for example, for a thumbnail, if it were an image, or if possible, using any player / pair to safely limit it so that they cannot access the whole song.

I come from a Rails environment and use Paperclip to process files and JPlayer to play them, if that matters.

Any pointers or best practices?

+3
source share
4 answers

This is possible using the HTTP header Content-range. This heading says, "Please just give me the bytes here and ignore the rest." If the web server is configured to handle them (for example, Apache), you will receive a 206 response with the body of only these bytes.

You must create a small proxy application that effectively acts as a gateway between the listener and Amazon.

To find out if your host will respond, try this from the command line:

curl -v -I http://www.mfiles.co.uk/mp3-downloads/01-Tartaros%20of%20light.mp3

Where the url is one of yours. If you are lucky, you will see:

Accept-Ranges: bytes
Content-Length: 5284483

This means that the server accepts the Content-range header, and the total file length is 5,284,483 bytes.

:

curl -H'Range: bytes=0-1761494' http://www.mfiles.co.uk/mp3-downloads/01-Tartaros%20of%20light.mp3 > /tmp/test1.mp3

/tmp/test 1.mp3 .

- -. https://github.com/aniero/rack-streaming-proxy, , , , "Range: bytes = 0-1761494", . .

, , , URL- , . script, , .

, GET "/preview/12345" - "http://amazon.com/my_long_url" .

, Varnish , MP3 , Amazon .

+4

, - " mp3 , 30 ".

0

, .

?

, - ( ), JWPlayer ( ).

, , - .

URL- / rtmp- CloudFront .

0

- mp3 .

, :

  • 1. . , .
    • 2. . , .
      • 3. X : ,

, : (-); ( ).

0
source

Source: https://habr.com/ru/post/1778824/


All Articles