@@ -1873,7 +1873,6 @@ func TestTranscoder_VFR(t *testing.T) {
1873
1873
run , dir := setupTest (t )
1874
1874
defer os .RemoveAll (dir )
1875
1875
1876
-
1877
1876
// prepare the input by generating a vfr video and verify its properties
1878
1877
cmd := `
1879
1878
ffmpeg -hide_banner -i "$1/../transcoder/test.ts" -an -vf "setpts='\
@@ -1967,3 +1966,49 @@ PTS_EOF
1967
1966
`
1968
1967
run (cmd )
1969
1968
}
1969
+
1970
+ func TestDurationFPS_GetCodecInfo (t * testing.T ) {
1971
+ run , dir := setupTest (t )
1972
+ defer os .RemoveAll (dir )
1973
+
1974
+ //Generate test files
1975
+ cmd := `
1976
+ cp "$1/../data/duplicate-audio-dts.ts" test.ts
1977
+ ffprobe -loglevel warning -show_format test.ts | grep duration=2.008555
1978
+ ffprobe -loglevel warning -show_streams -select_streams v test.ts | grep r_frame_rate=30/1
1979
+ cp "$1/../data/bunny.mp4" test.mp4
1980
+ ffmpeg -loglevel warning -i test.mp4 -c:v copy -c:a copy -t 2 test-short.mp4
1981
+ ffprobe -loglevel warning -show_format test-short.mp4 | grep duration=2.043356
1982
+ ffprobe -loglevel warning -show_streams -select_streams v test-short.mp4 | grep r_frame_rate=24/1
1983
+ ffmpeg -loglevel warning -i test-short.mp4 -c:v libvpx -c:a vorbis -strict -2 -t 2 test.webm
1984
+ ffprobe -loglevel warning -show_format test.webm | grep duration=2.049000
1985
+ ffprobe -loglevel warning -show_streams -select_streams v test.webm | grep r_frame_rate=24/1
1986
+ ffmpeg -loglevel warning -i test-short.mp4 -vn -c:a aac -b:a 128k test.m4a
1987
+ ffprobe -loglevel warning -show_format test.m4a | grep duration=2.042993
1988
+ ffmpeg -loglevel warning -i test-short.mp4 -vn -c:a flac test.flac
1989
+ ffprobe -loglevel warning -show_format test.flac | grep duration=2.043356
1990
+ `
1991
+ run (cmd )
1992
+
1993
+ files := []struct {
1994
+ Filename string
1995
+ Duration int64
1996
+ FPS float32
1997
+ }{
1998
+ {Filename : "test-short.mp4" , Duration : 2 , FPS : 24 },
1999
+ {Filename : "test.ts" , Duration : 2 , FPS : 30.0 },
2000
+ {Filename : "test.flac" , Duration : 2 , FPS : 0.0 },
2001
+ {Filename : "test.webm" , Duration : 2 , FPS : 24 },
2002
+ {Filename : "test.m4a" , Duration : 2 , FPS : 0.0 },
2003
+ }
2004
+ for _ , file := range files {
2005
+ t .Run (file .Filename , func (t * testing.T ) {
2006
+ assert := assert .New (t )
2007
+ status , format , err := GetCodecInfo (path .Join (dir , file .Filename ))
2008
+ assert .Nil (err , "getcodecinfo error" )
2009
+ assert .Equal (CodecStatusOk , status , "status not ok" )
2010
+ assert .Equal (file .Duration , format .DurSecs , "duration mismatch" )
2011
+ assert .Equal (file .FPS , format .FPS , "fps mismatch" )
2012
+ })
2013
+ }
2014
+ }
0 commit comments