David Kimura PRO
Joined 7/18/2015
Drifting Ruby Owner
Ruby Rogues Panelist
David Kimura PRO said over 4 years ago on Tracking Changes on Action Text :
  I would actually prefer a separate controller. When I first started out development, I would have several compromises with my controllers. First they were fat controllers, then they had various actions outside of the standards and so on. These all seemed fine until I had to go back and work on these older applications and these kinds of patterns were a pain to go back and work in. So, I would actually have a different controller and in this particular case, I would not have it dependent on articles. I would have probably do something like

resources :versions, only: [] do
  resource :restore
end

The reason why I would prefer leaving the article out of it is that the polymorphic association in the Version table already knows who the item belongs to. So, we can look up that item and do the necessary checks. I also like this way because then we can write it one time, and not have to worry about all of the different Action Text attributes used by other models; this solution would work for all of them.

David Kimura PRO said over 4 years ago on Tracking Changes on Action Text :
  You should be able to have a controller action with the content

version = Version.includes(:item).find(params[:id])
itemable = version.item
itemable.content = version.content
itemable.save

It should take the content of the version and set it to the related content. This of course would then create a new version based on this version.

David Kimura PRO said over 4 years ago on Tracking Changes on Action Text :
  You can do that with something existing like paper_trail. Or for other attributes, you could role your own solution as a concern; similar to what we did in this episode. https://www.driftingruby.com/episodes/auditing-with-paper-trail


David Kimura PRO said over 4 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. 

David Kimura PRO said over 4 years ago on Video Chat with WebRTC :
  Here's how I created the coturn server. Using an Ubuntu 18.04LTS virtual machine.

apt-get update && apt-get install -y coturn && apt-get clean

Edit the environment file to set some environment variables. Be sure to change as necessary.

# vi /etc/environment
TURN_PORT=3478
TURN_PORT_START=10000
TURN_PORT_END=20000
TURN_SECRET=yoursecretkey
TURN_SERVER_NAME=turn
TURN_REALM=YOURDOMAINNAME

Run source to set the variables

source /etc/environment

Edit the coturn file

sudo vi /etc/default/coturn

And change the value to 1

TURNSERVER_ENABLED=1

Generate an encrypted password. Be sure to use the same TURN_REALM name as set in the /etc/environment

turnadmin -k -u USERNAME -r YOURDOMAINNAME -p PASSWORD

Edit the turnserver configuration file

sudo vi /etc/turnserver.conf

Add the user into the configuration file. The encrypted password would be something like 0x0000000

user=USERNAME:PASSWORD

Restart coturn

sudo service coturn restart

Also, depending on where this is being hosted. You will need to open the UDP ports on your firewall based on the configuration set in /etc/environment. So, the password that you set will be encrypted on the server, but will need to be entered as plain text within the javascript stimulus controller.