media assets: save more metadata for videos.
Include the following metadata tags for videos: * FFmpeg:MajorBrand (e.g. mp42) * FFmpeg:PixFmt (e.g. yuv420p. Indicates bit depth and color subsampling mode) * FFmpeg:FrameCount (e.g. total number of frames in the video) * FFmpeg:VideoCodec (e.g. h264) * FFmpeg:VideoProfile (e.g. Main) * FFmpeg:AudioCodec (e.g. AAC) * FFmpeg:AudioProfile (e.g. LC) * FFmpeg:AudioLayout (e.g. stereo) * FFmpeg:AudioBitRate (e.g. 128kb/s)
This commit is contained in:
@@ -83,6 +83,10 @@ class FFmpeg
|
|||||||
frame_count / duration
|
frame_count / duration
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def major_brand
|
||||||
|
metadata.dig(:format, :tags, :major_brand)
|
||||||
|
end
|
||||||
|
|
||||||
def pix_fmt
|
def pix_fmt
|
||||||
video_stream[:pix_fmt]
|
video_stream[:pix_fmt]
|
||||||
end
|
end
|
||||||
@@ -99,6 +103,14 @@ class FFmpeg
|
|||||||
metadata[:streams].to_a.select { |stream| stream[:codec_type] == "video" }
|
metadata[:streams].to_a.select { |stream| stream[:codec_type] == "video" }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def audio_codec
|
||||||
|
audio_stream[:codec_name]
|
||||||
|
end
|
||||||
|
|
||||||
|
def audio_stream
|
||||||
|
audio_streams.first || {}
|
||||||
|
end
|
||||||
|
|
||||||
def audio_streams
|
def audio_streams
|
||||||
metadata[:streams].to_a.select { |stream| stream[:codec_type] == "audio" }
|
metadata[:streams].to_a.select { |stream| stream[:codec_type] == "audio" }
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#
|
#
|
||||||
# @see https://github.com/streamio/streamio-ffmpeg
|
# @see https://github.com/streamio/streamio-ffmpeg
|
||||||
class MediaFile::Video < MediaFile
|
class MediaFile::Video < MediaFile
|
||||||
delegate :duration, :frame_count, :frame_rate, :has_audio?, :is_corrupt?, :pix_fmt, :video_codec, :video_stream, :video_streams, :audio_streams, :error, to: :video
|
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
|
||||||
|
|
||||||
def dimensions
|
def dimensions
|
||||||
[video.width, video.height]
|
[video.width, video.height]
|
||||||
@@ -16,7 +16,18 @@ class MediaFile::Video < MediaFile
|
|||||||
end
|
end
|
||||||
|
|
||||||
def metadata
|
def metadata
|
||||||
super.merge({ "FFmpeg:Error" => error }.compact_blank)
|
super.merge({
|
||||||
|
"FFmpeg:Error" => error,
|
||||||
|
"FFmpeg:MajorBrand" => major_brand,
|
||||||
|
"FFmpeg:PixFmt" => pix_fmt,
|
||||||
|
"FFmpeg:FrameCount" => frame_count,
|
||||||
|
"FFmpeg:VideoCodec" => video_codec,
|
||||||
|
"FFmpeg:VideoProfile" => video_stream[:profile],
|
||||||
|
"FFmpeg:AudioCodec" => audio_codec,
|
||||||
|
"FFmpeg:AudioProfile" => audio_stream[:profile],
|
||||||
|
"FFmpeg:AudioLayout" => audio_stream[:channel_layout],
|
||||||
|
"FFmpeg:AudioBitRate" => audio_stream[:bit_rate],
|
||||||
|
}.compact_blank)
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_supported?
|
def is_supported?
|
||||||
|
|||||||
Reference in New Issue
Block a user