Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid exception on audio_channels method #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/rvideo/inspector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -393,14 +393,15 @@ def audio_channels_string

def audio_channels
return nil unless audio?
return audio_match[5].to_i if (audio_match[5].to_i > 0)

case audio_match[5]
when "mono"
1
when "stereo"
2
else
raise RuntimeError, "Unknown number of channels: #{audio_channels}"
raise RuntimeError, "Unknown number of channels: #{audio_match[5]}"
end
end

Expand Down Expand Up @@ -523,7 +524,7 @@ def bitrate_match
def audio_match
return nil unless valid?

/Stream\s*(.*?)[,|:|\(|\[].*?\s*Audio:\s*(.*?),\s*([0-9\.]*) (\w*),\s*([a-zA-Z:]*)/.match(audio_stream)
/Stream\s*(.*?)[,|:|\(|\[].*?\s*Audio:\s*(.*?),\s*([0-9\.]*) (\w*),\s*([(\d)*a-zA-Z:]*)/.match(audio_stream)
end

def video_match
Expand All @@ -542,4 +543,4 @@ def video_match
match
end
end
end
end