Pre-order

Phlex on Rails: Week Seven Update

One unit complete, six more to go, and the end of summer

Last week I nerd sniped myself into figuring out how to stream videos from a private S3 bucket. This week I laid down an entire video unit and am ending the summer, in the sense that I’m no longer chauffeuring my children to and from summer camps.

Course content updates

I finished my first unit, component fundamentals.

Screenshot of the first completed video unit

Component fundamentals

The Component fundamentals unit has been recorded, edited, encoded, and uploaded! This is what the rest of the videos will be like in terms of quality, content, and length.

One revelation I had shooting this course is that a vanilla Phlex component can render itself via VanillaComponent.new.call. This is why I preach that Phlex is actually more boring and vanilla than Erb to the “Boring/Vanilla” Rails crowd. For those of you who are less dogmatic, that means it will always be pretty straightforward integrating Phlex into Rails upgrades because of its MIT license and brilliant architecture. Thank Joel Drapper for his amazing work creating Phlex!

Getting started

This was actually the first video unit I recorded. There are still a few edits I need to make to some of the videos, but I uploaded what I have for now because it’s useful, informative, and I want people to start learning now.

Video workflow is improving

Despite having made a lot of progress in my video production workflow, I’m still working out a lot of tooling and editing issues. One thing I learned this week with the HLS gem I’m putting together is to not depend on ffmpeg to max out all the cores on your machine if you use a “video complex”, which is a fancy way of saying ffmpeg should encode the 1K, 2K, and 4K streams.

ffmpeg does not soak up all the cores

I built a nifty little process-based worker queue that I’ll talk about in a future code post that will soak up all my CPU cores for video encoding.

# A process-based worker queue
HLS::Jobs.process do |jobs|
  directory = HLS::Directory.new(source).glob("**/*.mp4")
  puts "Processing #{directory.count} files from #{source}"
  directory.each do |input, path|
    output = destination.join(path)
    FileUtils.mkdir_p(output)

    puts "Processing #{input.path} to #{output}"

    package = HLS::Video::Scalable.new(input:, output:)
    jobs.render package

    poster = HLS::Poster.new(input:, output:)
    jobs.render poster

    puts "Completed #{input.path} to #{output}"
  end
end

Course source code cleanup continues

I’m still working on cleaning up the Thingybase.com Rails source code base for this lesson. Thingybase is a home inventory system I built in 2017 to create labels for all my stuff. For purposes of this course, I’m using it because it’s a somewhat large Rails app that’s an accurate approximation of apps people are running that are thinking about incorporating Phlex.

Converted .slim templates to .erb

Nothing says true love like converting a bunch of old .slim templates to .erb. I did this because most of the people interested in Phlex are coming in from existing Rails projects with lots of .erb templates. I also did it because the slim-rails gem didn’t play nice with the sitepress-rails gem. I think most will agree that removing this is a win-win.

Actually I didn’t do it, Claude 4 did it with Zed in about 20 minutes and only screwed up one file out of 130. I was impressed with how well it performed such a mundane task.

Removed webpacker

Since Claude 4 did such an amazing job converting all these slim templates to erb, I decided to remove webpacker from the project. Did it do a good job? Yup. I highly recommend checking out Claude 4 if you have extremely boring maintenance & cleanup work.

Last week off for the summer

Since the kids start school next week, I’m going to spend most of my time with them, which means no new videos this week! That also means when they start school, I’ll have way more time to focus on cranking out these videos at a more expeditious pace.

Support this website for more original articles

If you enjoyed reading this article and want to use Plex with Rails, consider purchasing the Phlex on Rails video course.

Order the Phlex on Rails video course for $379 $289