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

Transcode VBR mp3 files to CBR #1162

Merged
merged 3 commits into from
Dec 16, 2024
Merged

Transcode VBR mp3 files to CBR #1162

merged 3 commits into from
Dec 16, 2024

Conversation

cavis
Copy link
Member

@cavis cavis commented Dec 6, 2024

Fixes #1109.

Requires PRX/Porter#164.

When a VBR file is uploaded, transcode it to CBR by running it back through Porter/ffmpeg.

Can be a bit slow, but better than having a misleading segmenter wavform.

@cavis cavis self-assigned this Dec 6, 2024
@kookster
Copy link
Member

It does lead me to wonder if we should just always transcode, rather than back and forth validating and conditionally fixing

Copy link
Member

@kookster kookster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm - couple of small ideas

@@ -25,6 +25,7 @@ def result
scope :copy_image, -> { where(type: "Tasks::CopyImageTask") }
scope :bad_audio_duration, -> { where("result ~ '\"DurationDiscrepancy\":([5-9]\\d[1-9]|[6-9]\\d{2}|[1-9]\d{3})'") }
scope :bad_audio_bytes, -> { where("result ~ '\"UnidentifiedBytes\":[1-9]'") }
scope :bad_audio_vbr, -> { where("result ~ '\"VariableBitrate\":true'") }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw the porter change to add this, smart.

@@ -55,6 +56,10 @@ def bad_audio_bytes?
porter_callback_inspect.dig(:Audio, :UnidentifiedBytes).to_i > 0
end

def bad_audio_vbr?
!!porter_callback_inspect.dig(:Audio, :VariableBitrate)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, we indifferent access the callbacks? nice
+1 I'm a big fan of !! for bools

@@ -58,7 +58,7 @@ def update_media_resource

media_resource.save!

if media_resource.status_complete? && (bad_audio_duration? || bad_audio_bytes?)
if media_resource.status_complete? && (bad_audio_duration? || bad_audio_bytes? || bad_audio_vbr?)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the only place we use these 3 bad_audio_*? methods, maybe combine into a single check, now that there are 4 conditions chained here? Purely aesthetic, this is fine!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added!

@@ -81,6 +85,16 @@ def slice_media!
end
end

def next_highest_bitrate
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea

@cavis cavis merged commit 76a43ca into main Dec 16, 2024
3 checks passed
@cavis cavis deleted the fix/transcode_vbr branch December 16, 2024 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Detect and "fix" (transcode) VBR mp3s
2 participants