media assets: fix .webm files not including video/audio bit rates in metadata.
Fix .webm files not including the `FFmpeg:VideoBitRate` and `FFmpeg:AudioBitRate`
fields in the media_metadata table. This was because the .webm format
doesn't include the video or audio bit rates in the metadata, and
ffprobe doesn't calculate them either, so we have to calculate them
ourselves by hand.
Fixup for 523d7afdd.
This commit is contained in:
@@ -132,7 +132,7 @@ class MediaFile::Image < MediaFile
|
||||
|
||||
def preview_frame
|
||||
if is_animated?
|
||||
FFmpeg.new(file).smart_video_preview
|
||||
FFmpeg.new(self).smart_video_preview
|
||||
else
|
||||
self
|
||||
end
|
||||
@@ -172,7 +172,7 @@ class MediaFile::Image < MediaFile
|
||||
end
|
||||
|
||||
def video
|
||||
FFmpeg.new(file)
|
||||
FFmpeg.new(self)
|
||||
end
|
||||
|
||||
memoize :image, :video, :preview_frame, :dimensions, :error, :metadata, :is_corrupt?, :is_animated_gif?, :is_animated_png?
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#
|
||||
# @see https://github.com/streamio/streamio-ffmpeg
|
||||
class MediaFile::Video < MediaFile
|
||||
delegate :duration, :frame_count, :frame_rate, :has_audio?, :is_corrupt?, :major_brand, :pix_fmt, :video_codec, :video_stream, :video_streams, :audio_codec, :audio_stream, :audio_streams, :error, to: :video
|
||||
delegate :duration, :frame_count, :frame_rate, :has_audio?, :is_corrupt?, :major_brand, :pix_fmt, :video_codec, :video_bit_rate, :video_stream, :video_streams, :audio_codec, :audio_bit_rate, :audio_stream, :audio_streams, :error, to: :video
|
||||
|
||||
def dimensions
|
||||
[video.width, video.height]
|
||||
@@ -23,10 +23,11 @@ class MediaFile::Video < MediaFile
|
||||
"FFmpeg:FrameCount" => frame_count,
|
||||
"FFmpeg:VideoCodec" => video_codec,
|
||||
"FFmpeg:VideoProfile" => video_stream[:profile],
|
||||
"FFmpeg:VideoBitRate" => video_bit_rate,
|
||||
"FFmpeg:AudioCodec" => audio_codec,
|
||||
"FFmpeg:AudioProfile" => audio_stream[:profile],
|
||||
"FFmpeg:AudioLayout" => audio_stream[:channel_layout],
|
||||
"FFmpeg:AudioBitRate" => audio_stream[:bit_rate],
|
||||
"FFmpeg:AudioBitRate" => audio_bit_rate,
|
||||
}.compact_blank)
|
||||
end
|
||||
|
||||
@@ -53,7 +54,7 @@ class MediaFile::Video < MediaFile
|
||||
private
|
||||
|
||||
def video
|
||||
FFmpeg.new(file)
|
||||
FFmpeg.new(self)
|
||||
end
|
||||
|
||||
def preview_frame
|
||||
|
||||
Reference in New Issue
Block a user