Archive for the ‘Ruby’ Category

Scripting: Python or Ruby? (& iOS Apps for Text/Script Editing)

Wednesday, January 23rd, 2013

I recently came across a handy script for recording streams.  It was in the scripting language python.  So I went to obtain it.  So far no problem.

But that got me thinking: I’d read somewhere a long time ago of python, or was it ruby (on rails or otherwise), being used to support broadcast or film digital production workflows. So first I wanted to confirm that, through web-search.  Then second I wanted to compare the languages, to see which one I felt best about.

Google:[python ruby workflow video production adobe avid]

    • This is a really good article, I can see that for me, python is the obvious choice – more readable to me.  Furthermore:
      • Ruby’s greatest strength is its amazing flexibility. There is a lot of “magic” in ruby and sometimes it is dark magic. Python intentionally has minimal magic. It’s greatest strengths are the best practices it enforces across its community. These practices make Python very readable across different projects; they ensure high quality documentation; they make the standard library kick ass.
      • (For a particulat given simple example, <<The python example is far more readable and maintainable. >>
    • On the other hand (in favour of ruby):
      • If ruby reminds of perl, your eyes do not deceive you. In many ways it is the love child of perl and smalltalk.
        • In the past have had a very good experience of using smalltalk
      • every large program should have its own internal DSL suited to the problem space … it seems much easier to create DSL’s (Domain Specific Languages). Ruby certainly spawns DSLs with much greater frequency than python. No single pythonic build tool dominates the problem space like rake does in the ruby community. Most python projects seems to use for administrative tasks even though that is not its explicit purpose.
    • Lists Implementations, Development Environments, Applications etc.
    • DIY BROADCAST: How to build your own TV Channel with Open Source & other goodies
    • Loads of great links eg for screenwriting (Celtx), multicam recording (Ingex Studio), editing (EditShare LightWorks), archive (BackBlaze) and playout (OpenPlayout, MLT).  Also 3D modelling (Blender), color correction (DaVinci Resolve Lite), Live Graphics (CasparCG), Digital Asset Management (EnterMedia).  And more … but you get the drift…
    • Example scripting and, serendipitously, some recommended iOS (iPhone/iPad) apps for note-taking and html script production, namely Nebulous Notes and TextExpander (which can work together).

rvideo: Ruby video transcoding library

Sunday, January 8th, 2012


    • <<Ruby is…A dynamic, open source programming language with a focus on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write.>>
    • Ruby is also totally free. Not only free of charge, but also free to use, copy, modify, and distribute.
    • My MacBook has a copy of it, at [/usr/bin/ruby].  No idea if it came with Mac OS or an application, but it’s there.
    • rvideo
      • Ruby video transcoding library
      • RVideo is a Ruby library inspects and processes video and audio files by providing an interface to free Unix tools like ffmpeg.
    • Demonstration of usage
      • A few examples:
        • file = => “#{APP_ROOT}/files/input.mp4”)
        • file = => @existing_response)
        • file = => “#{APP_ROOT}/files/input.mp4”,
        •   :ffmpeg_binary => “#{APP_ROOT}/bin/ffmpeg”)
        • file.fps        # => “29.97”
        • file.duration   # => “00:05:23.4”
    • To transcode a video, initialize a Transcoder object.
      • transcoder =
    • Then pass a command and valid options to the execute method.
      • recipe = “ffmpeg -i $input_file$ -ar 22050 -ab 64 -f flv -r 29.97 -s”
      • recipe += ” $resolution$ -y $output_file$”
      • recipe += “\nflvtool2 -U $output_file$”
      • begin
      •   transcoder.execute(recipe, {:input_file => “/path/to/input.mp4”,
      •     :output_file => “/path/to/output.flv”, :resolution => “640×360”})
      •   rescue TranscoderError => e
      •   puts “Unable to transcode file: #{e.class} – #{e.message}”
      • end
    • If the job succeeds, you can access the metadata of the input and output files with:
      • transcoder.original     # RVideo::Inspector object
      • transcoder.processed    # RVideo::Inspector object
    • Even if the file is processed, it may still have problems. RVideo will populate an errors array if the duration of the processed video differs from the duration of the original video, or if the processed file is unreadable.