Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore parametric stereo probing error on output files #529

Merged
merged 1 commit into from
Mar 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pipeline/coordinator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ type stubFFprobe struct {
Err error
}

func (f stubFFprobe) ProbeFile(_ string) (video.InputVideo, error) {
func (f stubFFprobe) ProbeFile(_ string, _ ...string) (video.InputVideo, error) {
if f.Err != nil {
return video.InputVideo{}, f.Err
}
Expand Down
Binary file added video/fixtures/parametric-stereo-error.mp4
Binary file not shown.
9 changes: 6 additions & 3 deletions video/probe.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,20 @@ import (
)

type Prober interface {
ProbeFile(url string) (InputVideo, error)
ProbeFile(url string, ffProbeOptions ...string) (InputVideo, error)
}

type Probe struct{}

func (p Probe) ProbeFile(url string) (iv InputVideo, err error) {
func (p Probe) ProbeFile(url string, ffProbeOptions ...string) (iv InputVideo, err error) {
if len(ffProbeOptions) == 0 {
ffProbeOptions = []string{"-loglevel", "error"}
}
var data *ffprobe.ProbeData
operation := func() error {
probeCtx, probeCancel := context.WithTimeout(context.Background(), 60*time.Second)
defer probeCancel()
data, err = ffprobe.ProbeURL(probeCtx, url, "-loglevel", "error")
data, err = ffprobe.ProbeURL(probeCtx, url, ffProbeOptions...)
return err
}

Expand Down
17 changes: 15 additions & 2 deletions video/profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package video
import (
"fmt"
"strconv"
"strings"
)

const (
Expand Down Expand Up @@ -167,10 +168,9 @@ type OutputVideoFile struct {
}

func PopulateOutput(probe Prober, outputURL string, videoFile OutputVideoFile) (OutputVideoFile, error) {
outputVideoProbe, err := probe.ProbeFile(outputURL)
outputVideoProbe, err := runProbe(probe, outputURL)
if err != nil {
return OutputVideoFile{}, fmt.Errorf("error probing output file from S3: %w", err)

}
videoFile.SizeBytes = outputVideoProbe.SizeBytes
videoTrack, err := outputVideoProbe.GetTrack(TrackTypeVideo)
Expand All @@ -182,3 +182,16 @@ func PopulateOutput(probe Prober, outputURL string, videoFile OutputVideoFile) (
videoFile.Bitrate = videoTrack.Bitrate
return videoFile, nil
}

func runProbe(probe Prober, outputURL string) (InputVideo, error) {
outputVideoProbe, err := probe.ProbeFile(outputURL)
if err == nil {
return outputVideoProbe, nil
}

// ignore this probing error if found and re-run with fatal loglevel to obtain the probe data
if strings.Contains(strings.ToLower(err.Error()), "parametric stereo signaled to be not-present but was found in the bitstream") {
return probe.ProbeFile(outputURL, "-loglevel", "fatal")
}
return InputVideo{}, err
}
11 changes: 11 additions & 0 deletions video/profiles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,14 @@ func TestGetPlaybackProfiles(t *testing.T) {
})
}
}

func TestPopulateOutput(t *testing.T) {
out, err := PopulateOutput(Probe{}, "fixtures/parametric-stereo-error.mp4", OutputVideoFile{})
require.NoError(t, err)
require.Equal(t, OutputVideoFile{
SizeBytes: 275075,
Width: 576,
Height: 1024,
Bitrate: 315733,
}, out)
}