Skip to content

Commit

Permalink
Fix unit test breakage resulting from ffmpeg upgrade.
Browse files Browse the repository at this point in the history
  • Loading branch information
j0sh committed Nov 21, 2019
1 parent 48c610d commit de42c89
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 34 deletions.
14 changes: 0 additions & 14 deletions ffmpeg/ffmpeg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1018,20 +1018,6 @@ func TestTranscoder_StreamCopyAndDrop(t *testing.T) {
`
run(cmd)

// Test failure of audio copy in mpegts-to-(not-mp4). eg, flv
// Fixing this requires using the aac_adtstoasc bitstream filter.
// (mp4 muxer automatically inserts it if necessary; others don't)
in.Fname = "../transcoder/test.ts"
out = []TranscodeOptions{TranscodeOptions{
Oname: dir + "/fail.flv",
VideoEncoder: ComponentOptions{Name: "drop"},
AudioEncoder: ComponentOptions{Name: "copy"},
}}
_, err = Transcode3(in, out)
if err == nil || err.Error() != "Invalid data found when processing input" {
t.Error("Expected error converting audio from ts to flv but got ", err)
}

// Encode one stream of a short sample while copying / dropping another
in.Fname = dir + "/test-short.ts"
out = []TranscodeOptions{TranscodeOptions{
Expand Down
19 changes: 16 additions & 3 deletions ffmpeg/nvidia_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,10 +445,23 @@ func TestNvidia_DrainFilters(t *testing.T) {
set -eux
cd "$0"
# ensure we have a 100fps output
# sanity check with ffmpeg itself
ffmpeg -loglevel warning -i test.ts -c:a copy -c:v libx264 -vf fps=100 -vsync 0 ffmpeg-out.ts
ffprobe -loglevel warning -show_streams -select_streams v -count_frames ffmpeg-out.ts > ffmpeg,out
grep nb_read_frames ffmpeg,out > ffmpeg-read-frames.out
grep duration= ffmpeg,out > ffmpeg-duration.out
# ensure output has correct fps and duration
ffprobe -loglevel warning -show_streams -select_streams v -count_frames out.ts > probe.out
grep nb_read_frames=100 probe.out
grep duration=1.00 probe.out
grep nb_read_frames probe.out > read-frames.out
diff -u ffmpeg-read-frames.out read-frames.out
grep duration= probe.out > duration.out
diff -u ffmpeg-duration.out duration.out
# actual values - these are not *that* important as long as they're
# reasonable and match ffmpeg's
grep nb_read_frames=102 probe.out
grep duration=1.0200 probe.out
`
run(cmd)

Expand Down
16 changes: 3 additions & 13 deletions segmenter/video_segmenter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,22 +436,12 @@ func TestServerDisconnect(t *testing.T) {
strmUrl := fmt.Sprintf("rtmp://localhost:%v/stream/%v", port, strm.GetStreamID())
opt := SegmenterOptions{SegLength: time.Second * 4}
vs := NewFFMpegVideoSegmenter("tmp", strm.GetStreamID(), strmUrl, opt)
server := &rtmp.Server{Addr: ":" + port}
player := vidplayer.NewVidPlayer(server, "", nil)
player.HandleRTMPPlay(
func(url *url.URL) (stream.RTMPVideoStream, error) {
return strm, nil
})

//Kick off RTMP server
go func() {
err := player.RtmpServer.ListenAndServe()
if err != nil {
t.Errorf("Error kicking off RTMP server: %v", err)
}
}()
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()
cmd := "dd if=/dev/urandom count=1 ibs=2000 | nc -Nl " + port
go exec.CommandContext(ctx, "bash", "-c", cmd).Output()

err := RunRTMPToHLS(vs, ctx)
if err == nil || err.Error() != "Input/output error" {
t.Error("Expected 'Input/output error' but instead got ", err)
Expand Down
8 changes: 4 additions & 4 deletions transcoder/ffmpeg_segment_transcoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ func TestTrans(t *testing.T) {
t.Errorf("Expecting 2 output segments, got %v", len(r))
}

if len(r[0]) < 250000 || len(r[0]) > 280000 {
t.Errorf("Expecting output size to be between 250000 and 280000 , got %v", len(r[0]))
if len(r[0]) < 250000 || len(r[0]) > 285000 {
t.Errorf("Expecting output size to be between 250000 and 285000 , got %v", len(r[0]))
}

if len(r[1]) < 280000 || len(r[1]) > 310000 {
t.Errorf("Expecting output size to be between 280000 and 310000 , got %v", len(r[1]))
if len(r[1]) < 280000 || len(r[1]) > 314000 {
t.Errorf("Expecting output size to be between 280000 and 314000 , got %v", len(r[1]))
}

if len(r[2]) < 600000 || len(r[2]) > 700000 {
Expand Down

0 comments on commit de42c89

Please sign in to comment.