Add channels to audio info

This commit is contained in:
Zoe Roux 2026-04-02 15:18:22 +02:00
parent 2f2fdfc13c
commit d868ad9e61
No known key found for this signature in database
5 changed files with 19 additions and 5 deletions

View File

@ -0,0 +1,5 @@
begin;
alter table gocoder.audios drop column channels;
commit;

View File

@ -0,0 +1,5 @@
begin;
alter table gocoder.audios add column channels int not null default 2;
commit;

View File

@ -100,11 +100,11 @@ func GetMimeCodec(stream *ffprobe.Stream) *string {
return &ret
case "ac3":
ret := "mp4a.a5"
ret := "ac-3"
return &ret
case "eac3":
ret := "mp4a.a6"
ret := "ec-3"
return &ret
case "flac":

View File

@ -17,7 +17,7 @@ import (
"gopkg.in/vansante/go-ffprobe.v2"
)
const InfoVersion = 3
const InfoVersion = 4
type Versions struct {
Info int32 `json:"info" db:"ver_info"`
@ -98,6 +98,8 @@ type Audio struct {
Codec string `json:"codec" db:"codec"`
/// The codec of this stream (defined as the RFC 6381).
MimeCodec *string `json:"mimeCodec" db:"mime_codec"`
/// The number of channels that stream has.
Channels int `json:"channels" db:"channels"`
/// The average bitrate of the audio in bytes/s
Bitrate uint32 `json:"bitrate" db:"bitrate"`
/// Is this stream the default one of it's type?
@ -280,6 +282,7 @@ func RetriveMediaInfo(path string, sha string) (*MediaInfo, error) {
Language: NullIfUnd(lang.String()),
Codec: stream.CodecName,
MimeCodec: GetMimeCodec(stream),
Channels: stream.Channels,
Bitrate: ParseUint(cmp.Or(stream.BitRate, mi.Format.BitRate)),
IsDefault: stream.Disposition.Default != 0,
}

View File

@ -319,7 +319,7 @@ func (s *MetadataService) storeFreshMetadata(ctx context.Context, path string, s
ctx,
`
insert into gocoder.audios(sha, idx, title, language, codec, mime_codec, is_default, bitrate)
values ($1, $2, $3, $4, $5, $6, $7, $8)
values ($1, $2, $3, $4, $5, $6, $7, $8, $9)
on conflict (sha, idx) do update set
sha = excluded.sha,
idx = excluded.idx,
@ -327,10 +327,11 @@ func (s *MetadataService) storeFreshMetadata(ctx context.Context, path string, s
language = excluded.language,
codec = excluded.codec,
mime_codec = excluded.mime_codec,
channels = excluded.channels,
is_default = excluded.is_default,
bitrate = excluded.bitrate
`,
ret.Sha, a.Index, a.Title, a.Language, a.Codec, a.MimeCodec, a.IsDefault, a.Bitrate,
ret.Sha, a.Index, a.Title, a.Language, a.Codec, a.MimeCodec, a.Channels, a.IsDefault, a.Bitrate,
)
}
for _, s := range ret.Subtitles {