Skip to content

Commit

Permalink
Support 7.1 (8) channels
Browse files Browse the repository at this point in the history
  • Loading branch information
deluan committed Sep 20, 2021
1 parent e12a14a commit 1365adb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion scanner/metadata/ffmpeg/ffmpeg.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ var (
durationRx = regexp.MustCompile(`^\s\sDuration: ([\d.:]+).*bitrate: (\d+)`)

// Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp, 192 kb/s
audioStreamRx = regexp.MustCompile(`^\s{2,4}Stream #\d+:\d+.*: (Audio): (.*), (.* Hz), (mono|stereo|5.1),*(.*.,)*(.(\d+).kb/s)*`)
audioStreamRx = regexp.MustCompile(`^\s{2,4}Stream #\d+:\d+.*: (Audio): (.*), (.* Hz), ([\w\.]+),*(.*.,)*(.(\d+).kb/s)*`)

// Stream #0:1: Video: mjpeg, yuvj444p(pc, bt470bg/unknown/unknown), 600x600 [SAR 1:1 DAR 1:1], 90k tbr, 90k tbn, 90k tbc`
coverRx = regexp.MustCompile(`^\s{2,4}Stream #\d+:\d+: (Video):.*`)
Expand Down Expand Up @@ -187,6 +187,8 @@ func (e *Parser) parseChannels(tag string) string {
return "2"
} else if tag == "5.1" {
return "6"
} else if tag == "7.1" {
return "8"
}

return "0"
Expand Down
9 changes: 9 additions & 0 deletions scanner/metadata/ffmpeg/ffmpeg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,15 @@ Input #0, mp3, from '/Users/deluan/Music/iTunes/iTunes Media/Music/Compilations/
Expect(md).To(HaveKeyWithValue("channels", []string{"2"}))
})

It("parse 7.1 channels from the stream", func() {
const output = `
Input #0, wav, from '/Users/deluan/Music/Music/Media/_/multichannel/Nums_7dot1_24_48000.wav':
Duration: 00:00:09.05, bitrate: 9216 kb/s
Stream #0:0: Audio: pcm_s24le ([1][0][0][0] / 0x0001), 48000 Hz, 7.1, s32 (24 bit), 9216 kb/s`
md, _ := e.extractMetadata("tests/fixtures/test.mp3", output)
Expect(md).To(HaveKeyWithValue("channels", []string{"8"}))
})

It("parse channels from the stream without bitrate", func() {
const output = `
Input #0, flac, from '/Users/deluan/Music/iTunes/iTunes Media/Music/Compilations/Putumayo Presents Blues Lounge/09 Pablo's Blues.flac':
Expand Down

0 comments on commit 1365adb

Please sign in to comment.