Skip to content

Commit

Permalink
ffmpeg: uncomment the NoKeyframe specific unit test (livepeer#277)
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesWanglf authored Dec 7, 2021
1 parent 91b94f8 commit 1b6c4df
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 49 deletions.
Binary file added data/kryp-1.ts
Binary file not shown.
Binary file added data/kryp-2.ts
Binary file not shown.
83 changes: 40 additions & 43 deletions ffmpeg/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1322,6 +1322,46 @@ func TestTranscoderAPI_ClipInvalidConfig(t *testing.T) {
}
}

func noKeyframeSegment(t *testing.T, accel Acceleration) {
// Reproducing #219
run, dir := setupTest(t)
defer os.RemoveAll(dir)

cmd := `
cp "$1"/../data/kryp-*.ts .
# verify no keyframes in kryp-2.ts but there in kryp-1.ts
ffprobe -select_streams v -show_streams -show_packets kryp-1.ts | grep flags=K | wc -l | grep 1
ffprobe -select_streams v -show_streams -show_packets kryp-2.ts | grep flags=K | wc -l | grep 0
`
run(cmd)

prof := P144p30fps16x9
for i := 1; i <= 2; i++ {
tc := NewTranscoder()
in := &TranscodeOptionsIn{
Fname: fmt.Sprintf("%s/kryp-%d.ts", dir, i),
Accel: accel,
}
out := []TranscodeOptions{{
Oname: fmt.Sprintf("%s/out%d.ts", dir, i),
Profile: prof,
Accel: accel,
}}
_, err := tc.Transcode(in, out)
if i == 2 && (err == nil || err.Error() != "No keyframes in input") {
t.Error("Expected to fail for no keyframe segment but did not")
} else if i != 2 && err != nil {
t.Error(err)
}
tc.StopTranscoder()
}
}

func TestTranscoder_NoKeyframe(t *testing.T) {
noKeyframeSegment(t, Software)
}

/*
func detectionFreq(t *testing.T, accel Acceleration) {
run, dir := setupTest(t)
Expand Down Expand Up @@ -1377,46 +1417,3 @@ func TestTranscoder_DetectionFreq(t *testing.T) {
detectionFreq(t, Software)
}
*/

/*
func noKeyframeSegment(t *testing.T, accel Acceleration) {
// Reproducing #219
run, dir := setupTest(t)
defer os.RemoveAll(dir)
cmd := `
cp "$1"/../transcoder/kryp-*.ts .
# verify no keyframes in kryp-2.ts but there in kryp-1.ts
ffprobe -select_streams v -show_streams -show_packets kryp-1.ts | grep flags=K | wc -l | grep 1
ffprobe -select_streams v -show_streams -show_packets kryp-2.ts | grep flags=K | wc -l | grep 0
`
run(cmd)
tc := NewTranscoder()
prof := P144p30fps16x9
for i := 1; i <= 2; i++ {
in := &TranscodeOptionsIn{
Fname: fmt.Sprintf("%s/kryp-%d.ts", dir, i),
Accel: accel,
}
out := []TranscodeOptions{{
Oname: fmt.Sprintf("%s/out%d.ts", dir, i),
Profile: prof,
Accel: accel,
}}
_, err := tc.Transcode(in, out)
if i == 2 && (err == nil || err.Error() != "No keyframes in input") {
t.Error("Expected to fail for no keyframe segment but did not")
} else if i != 2 && err != nil {
t.Error(err)
}
}
tc.StopTranscoder()
}
func TestTranscoder_NoKeyframe(t *testing.T) {
noKeyframeSegment(t, Software)
}
*/
10 changes: 4 additions & 6 deletions ffmpeg/nvidia_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -792,15 +792,13 @@ func TestNvidia_OutputFPS(t *testing.T) {
outputFPS(t, Nvidia)
}

/*
func TestNvidia_DetectionFreq(t *testing.T) {
detectionFreq(t, Nvidia)
func TestNvidia_NoKeyframe(t *testing.T) {
noKeyframeSegment(t, Nvidia)
}
*/

/*
func TestNvidia_NoKeyframe(t *testing.T) {
noKeyframeSegment(t, Nvidia)
func TestNvidia_DetectionFreq(t *testing.T) {
detectionFreq(t, Nvidia)
}
*/

Expand Down

0 comments on commit 1b6c4df

Please sign in to comment.