lisamelton / other_video_transcoding

Other tools to transcode videos.
MIT License
543 stars 24 forks source link

Error passing brackets to the --x265-params option #119

Closed martinpickett closed 2 years ago

martinpickett commented 2 years ago

If you pass a KEY:VALUE pair with --x265-params where the VALUE contains brackets, other-transcode throws an error "/usr/local/lib/ruby/gems/3.0.0/bin/other-transcode: invalid argument:".

Luckily the fix seems simple, inserting just four characters to line 846 solves my problem. The offending line checks the validity of KEY:VALUE pairs with a regular expression, changing the expression slightly to allow brackets is all that is required. What I did, with a bit of context, is as follows.

Current:

opts.on '--x265-params ARG' do |arg|
    arg.split ':' do |param|
        fail UsageError, "invalid argument: #{arg}" unless param =~ /^[\w\-]+=[\w\-\.,]+$/
    end

New:

opts.on '--x265-params ARG' do |arg|
    arg.split ':' do |param|
        fail UsageError, "invalid argument: #{arg}" unless param =~ /^[\w\-]+=[\w\-\(\)\.,]+$/
    end

The four magical characters are \(\) inserted into the second half of the regular expression.

I am sure there are other ways to fix this issue so please do what you like, but without brackets, no one can do HDR10 encoding with other-transcode.

lisamelton commented 2 years ago

@martinpickett Thanks for opening this! And finding and fixing the bug. :)

lisamelton commented 2 years ago

The fix (slightly different) is checked in now.

martinpickett commented 2 years ago

Thanks. I have checked out the change and it is working for me on my Mac.