Episodes
David Kimura PRO said over 2 years ago on Adaptive Bitrate Streaming with Active Storage :
I did run into an issue recently where the quality selector no longer worked. I ended up having to do this.

import contribQualityLevels from 'videojs-contrib-quality-levels'

videojs.registerPlugin('qualityLevels', contribQualityLevels)


almokhtar said over 2 years ago on Adaptive Bitrate Streaming with Active Storage :
  i wanna prevent the user from downloading videos is this the way? 

David Kimura PRO said over 2 years ago on Adaptive Bitrate Streaming with Active Storage :
  this will add a layer of complexity as the video is divided into small segments, but the end user browser still gets an unencrypted stream. You cannot really prevent downloading since the end user will need to play the video. However, if you were to have the video segments encrypted on the server side and provide a key to the end user to have their browser decrypt the video, this would add a level of complexity that most would just assume that they cannot access the videos.

afogel said over 2 years ago on Adaptive Bitrate Streaming with Active Storage :
hey Dave,

This was an exceptional episode. I had a few questions/requests:
- I'm wondering whether you could provide a few more resources about what you researched in order to figure out how to work with FFMPEG and HLS. For example, how often and where might you look to keep tabs on new developments/make updates so that you keep up with high quality video serving?
- What are the tradeoffs that you've found to using mp4 over webm ? Since we have already broken out ffmpeg, should we add a step to transcode  to webm instead of mp4?
- I'm curious why did you choose to go with a bash script over writing an FFMPEG wrapper in ruby (or using an existing gem, like streamio-ffmpeg)?
- When you deploy this to production -- how do you monitor resource usage/failures?
- How might you write tests for an the `ConvertHls` class?
- How might you debug the bash script if you deploy to prod?

Thanks!

David Kimura PRO said over 2 years ago on Adaptive Bitrate Streaming with Active Storage :
  
- I'm wondering whether you could provide a few more resources about what you researched in order to figure out how to work with FFMPEG and HLS. For example, how often and where might you look to keep tabs on new developments/make updates so that you keep up with high quality video serving?

Honestly, I forget the resources that I came across while researching this episode. It was several weeks of research to get to this final product. However, the github pages for the videojs and https://github.com/videojs/http-streaming are good resources



- What are the tradeoffs that you've found to using mp4 over webm ? Since we have already broken out ffmpeg, should we add a step to transcode  to webm instead of mp4?

The web now-a-days works pretty good using MP4. So far, I've not seen any issues on the browsers and devices that i've tested on.

- I'm curious why did you choose to go with a bash script over writing an FFMPEG wrapper in ruby (or using an existing gem, like streamio-ffmpeg)?

I didn't want to add an additional dependency to my application. The bash script is complicated, but easy enough to debug locally.

- When you deploy this to production -- how do you monitor resource usage/failures?

I run the conversion in a background job. The background job handles retrying as well as notifications. As far as resources go, and since these are happening in a background job, I would rely on the infrastructure to handle notifications of peaks and autoscaling.

- How might you write tests for an the `ConvertHls` class?

I would probably include a tiny video file within my repo and use that as my test case. As edge cases arise, perhaps with other formats, those could be added as well. I would try to keep each video file <= 1MB (or have them externally available).

- How might you debug the bash script if you deploy to prod?

So far, I've not had to worry about this. Everything has been working fairly well. It is actually what I'm using on Drifting Ruby right now. However, if I did have to debug a production issue, I would probably pull down the video file in question and test it locally. 

afogel said over 2 years ago on Adaptive Bitrate Streaming with Active Storage :
when we download in the stream controller, does that remain on the server or does rails clear the cache later (or something else)?

David Kimura PRO said over 2 years ago on Adaptive Bitrate Streaming with Active Storage :
  In this example, it is persisting the data into memory for the life of the request. If there are a bunch of concurrent streams, then this could be problematic. However, on the 2GB RAM servers that I'm running Drifting Ruby on, I haven't seen it become a real issue yet.

