Create complete mediainfo/keyframe migration

This commit is contained in:
Zoe Roux 2024-07-15 22:01:46 +07:00
parent 5854c731a3
commit 9f7607cb87
2 changed files with 63 additions and 6 deletions

View File

@ -1,18 +1,72 @@
begin;
create table if not exists info(
create table info(
sha varchar(20) not null primary key,
path varchar(4096) not null unique,
extension varchar(256),
extension varchar(16),
mime_codec varchar(1024),
size bigint not null,
duration real not null,
container varchar(256)
container varchar(256),
fonts text[],
ver_ffprobe integer,
ver_extract integer,
ver_thumbs integer,
ver_keyframes integer
);
create table if not exists videos(
sha varchar(20) not null primary key,
create table videos(
sha varchar(20) not null references info(sha) on delete cascade,
idx integer not null,
title varchar(1024),
language varchar(256),
codec varchar(256) not null,
mime_codec varchar(256),
width integer not null,
height integer not null,
bitrate integer not null,
)
keyframes double precision[],
constraint videos_pk primary key (sha, idx)
);
create table audios(
sha varchar(20) not null references info(sha) on delete cascade,
idx integer not null,
title varchar(1024),
language varchar(256),
codec varchar(256) not null,
mime_codec varchar(256),
is_default boolean not null,
keyframes double precision[],
constraint audios_pk primary key (sha, idx)
);
create table subtitles(
sha varchar(20) not null references info(sha) on delete cascade,
-- Can be null when is_external is true
idx integer,
title varchar(1024),
language varchar(256),
codec varchar(256) not null,
extension varchar(16),
is_defaut boolean not null,
is_forced boolean not null,
is_external boolean not null,
path varchar(4096)
);
create type chapter_type as enum('content', 'recap', 'intro', 'credits');
create table chapters(
sha varchar(20) not null references info(sha) on delete cascade,
start_time real not null,
end_time real not null,
name varchar(1024),
type chapter_type
);
commit;

View File

@ -54,6 +54,8 @@ type Video struct {
Codec string `json:"codec"`
/// The codec of this stream (defined as the RFC 6381).
MimeCodec *string `json:"mimeCodec"`
/// The title of the stream.
Title *string `json:"title"`
/// The language of this stream (as a ISO-639-2 language code)
Language *string `json:"language"`
/// The max quality of this video track.
@ -268,6 +270,7 @@ func getInfo(path string) (*MediaInfo, error) {
return Video{
Codec: stream.CodecName,
MimeCodec: GetMimeCodec(stream),
Title: OrNull(stream.Tags.Title),
Language: NullIfUnd(lang.String()),
Quality: QualityFromHeight(uint32(stream.Height)),
Width: uint32(stream.Width),