Skip to content

Commit

Permalink
streams
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikvedvik committed Sep 13, 2023
1 parent 770314c commit 8bb7ca1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 34 deletions.
58 changes: 25 additions & 33 deletions services/vidispine/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ type Clip struct {
}

type AudioFile struct {
VXID string
Channels []int
File string
VXID string
Streams []int
File string
}

type ExportData struct {
Expand Down Expand Up @@ -178,8 +178,8 @@ func getRelatedAudios(c *Client, clip *Clip, languagesToExport []string) (*Clip,
// If nor (floor language) is missing we fall back to silece
if lang == "nor" {
clip.AudioFiles[lang] = &AudioFile{
Channels: []int{1, 2},
File: EmptyWAVFile,
Streams: []int{0},
File: EmptyWAVFile,
}
} else if languagesToExport[0] == "nor" {
// Fall back to "nor" audio and issue a warning *somewhere*
Expand All @@ -205,22 +205,19 @@ func getRelatedAudios(c *Client, clip *Clip, languagesToExport []string) (*Clip,
}
}

channels := []int{}
var streams []int

if len(relatedAudioShape.AudioComponent) > 0 {
for i := 0; i < relatedAudioShape.AudioComponent[0].ChannelCount; i++ {
channels = append(channels, i+1)
}
streams = append(streams, relatedAudioShape.AudioComponent[0].EssenceStreamID)
} else {
return clip, fmt.Errorf("no audio components found for item %s", relatedAudioVXID)
}

clip.AudioFiles[lang] = &AudioFile{
VXID: relatedAudioVXID,
File: relatedAudioShape.GetPath(),
Channels: channels,
VXID: relatedAudioVXID,
File: relatedAudioShape.GetPath(),
Streams: streams,
}

}

return clip, nil
Expand All @@ -233,55 +230,50 @@ func getEmbeddedAudio(c *Client, clip *Clip, languagesToExport []string) (*Clip,
}

shape := shapes.GetShape("original")
if len(shape.AudioComponent) != 16 && len(shape.AudioComponent) > 2 {
return clip, fmt.Errorf("Found %d audio components, expected 2 or 16", len(shape.AudioComponent))
if len(shape.AudioComponent) != 16 && len(shape.AudioComponent) > 1 {
return clip, fmt.Errorf("found %d audio components, expected 1 or 16", len(shape.AudioComponent))
}

if len(shape.AudioComponent) == 0 {
// We have no audio, so we fall back to silence
channels := []int{1, 2}
streams := []int{0}
for _, lang := range languagesToExport {
clip.AudioFiles[lang] = &AudioFile{
File: EmptyWAVFile,
Channels: channels,
File: EmptyWAVFile,
Streams: streams,
}
}

return clip, nil
}

if shape.AudioComponent[0].ChannelCount <= 2 {
if len(shape.AudioComponent) == 1 {
// We have stereo or mono audio, so we copy it to all languages

channels := []int{}
for i := 1; i <= shape.AudioComponent[0].ChannelCount; i++ {
channels = append(channels, i)
}

for _, lang := range languagesToExport {
clip.AudioFiles[lang] = &AudioFile{
VXID: clip.VXID,
File: shape.GetPath(),
Channels: channels,
VXID: clip.VXID,
File: shape.GetPath(),
Streams: []int{shape.AudioComponent[0].EssenceStreamID},
}
}

return clip, nil
}

for _, lang := range languagesToExport {
// We have an actual 16 channel audio file, so we need to figure out which channels to use
// and assign them to the correct language

if l, ok := bccmflows.LanguagesByISO[lang]; ok {
channels := []int{}
var streams []int
for i := 0; i < l.MU1ChannelCount; i++ {
channels = append(channels, l.MU1ChannelStart+i)
streams = append(streams, l.MU1ChannelStart+i)
}

clip.AudioFiles[lang] = &AudioFile{
VXID: clip.VXID,
File: clip.VideoFile,
Channels: channels,
VXID: clip.VXID,
File: clip.VideoFile,
Streams: streams,
}
} else {
return clip, errors.New("No language " + lang + " found in bccmflows.LanguagesByISO")
Expand Down
2 changes: 1 addition & 1 deletion workflows/asset_export-vx.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func exportDataToMergeInputs(data *vidispine.ExportData, tempFolder, subtitlesFo
Path: af.File,
Start: clip.InSeconds,
End: clip.OutSeconds,
Streams: af.Channels,
Streams: af.Streams,
})
}

Expand Down

0 comments on commit 8bb7ca1

Please sign in to comment.