afogel said over 2 years ago on Adaptive Bitrate Streaming with Active Storage :
 Thanks!  My current cluster is running 2 servers @ 4GB RAM each, so should be fine for the small amount of traffic that I have. I think what I'll want to know is how I can monitor so I know when I need to scale further.


ye-lin-aung said almost 2 years ago on Adaptive Bitrate Streaming with Active Storage :
How can we track the progress of ffmpeg encoding ? 

David Kimura PRO said almost 2 years ago on Adaptive Bitrate Streaming with Active Storage :
  ooo that could be tricky. You could do an in app or email notification whenever it finishes. On this site, I have a slack notification which lets me know when it's finished. You may look into something like this https://superuser.com/a/1460400/86978 and then implement it with a progress bar ui like in this episode https://www.driftingruby.com/episodes/realtime-client-updates-from-background-jobs-with-stimulus


Wong You Jing said over 1 year ago on Adaptive Bitrate Streaming with Active Storage :
I'm unfamiliar with the bin code, but even copy pasting it directly gives me an error. 

It seems that aac is a built in default, and im on ffmpeg v4

[NULL @ 0x7f8c74813200] Unable to find a suitable output format for 'aac'
aac: Invalid argument

Just wondering if anyone has encountered the same, as my googling skills have failed me.

David Kimura PRO said over 1 year ago on Adaptive Bitrate Streaming with Active Storage :
  It's likely some kind of issue with improper codecs or something. I do use handbrake on all of my videos before I upload them. I use the Web 1080p conversion. I don't know what that translates to on ffmpeg, but you might need to do some kind of transcoding before creating the variants. 

Ratnakar said 7 months ago on Adaptive Bitrate Streaming with Active Storage :
I have the same issue Unable to find a suitable output format for 'aac' aac: Invalid argument 

Any solution on this error ?

David Kimura PRO said 7 months ago on Adaptive Bitrate Streaming with Active Storage :
Where are you receiving this error? All of the videos I use are using the H.264 video codec along with AAC Audio codec. If you're getting this error when transcoding the video, what version of ffmpeg do you have? I have a few different versions that are running on various machines that have done the transcoding.

ffmpeg version 4.2.4
ffmpeg version 5.0-static

Ratnakar said 7 months ago on Adaptive Bitrate Streaming with Active Storage :
Mine is ffmpeg version 5.0 and I am running it on mac M1

Its when transcoding the file, I guess its with this line -c:a aac

ffmpeg -hide_banner -y -i tmp/videos/$1.mp4 \-hls_base_url "$2/users/" \-threads 1\-c:a aac -ar 48000 -c:v h264 -profile:v main -crf 20 -sc_threshold 0 -hls_time 4 -hls_playlist_type vod -vf scale=w=640:h=360:force_original_aspect_ratio=decrease \-b:v 800k -maxrate 700000 -bufsize 700000 -b:a 96k \-hls_segment_filename tmp/videos/$1/$1_360p_%03d.ts \tmp/videos/$1/$1_360p.m3u8 \



Ratnakar said 7 months ago on Adaptive Bitrate Streaming with Active Storage :
And how to minimize segment size, right now its nearly 12mb which makes my server very slow on returning response. all I want to make segments to be very smaller in size (in kb) what is the way ?

David Kimura PRO said 7 months ago on Adaptive Bitrate Streaming with Active Storage :
That's going to greatly depend on the encoding quality. Check out Handbrake to see some of the settings and determine what is acceptable encoding quality. You can also look at the command running in the terminal (with top or htop) to get the ffmpeg settings used.

I don't think that I've tried using the M1 directly to do the encoding. I've always tested within a docker container since that's where I do most of my development.

Ratnakar said 7 months ago on Adaptive Bitrate Streaming with Active Storage :
I fixed the bug, there is typo in the code 

-threads 1\

it needs a space before new line char

-threads 1 \


Please correct it in your code sample

Login to Comment