diff --git a/src/AvTranscoder/file/FormatContext.cpp b/src/AvTranscoder/file/FormatContext.cpp index 1306347e..1579b76b 100644 --- a/src/AvTranscoder/file/FormatContext.cpp +++ b/src/AvTranscoder/file/FormatContext.cpp @@ -191,12 +191,12 @@ void FormatContext::setOutputFormat( const std::string& filename, const std::str msg += filename; if( ! shortName.empty() ) { - msg += ", "; + msg += ", formatName = "; msg += shortName; } if( ! mimeType.empty() ) { - msg += ", "; + msg += ", mimeType = "; msg += mimeType; } throw std::ios_base::failure( msg ); diff --git a/src/AvTranscoder/file/OutputFile.cpp b/src/AvTranscoder/file/OutputFile.cpp index 057a33f2..3d82113b 100644 --- a/src/AvTranscoder/file/OutputFile.cpp +++ b/src/AvTranscoder/file/OutputFile.cpp @@ -11,7 +11,7 @@ namespace avtranscoder { -OutputFile::OutputFile( const std::string& filename ) +OutputFile::OutputFile( const std::string& filename, const std::string& formatName, const std::string& mimeType ) : _formatContext( AV_OPT_FLAG_ENCODING_PARAM ) , _outputStreams() , _frameCount() @@ -19,7 +19,7 @@ OutputFile::OutputFile( const std::string& filename ) , _profile() { _formatContext.setFilename( filename ); - _formatContext.setOutputFormat( filename ); + _formatContext.setOutputFormat( filename, formatName, mimeType ); } OutputFile::~OutputFile() diff --git a/src/AvTranscoder/file/OutputFile.hpp b/src/AvTranscoder/file/OutputFile.hpp index bf71f30d..a2b7c1a3 100644 --- a/src/AvTranscoder/file/OutputFile.hpp +++ b/src/AvTranscoder/file/OutputFile.hpp @@ -22,10 +22,15 @@ class AvExport OutputFile : public IOutputFile public: /** - * @brief Open an output media file + * @brief Create an output media file. * @param filename resource to access + * @param formatName should matches with the names of the registered formats + * @param mimeType should matches with the MIME type of the registered formats + * @note The caller should indicate formatName and/or mimeType if the filename has no extension. + * @note The ressource is allocated when beginWrap. + * @see beginWrap **/ - OutputFile( const std::string& filename = "" ); + OutputFile( const std::string& filename, const std::string& formatName = "", const std::string& mimeType = "" ); ~OutputFile(); diff --git a/test/pyTest/testEProcessMethod.py b/test/pyTest/testEProcessMethod.py index d8c26090..ac733af1 100644 --- a/test/pyTest/testEProcessMethod.py +++ b/test/pyTest/testEProcessMethod.py @@ -2,8 +2,8 @@ # Check if environment is setup to run the tests if os.environ.get('AVTRANSCODER_TEST_VIDEO_AVI_FILE') is None or os.environ.get('AVTRANSCODER_TEST_AUDIO_MOV_FILE') is None or os.environ.get('AVTRANSCODER_TEST_AUDIO_WAVE_FILE') is None: - from nose.plugins.skip import SkipTest - raise SkipTest("Need to define environment variables AVTRANSCODER_TEST_VIDEO_AVI_FILE / AVTRANSCODER_TEST_AUDIO_MOV_FILE / AVTRANSCODER_TEST_AUDIO_WAVE_FILE") + from nose.plugins.skip import SkipTest + raise SkipTest("Need to define environment variables AVTRANSCODER_TEST_VIDEO_AVI_FILE / AVTRANSCODER_TEST_AUDIO_MOV_FILE / AVTRANSCODER_TEST_AUDIO_WAVE_FILE") from nose.tools import * @@ -14,117 +14,117 @@ def testEProcessMethodShortest(): - """ - Process with method eProcessMethodShortest, check output duration. - """ - inputFileName_longest = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE'] - inputFileName_shortest = os.environ['AVTRANSCODER_TEST_AUDIO_MOV_FILE'] - outputFileName = "testEProcessMethodShortest.mov" + """ + Process with method eProcessMethodShortest, check output duration. + """ + inputFileName_longest = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE'] + inputFileName_shortest = os.environ['AVTRANSCODER_TEST_AUDIO_MOV_FILE'] + outputFileName = "testEProcessMethodShortest.mov" - ouputFile = av.OutputFile( outputFileName ) - transcoder = av.Transcoder( ouputFile ) - transcoder.setProcessMethod( av.eProcessMethodShortest ) + ouputFile = av.OutputFile( outputFileName ) + transcoder = av.Transcoder( ouputFile ) + transcoder.setProcessMethod( av.eProcessMethodShortest ) - transcoder.add( inputFileName_longest, 0, "" ) - transcoder.add( inputFileName_shortest, 0, "" ) + transcoder.add( inputFileName_longest, 0, "" ) + transcoder.add( inputFileName_shortest, 0, "" ) - progress = av.ConsoleProgress() - transcoder.process( progress ) + progress = av.ConsoleProgress() + transcoder.process( progress ) - # get src file - src_inputFile_shortest = av.InputFile( inputFileName_shortest ) - src_properties_shortest = src_inputFile_shortest.getProperties() + # get src file + src_inputFile_shortest = av.InputFile( inputFileName_shortest ) + src_properties_shortest = src_inputFile_shortest.getProperties() - # get dst file - dst_inputFile = av.InputFile( outputFileName ) - dst_properties = dst_inputFile.getProperties() + # get dst file + dst_inputFile = av.InputFile( outputFileName ) + dst_properties = dst_inputFile.getProperties() - assert_equals( dst_properties.getDuration(), src_properties_shortest.getDuration() ) + assert_equals( dst_properties.getDuration(), src_properties_shortest.getDuration() ) def testEProcessMethodLongest(): - """ - Process with method eProcessMethodLongest, check output duration. - """ - inputFileName_longest = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE'] - inputFileName_shortest = os.environ['AVTRANSCODER_TEST_AUDIO_MOV_FILE'] - outputFileName = "testEProcessMethodLongest.mov" + """ + Process with method eProcessMethodLongest, check output duration. + """ + inputFileName_longest = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE'] + inputFileName_shortest = os.environ['AVTRANSCODER_TEST_AUDIO_MOV_FILE'] + outputFileName = "testEProcessMethodLongest.mov" - ouputFile = av.OutputFile( outputFileName ) - transcoder = av.Transcoder( ouputFile ) - transcoder.setProcessMethod( av.eProcessMethodLongest ) + ouputFile = av.OutputFile( outputFileName ) + transcoder = av.Transcoder( ouputFile ) + transcoder.setProcessMethod( av.eProcessMethodLongest ) - transcoder.add( inputFileName_longest, 0, "" ) - transcoder.add( inputFileName_shortest, 0, "" ) + transcoder.add( inputFileName_longest, 0, "" ) + transcoder.add( inputFileName_shortest, 0, "" ) - progress = av.ConsoleProgress() - transcoder.process( progress ) + progress = av.ConsoleProgress() + transcoder.process( progress ) # get src file - src_inputFile_longest = av.InputFile( inputFileName_longest ) - src_properties_longest = src_inputFile_longest.getProperties() + src_inputFile_longest = av.InputFile( inputFileName_longest ) + src_properties_longest = src_inputFile_longest.getProperties() - # get dst file - dst_inputFile = av.InputFile( outputFileName ) - dst_properties = dst_inputFile.getProperties() + # get dst file + dst_inputFile = av.InputFile( outputFileName ) + dst_properties = dst_inputFile.getProperties() - assert_equals( dst_properties.getDuration(), src_properties_longest.getDuration() ) + assert_equals( dst_properties.getDuration(), src_properties_longest.getDuration() ) def testEProcessMethodBasedOnStream(): - """ - Process with method testEProcessMethodBasedOnStream, check output duration. - """ - inputFileName_first = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE'] - inputFileName_second = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE'] - inputFileName_third = os.environ['AVTRANSCODER_TEST_AUDIO_MOV_FILE'] - outputFileName = "testEProcessMethodShortest.mov" + """ + Process with method testEProcessMethodBasedOnStream, check output duration. + """ + inputFileName_first = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE'] + inputFileName_second = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE'] + inputFileName_third = os.environ['AVTRANSCODER_TEST_AUDIO_MOV_FILE'] + outputFileName = "testEProcessMethodShortest.mov" - ouputFile = av.OutputFile( outputFileName ) - transcoder = av.Transcoder( ouputFile ) - transcoder.setProcessMethod( av.eProcessMethodBasedOnStream, 1 ) + ouputFile = av.OutputFile( outputFileName ) + transcoder = av.Transcoder( ouputFile ) + transcoder.setProcessMethod( av.eProcessMethodBasedOnStream, 1 ) - transcoder.add( inputFileName_first, 0, "" ) - transcoder.add( inputFileName_second, 0, "" ) - transcoder.add( inputFileName_third, 0, "" ) + transcoder.add( inputFileName_first, 0, "" ) + transcoder.add( inputFileName_second, 0, "" ) + transcoder.add( inputFileName_third, 0, "" ) - progress = av.ConsoleProgress() - transcoder.process( progress ) + progress = av.ConsoleProgress() + transcoder.process( progress ) - # get src file - src_inputFile_second = av.InputFile( inputFileName_second ) - src_properties_second = src_inputFile_second.getProperties() + # get src file + src_inputFile_second = av.InputFile( inputFileName_second ) + src_properties_second = src_inputFile_second.getProperties() - # get dst file - dst_inputFile = av.InputFile( outputFileName ) - dst_properties = dst_inputFile.getProperties() + # get dst file + dst_inputFile = av.InputFile( outputFileName ) + dst_properties = dst_inputFile.getProperties() - assert_equals( dst_properties.getDuration(), src_properties_second.getDuration() ) + assert_equals( dst_properties.getDuration(), src_properties_second.getDuration() ) def testEProcessMethodBasedOnDuration(): - """ - Process with method eProcessMethodBasedOnDuration, check output duration. - """ - inputFileName_first = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE'] - inputFileName_second = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE'] - inputFileName_third = os.environ['AVTRANSCODER_TEST_AUDIO_MOV_FILE'] - outputFileName = "testEProcessMethodBasedOnDuration.mov" - - ouputFile = av.OutputFile( outputFileName ) - transcoder = av.Transcoder( ouputFile ) - transcoder.setProcessMethod( av.eProcessMethodBasedOnDuration, 0, 50 ) - - transcoder.add( inputFileName_first, 0, "" ) - transcoder.add( inputFileName_second, 0, "" ) - transcoder.add( inputFileName_third, 0, "" ) - - progress = av.ConsoleProgress() - transcoder.process( progress ) - - # get dst file - dst_inputFile = av.InputFile( outputFileName ) - dst_properties = dst_inputFile.getProperties() - - assert_equals( dst_properties.getDuration(), 50 ) + """ + Process with method eProcessMethodBasedOnDuration, check output duration. + """ + inputFileName_first = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE'] + inputFileName_second = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE'] + inputFileName_third = os.environ['AVTRANSCODER_TEST_AUDIO_MOV_FILE'] + outputFileName = "testEProcessMethodBasedOnDuration.mov" + + ouputFile = av.OutputFile( outputFileName ) + transcoder = av.Transcoder( ouputFile ) + transcoder.setProcessMethod( av.eProcessMethodBasedOnDuration, 0, 50 ) + + transcoder.add( inputFileName_first, 0, "" ) + transcoder.add( inputFileName_second, 0, "" ) + transcoder.add( inputFileName_third, 0, "" ) + + progress = av.ConsoleProgress() + transcoder.process( progress ) + + # get dst file + dst_inputFile = av.InputFile( outputFileName ) + dst_properties = dst_inputFile.getProperties() + + assert_equals( dst_properties.getDuration(), 50 ) diff --git a/test/pyTest/testNbFrames.py b/test/pyTest/testNbFrames.py index 0631a81c..d3da3f5f 100644 --- a/test/pyTest/testNbFrames.py +++ b/test/pyTest/testNbFrames.py @@ -2,8 +2,8 @@ # Check if environment is setup to run the tests if os.environ.get('AVTRANSCODER_TEST_VIDEO_AVI_FILE') is None: - from nose.plugins.skip import SkipTest - raise SkipTest("Need to define environment variable AVTRANSCODER_TEST_VIDEO_AVI_FILE") + from nose.plugins.skip import SkipTest + raise SkipTest("Need to define environment variable AVTRANSCODER_TEST_VIDEO_AVI_FILE") from nose.tools import * @@ -14,55 +14,55 @@ def testNbFramesVideoRewrap(): - """ - Rewrap one video stream, check nb frames. - """ - inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE'] - outputFileName = "testNbFramesVideoRewrap.mov" + """ + Rewrap one video stream, check nb frames. + """ + inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE'] + outputFileName = "testNbFramesVideoRewrap.mov" - ouputFile = av.OutputFile( outputFileName ) - transcoder = av.Transcoder( ouputFile ) + ouputFile = av.OutputFile( outputFileName ) + transcoder = av.Transcoder( ouputFile ) - transcoder.add( inputFileName, 0, "" ) + transcoder.add( inputFileName, 0, "" ) - progress = av.ConsoleProgress() - transcoder.process( progress ) + progress = av.ConsoleProgress() + transcoder.process( progress ) - # get src file of rewrap - src_inputFile = av.InputFile( inputFileName ) - src_properties = src_inputFile.getProperties() - src_videoStream = src_properties.getVideoProperties()[0] + # get src file of rewrap + src_inputFile = av.InputFile( inputFileName ) + src_properties = src_inputFile.getProperties() + src_videoStream = src_properties.getVideoProperties()[0] - # get dst file of rewrap - dst_inputFile = av.InputFile( outputFileName ) - dst_properties = dst_inputFile.getProperties() - dst_videoStream = dst_properties.getVideoProperties()[0] + # get dst file of rewrap + dst_inputFile = av.InputFile( outputFileName ) + dst_properties = dst_inputFile.getProperties() + dst_videoStream = dst_properties.getVideoProperties()[0] - assert_equals( src_videoStream.getNbFrames(), dst_videoStream.getNbFrames() ) + assert_equals( src_videoStream.getNbFrames(), dst_videoStream.getNbFrames() ) def testNbFramesVideoTranscode(): - """ - Transcode one video stream (to h264), check nb frames. - """ - inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE'] - outputFileName = "testNbFramesVideoTranscode.mov" + """ + Transcode one video stream (to h264), check nb frames. + """ + inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE'] + outputFileName = "testNbFramesVideoTranscode.mov" - ouputFile = av.OutputFile( outputFileName ) - transcoder = av.Transcoder( ouputFile ) + ouputFile = av.OutputFile( outputFileName ) + transcoder = av.Transcoder( ouputFile ) - transcoder.add( inputFileName, 0, "mpeg2" ) + transcoder.add( inputFileName, 0, "mpeg2" ) - progress = av.ConsoleProgress() - transcoder.process( progress ) + progress = av.ConsoleProgress() + transcoder.process( progress ) - # get src file of transcode - src_inputFile = av.InputFile( inputFileName ) - src_properties = src_inputFile.getProperties() - src_videoStream = src_properties.getVideoProperties()[0] + # get src file of transcode + src_inputFile = av.InputFile( inputFileName ) + src_properties = src_inputFile.getProperties() + src_videoStream = src_properties.getVideoProperties()[0] - # get dst file of transcode - dst_inputFile = av.InputFile( outputFileName ) - dst_properties = dst_inputFile.getProperties() - dst_videoStream = dst_properties.getVideoProperties()[0] + # get dst file of transcode + dst_inputFile = av.InputFile( outputFileName ) + dst_properties = dst_inputFile.getProperties() + dst_videoStream = dst_properties.getVideoProperties()[0] - assert_equals( src_videoStream.getNbFrames(), dst_videoStream.getNbFrames() ) + assert_equals( src_videoStream.getNbFrames(), dst_videoStream.getNbFrames() ) diff --git a/test/pyTest/testNbSamples.py b/test/pyTest/testNbSamples.py index b77c9127..835602f0 100644 --- a/test/pyTest/testNbSamples.py +++ b/test/pyTest/testNbSamples.py @@ -2,8 +2,8 @@ # Check if environment is setup to run the tests if os.environ.get('AVTRANSCODER_TEST_AUDIO_WAVE_FILE') is None: - from nose.plugins.skip import SkipTest - raise SkipTest("Need to define environment variable AVTRANSCODER_TEST_AUDIO_WAVE_FILE") + from nose.plugins.skip import SkipTest + raise SkipTest("Need to define environment variable AVTRANSCODER_TEST_AUDIO_WAVE_FILE") from nose.tools import * @@ -14,62 +14,62 @@ def testNbSamplesAudioRewrap(): - """ - Rewrap one audio stream, check nb samples. - """ - inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE'] - outputFileName = "testNbSamplesAudioRewrap.wav" + """ + Rewrap one audio stream, check nb samples. + """ + inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE'] + outputFileName = "testNbSamplesAudioRewrap.wav" - ouputFile = av.OutputFile( outputFileName ) - transcoder = av.Transcoder( ouputFile ) + ouputFile = av.OutputFile( outputFileName ) + transcoder = av.Transcoder( ouputFile ) - transcoder.add( inputFileName, 0, "" ) + transcoder.add( inputFileName, 0, "" ) - progress = av.ConsoleProgress() - transcoder.process( progress ) + progress = av.ConsoleProgress() + transcoder.process( progress ) - # get src file of rewrap - src_inputFile = av.InputFile( inputFileName ) - src_properties = src_inputFile.getProperties() - src_audioStream = src_properties.getAudioProperties()[0] + # get src file of rewrap + src_inputFile = av.InputFile( inputFileName ) + src_properties = src_inputFile.getProperties() + src_audioStream = src_properties.getAudioProperties()[0] - # get dst file of rewrap - dst_inputFile = av.InputFile( outputFileName ) - dst_properties = dst_inputFile.getProperties() - dst_audioStream = dst_properties.getAudioProperties()[0] + # get dst file of rewrap + dst_inputFile = av.InputFile( outputFileName ) + dst_properties = dst_inputFile.getProperties() + dst_audioStream = dst_properties.getAudioProperties()[0] - assert_equals( src_audioStream.getNbSamples(), dst_audioStream.getNbSamples() ) + assert_equals( src_audioStream.getNbSamples(), dst_audioStream.getNbSamples() ) def testNbSamplesAudioTranscode(): - """ - Transcode one audio stream (to wave24b48kmono), check nb samples. - """ - inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE'] - outputFileName = "testNbSamplesAudioTranscode.wav" - - ouputFile = av.OutputFile( outputFileName ) - transcoder = av.Transcoder( ouputFile ) - - # create custom profile - customProfile = av.ProfileMap() - customProfile[av.avProfileIdentificator] = "customProfile" - customProfile[av.avProfileIdentificatorHuman] = "custom profile" - customProfile[av.avProfileType] = av.avProfileTypeAudio - customProfile[av.avProfileCodec] = "pcm_s16le" - - transcoder.add( inputFileName, 0, customProfile ) - - progress = av.ConsoleProgress() - transcoder.process( progress ) - - # get src file of transcode - src_inputFile = av.InputFile( inputFileName ) - src_properties = src_inputFile.getProperties() - src_audioStream = src_properties.getAudioProperties()[0] - - # get dst file of transcode - dst_inputFile = av.InputFile( outputFileName ) - dst_properties = dst_inputFile.getProperties() - dst_audioStream = dst_properties.getAudioProperties()[0] - - assert_equals( src_audioStream.getNbSamples(), dst_audioStream.getNbSamples() ) + """ + Transcode one audio stream (to wave24b48kmono), check nb samples. + """ + inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE'] + outputFileName = "testNbSamplesAudioTranscode.wav" + + ouputFile = av.OutputFile( outputFileName ) + transcoder = av.Transcoder( ouputFile ) + + # create custom profile + customProfile = av.ProfileMap() + customProfile[av.avProfileIdentificator] = "customProfile" + customProfile[av.avProfileIdentificatorHuman] = "custom profile" + customProfile[av.avProfileType] = av.avProfileTypeAudio + customProfile[av.avProfileCodec] = "pcm_s16le" + + transcoder.add( inputFileName, 0, customProfile ) + + progress = av.ConsoleProgress() + transcoder.process( progress ) + + # get src file of transcode + src_inputFile = av.InputFile( inputFileName ) + src_properties = src_inputFile.getProperties() + src_audioStream = src_properties.getAudioProperties()[0] + + # get dst file of transcode + dst_inputFile = av.InputFile( outputFileName ) + dst_properties = dst_inputFile.getProperties() + dst_audioStream = dst_properties.getAudioProperties()[0] + + assert_equals( src_audioStream.getNbSamples(), dst_audioStream.getNbSamples() ) diff --git a/test/pyTest/testOffset.py b/test/pyTest/testOffset.py index fec33dc7..1ef13c98 100644 --- a/test/pyTest/testOffset.py +++ b/test/pyTest/testOffset.py @@ -2,8 +2,8 @@ # Check if environment is setup to run the tests if os.environ.get('AVTRANSCODER_TEST_AUDIO_WAVE_FILE') is None or os.environ.get('AVTRANSCODER_TEST_AUDIO_MOV_FILE') is None or os.environ.get('AVTRANSCODER_TEST_VIDEO_AVI_FILE') is None: - from nose.plugins.skip import SkipTest - raise SkipTest("Need to define environment variables AVTRANSCODER_TEST_VIDEO_AVI_FILE / AVTRANSCODER_TEST_AUDIO_MOV_FILE / AVTRANSCODER_TEST_AUDIO_WAVE_FILE") + from nose.plugins.skip import SkipTest + raise SkipTest("Need to define environment variables AVTRANSCODER_TEST_VIDEO_AVI_FILE / AVTRANSCODER_TEST_AUDIO_MOV_FILE / AVTRANSCODER_TEST_AUDIO_WAVE_FILE") from nose.tools import * @@ -15,316 +15,323 @@ def testTranscodeAudioPositiveOffset(): - """ - Transcode one audio stream (profile wave24b48kmono) with offset at the beginning of the process. - """ - inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE'] - outputFileName = "testTranscodeAudioPositiveOffset.wav" - offset = 10 + """ + Transcode one audio stream (profile wave24b48kmono) with offset at the beginning of the process. + """ + inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE'] + outputFileName = "testTranscodeAudioPositiveOffset.wav" + offset = 10 - ouputFile = av.OutputFile( outputFileName ) - transcoder = av.Transcoder( ouputFile ) + ouputFile = av.OutputFile( outputFileName ) + transcoder = av.Transcoder( ouputFile ) - transcoder.add( inputFileName, 0, "wave24b48kmono", offset ) + transcoder.add( inputFileName, 0, "wave24b48kmono", offset ) - progress = av.ConsoleProgress() - transcoder.process( progress ) + progress = av.ConsoleProgress() + transcoder.process( progress ) - # get src file - src_inputFile = av.InputFile( inputFileName ) - src_properties = src_inputFile.getProperties() - src_audioStream = src_properties.getAudioProperties()[0] + # get src file + src_inputFile = av.InputFile( inputFileName ) + src_properties = src_inputFile.getProperties() + src_audioStream = src_properties.getAudioProperties()[0] - # get dst file - dst_inputFile = av.InputFile( outputFileName ) - dst_properties = dst_inputFile.getProperties() - dst_audioStream = dst_properties.getAudioProperties()[0] + # get dst file + dst_inputFile = av.InputFile( outputFileName ) + dst_properties = dst_inputFile.getProperties() + dst_audioStream = dst_properties.getAudioProperties()[0] - # check output duration - assert_equals( src_audioStream.getDuration() + offset, dst_audioStream.getDuration() ) + # check output duration + assert_equals( src_audioStream.getDuration() + offset, dst_audioStream.getDuration() ) def testTranscodeAudioNegativeOffset(): - """ - Transcode one audio stream (profile wave24b48kmono) with a negative offset at the beginning of the process. - """ - inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE'] - outputFileName = "testTranscodeAudioNegativeOffset.wav" - offset = -5.5 + """ + Transcode one audio stream (profile wave24b48kmono) with a negative offset at the beginning of the process. + """ + inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE'] + outputFileName = "testTranscodeAudioNegativeOffset.wav" + offset = -5.5 - ouputFile = av.OutputFile( outputFileName ) - transcoder = av.Transcoder( ouputFile ) + ouputFile = av.OutputFile( outputFileName ) + transcoder = av.Transcoder( ouputFile ) - transcoder.add( inputFileName, 0, "wave24b48kmono", offset ) + transcoder.add( inputFileName, 0, "wave24b48kmono", offset ) - progress = av.ConsoleProgress() - transcoder.process( progress ) + progress = av.ConsoleProgress() + transcoder.process( progress ) - # get src file - src_inputFile = av.InputFile( inputFileName ) - src_properties = src_inputFile.getProperties() - src_audioStream = src_properties.getAudioProperties()[0] + # get src file + src_inputFile = av.InputFile( inputFileName ) + src_properties = src_inputFile.getProperties() + src_audioStream = src_properties.getAudioProperties()[0] - # get dst file - dst_inputFile = av.InputFile( outputFileName ) - dst_properties = dst_inputFile.getProperties() - dst_audioStream = dst_properties.getAudioProperties()[0] + # get dst file + dst_inputFile = av.InputFile( outputFileName ) + dst_properties = dst_inputFile.getProperties() + dst_audioStream = dst_properties.getAudioProperties()[0] - # check output duration - assert_almost_equals( src_audioStream.getDuration() + offset, dst_audioStream.getDuration(), delta=0.01 ) + # check output duration + assert_almost_equals( src_audioStream.getDuration() + offset, dst_audioStream.getDuration(), delta=0.01 ) def testRewrapAudioPositiveOffset(): - """ - Rewrap one audio stream with offset at the beginning of the process. - """ - inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE'] - outputFileName = "testRewrapAudioPositiveOffset.wav" - offset = 10 + """ + Rewrap one audio stream with offset at the beginning of the process. + """ + inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE'] + outputFileName = "testRewrapAudioPositiveOffset.wav" + offset = 10 - ouputFile = av.OutputFile( outputFileName ) - transcoder = av.Transcoder( ouputFile ) + ouputFile = av.OutputFile( outputFileName ) + transcoder = av.Transcoder( ouputFile ) - transcoder.add( inputFileName, 0, "", offset ) + transcoder.add( inputFileName, 0, "", offset ) - progress = av.ConsoleProgress() - transcoder.process( progress ) + progress = av.ConsoleProgress() + transcoder.process( progress ) - # get src file - src_inputFile = av.InputFile( inputFileName ) - src_properties = src_inputFile.getProperties() - src_audioStream = src_properties.getAudioProperties()[0] + # get src file + src_inputFile = av.InputFile( inputFileName ) + src_properties = src_inputFile.getProperties() + src_audioStream = src_properties.getAudioProperties()[0] - # get dst file - dst_inputFile = av.InputFile( outputFileName ) - dst_properties = dst_inputFile.getProperties() - dst_audioStream = dst_properties.getAudioProperties()[0] + # get dst file + dst_inputFile = av.InputFile( outputFileName ) + dst_properties = dst_inputFile.getProperties() + dst_audioStream = dst_properties.getAudioProperties()[0] - # check output duration - assert_equals( src_audioStream.getDuration() + offset, dst_audioStream.getDuration() ) - assert_equals( src_audioStream.getNbSamples() + ( offset * dst_audioStream.getSampleRate() * dst_audioStream.getChannels() ), dst_audioStream.getNbSamples() ) + # check output duration + assert_equals( src_audioStream.getDuration() + offset, dst_audioStream.getDuration() ) + # check output duration + assert_equals( src_audioStream.getDuration() + offset, dst_audioStream.getDuration() ) + assert_equals( src_audioStream.getNbSamples() + ( offset * dst_audioStream.getSampleRate() * dst_audioStream.getChannels() ), dst_audioStream.getNbSamples() ) def testRewrapAudioNegativeOffset(): - """ - Rewrap one audio stream with a negative offset at the beginning of the process. - """ - inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE'] - outputFileName = "testRewrapAudioNegativeOffset.wav" - offset = -5.5 + """ + Rewrap one audio stream with a negative offset at the beginning of the process. + """ + inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE'] + outputFileName = "testRewrapAudioNegativeOffset.wav" + offset = -5.5 - ouputFile = av.OutputFile( outputFileName ) - transcoder = av.Transcoder( ouputFile ) + ouputFile = av.OutputFile( outputFileName ) + transcoder = av.Transcoder( ouputFile ) - transcoder.add( inputFileName, 0, "", offset ) + transcoder.add( inputFileName, 0, "", offset ) - progress = av.ConsoleProgress() - transcoder.process( progress ) + progress = av.ConsoleProgress() + transcoder.process( progress ) - # get src file - src_inputFile = av.InputFile( inputFileName ) - src_properties = src_inputFile.getProperties() - src_audioStream = src_properties.getAudioProperties()[0] + # get src file + src_inputFile = av.InputFile( inputFileName ) + src_properties = src_inputFile.getProperties() + src_audioStream = src_properties.getAudioProperties()[0] - # get dst file - dst_inputFile = av.InputFile( outputFileName ) - dst_properties = dst_inputFile.getProperties() - dst_audioStream = dst_properties.getAudioProperties()[0] + # get dst file + dst_inputFile = av.InputFile( outputFileName ) + dst_properties = dst_inputFile.getProperties() + dst_audioStream = dst_properties.getAudioProperties()[0] - # check output duration - assert_almost_equals( src_audioStream.getDuration() + offset, dst_audioStream.getDuration(), delta=0.01 ) - assert_equals( src_audioStream.getNbSamples() + ( offset * dst_audioStream.getSampleRate() * dst_audioStream.getChannels() ), dst_audioStream.getNbSamples() ) + # check output duration + assert_almost_equals( src_audioStream.getDuration() + offset, dst_audioStream.getDuration(), delta=0.01 ) + # check output duration + assert_almost_equals( src_audioStream.getDuration() + offset, dst_audioStream.getDuration(), delta=0.01 ) + assert_equals( src_audioStream.getNbSamples() + ( offset * dst_audioStream.getSampleRate() * dst_audioStream.getChannels() ), dst_audioStream.getNbSamples() ) def testTranscodeVideoPositiveOffset(): - """ - Transcode one video stream (profile mpeg2) with offset at the beginning of the process. - """ - inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE'] - outputFileName = "testTranscodeVideoPositiveOffset.mov" - offset = 10 + """ + Transcode one video stream (profile mpeg2) with offset at the beginning of the process. + """ + inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE'] + outputFileName = "testTranscodeVideoPositiveOffset.mov" + offset = 10 - ouputFile = av.OutputFile( outputFileName ) - transcoder = av.Transcoder( ouputFile ) + ouputFile = av.OutputFile( outputFileName ) + transcoder = av.Transcoder( ouputFile ) - transcoder.add( inputFileName, 0, "mpeg2", offset ) + transcoder.add( inputFileName, 0, "mpeg2", offset ) - progress = av.ConsoleProgress() - transcoder.process( progress ) + progress = av.ConsoleProgress() + transcoder.process( progress ) - # get src file - src_inputFile = av.InputFile( inputFileName ) - src_properties = src_inputFile.getProperties() - src_videoStream = src_properties.getVideoProperties()[0] + # get src file + src_inputFile = av.InputFile( inputFileName ) + src_properties = src_inputFile.getProperties() + src_videoStream = src_properties.getVideoProperties()[0] - # get dst file - dst_inputFile = av.InputFile( outputFileName ) - dst_properties = dst_inputFile.getProperties() - dst_videoStream = dst_properties.getVideoProperties()[0] + # get dst file + dst_inputFile = av.InputFile( outputFileName ) + dst_properties = dst_inputFile.getProperties() + dst_videoStream = dst_properties.getVideoProperties()[0] - # check output duration - assert_equals( src_videoStream.getDuration() + offset, dst_videoStream.getDuration() ) + # check output duration + assert_equals( src_videoStream.getDuration() + offset, dst_videoStream.getDuration() ) def testTranscodeVideoNegativeOffset(): - """ - Transcode one video stream (profile mpeg2) with a negative offset at the beginning of the process. - """ - inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE'] - outputFileName = "testTranscodeVideoNegativeOffset.mov" - offset = -5.5 + """ + Transcode one video stream (profile mpeg2) with a negative offset at the beginning of the process. + """ + inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE'] + outputFileName = "testTranscodeVideoNegativeOffset.mov" + offset = -5.5 - ouputFile = av.OutputFile( outputFileName ) - transcoder = av.Transcoder( ouputFile ) + ouputFile = av.OutputFile( outputFileName ) + transcoder = av.Transcoder( ouputFile ) - transcoder.add( inputFileName, 0, "mpeg2", offset ) + transcoder.add( inputFileName, 0, "mpeg2", offset ) - progress = av.ConsoleProgress() - transcoder.process( progress ) + progress = av.ConsoleProgress() + transcoder.process( progress ) - # get src file - src_inputFile = av.InputFile( inputFileName ) - src_properties = src_inputFile.getProperties() - src_videoStream = src_properties.getVideoProperties()[0] + # get src file + src_inputFile = av.InputFile( inputFileName ) + src_properties = src_inputFile.getProperties() + src_videoStream = src_properties.getVideoProperties()[0] - # get dst file - dst_inputFile = av.InputFile( outputFileName ) - dst_properties = dst_inputFile.getProperties() - dst_videoStream = dst_properties.getVideoProperties()[0] + # get dst file + dst_inputFile = av.InputFile( outputFileName ) + dst_properties = dst_inputFile.getProperties() + dst_videoStream = dst_properties.getVideoProperties()[0] - # check output duration - assert_equals( src_videoStream.getDuration() + offset, dst_videoStream.getDuration() ) + # check output duration + assert_equals( src_videoStream.getDuration() + offset, dst_videoStream.getDuration() ) def testRewrapVideoPositiveOffset(): - """ - Rewrap one video stream with offset at the beginning of the process. - """ - inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE'] - outputFileName = "testRewrapVideoPositiveOffset.mov" - offset = 10 + """ + Rewrap one video stream with offset at the beginning of the process. + """ + inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE'] + outputFileName = "testRewrapVideoPositiveOffset.mov" + offset = 10 - ouputFile = av.OutputFile( outputFileName ) - transcoder = av.Transcoder( ouputFile ) + ouputFile = av.OutputFile( outputFileName ) + transcoder = av.Transcoder( ouputFile ) - transcoder.add( inputFileName, 0, "", offset ) + transcoder.add( inputFileName, 0, "", offset ) - progress = av.ConsoleProgress() - transcoder.process( progress ) + progress = av.ConsoleProgress() + transcoder.process( progress ) - # get src file - src_inputFile = av.InputFile( inputFileName ) - src_properties = src_inputFile.getProperties() - src_videoStream = src_properties.getVideoProperties()[0] + # get src file + src_inputFile = av.InputFile( inputFileName ) + src_properties = src_inputFile.getProperties() + src_videoStream = src_properties.getVideoProperties()[0] - # get dst file - dst_inputFile = av.InputFile( outputFileName ) - dst_properties = dst_inputFile.getProperties() - dst_videoStream = dst_properties.getVideoProperties()[0] + # get dst file + dst_inputFile = av.InputFile( outputFileName ) + dst_properties = dst_inputFile.getProperties() + dst_videoStream = dst_properties.getVideoProperties()[0] - # check output duration - assert_equals( src_videoStream.getDuration() + offset, dst_videoStream.getDuration() ) - assert_equals( src_videoStream.getNbFrames() + ( offset * dst_videoStream.getFps() ), dst_videoStream.getNbFrames() ) + # check output duration + assert_equals( src_videoStream.getDuration() + offset, dst_videoStream.getDuration() ) + # check output duration + assert_equals( src_videoStream.getDuration() + offset, dst_videoStream.getDuration() ) + assert_equals( src_videoStream.getNbFrames() + ( offset * dst_videoStream.getFps() ), dst_videoStream.getNbFrames() ) def testRewrapVideoNegativeOffset(): - """ - Rewrap one video stream with a negative offset at the beginning of the process. - """ - inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE'] - outputFileName = "testRewrapVideoNegativeOffset.mov" - offset = -5.5 + """ + Rewrap one video stream with a negative offset at the beginning of the process. + """ + inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE'] + outputFileName = "testRewrapVideoNegativeOffset.mov" + offset = -5.5 - ouputFile = av.OutputFile( outputFileName ) - transcoder = av.Transcoder( ouputFile ) + ouputFile = av.OutputFile( outputFileName ) + transcoder = av.Transcoder( ouputFile ) - transcoder.add( inputFileName, 0, "", offset ) + transcoder.add( inputFileName, 0, "", offset ) - progress = av.ConsoleProgress() - transcoder.process( progress ) + progress = av.ConsoleProgress() + transcoder.process( progress ) - # get src file - src_inputFile = av.InputFile( inputFileName ) - src_properties = src_inputFile.getProperties() - src_videoStream = src_properties.getVideoProperties()[0] + # get src file + src_inputFile = av.InputFile( inputFileName ) + src_properties = src_inputFile.getProperties() + src_videoStream = src_properties.getVideoProperties()[0] - # get dst file - dst_inputFile = av.InputFile( outputFileName ) - dst_properties = dst_inputFile.getProperties() - dst_videoStream = dst_properties.getVideoProperties()[0] + # get dst file + dst_inputFile = av.InputFile( outputFileName ) + dst_properties = dst_inputFile.getProperties() + dst_videoStream = dst_properties.getVideoProperties()[0] - # check output duration - assert_equals( src_videoStream.getDuration() + offset, dst_videoStream.getDuration() ) - assert_equals( src_videoStream.getNbFrames() + ( offset * dst_videoStream.getFps() ), dst_videoStream.getNbFrames() ) + # check output duration + assert_equals( src_videoStream.getDuration() + offset, dst_videoStream.getDuration() ) + # check output duration + assert_equals( src_videoStream.getDuration() + offset, dst_videoStream.getDuration() ) + assert_equals( src_videoStream.getNbFrames() + ( offset * dst_videoStream.getFps() ), dst_videoStream.getNbFrames() ) def testMultipleOffsetFromSameInputFile(): - """ - Process multiple streams with different offset at the beginning of the process. - """ - inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_MOV_FILE'] - outputFileName = "testMultipleOffsetFromSameInputFile.mov" - offset_1 = 10 - offset_2 = 3 - - ouputFile = av.OutputFile( outputFileName ) - transcoder = av.Transcoder( ouputFile ) - - transcoder.add( inputFileName, 0, "", offset_1 ) - transcoder.add( inputFileName, 1, "", offset_2 ) - - progress = av.ConsoleProgress() - transcoder.process( progress ) - - # get src file - src_inputFile = av.InputFile( inputFileName ) - src_properties = src_inputFile.getProperties() - src_videoStream = src_properties.getVideoProperties()[0] - src_audioStream = src_properties.getAudioProperties()[0] - - # get dst file - dst_inputFile = av.InputFile( outputFileName ) - dst_properties = dst_inputFile.getProperties() - dst_videoStream = dst_properties.getVideoProperties()[0] - dst_audioStream = dst_properties.getAudioProperties()[0] + """ + Process multiple streams with different offset at the beginning of the process. + """ + inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_MOV_FILE'] + outputFileName = "testMultipleOffsetFromSameInputFile.mov" + offset_1 = 10 + offset_2 = 3 + + ouputFile = av.OutputFile( outputFileName ) + transcoder = av.Transcoder( ouputFile ) + + transcoder.add( inputFileName, 0, "", offset_1 ) + transcoder.add( inputFileName, 1, "", offset_2 ) + + progress = av.ConsoleProgress() + transcoder.process( progress ) + + # get src file + src_inputFile = av.InputFile( inputFileName ) + src_properties = src_inputFile.getProperties() + src_videoStream = src_properties.getVideoProperties()[0] + src_audioStream = src_properties.getAudioProperties()[0] + + # get dst file + dst_inputFile = av.InputFile( outputFileName ) + dst_properties = dst_inputFile.getProperties() + dst_videoStream = dst_properties.getVideoProperties()[0] + dst_audioStream = dst_properties.getAudioProperties()[0] # check output duration - assert_equals( src_videoStream.getDuration() + offset_1, dst_videoStream.getDuration() ) - assert_equals( src_audioStream.getDuration() + offset_1, dst_audioStream.getDuration() ) + assert_equals( src_videoStream.getDuration() + offset_1, dst_videoStream.getDuration() ) + assert_equals( src_audioStream.getDuration() + offset_1, dst_audioStream.getDuration() ) def testMultipleOffsetFromSameStream(): - """ - Process same stream several times with different offset at the beginning of the process. - """ - inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_MOV_FILE'] - outputFileName = "testMultipleOffsetFromSameStream.mov" - offset_1 = 2 - offset_2 = -2 - - ouputFile = av.OutputFile( outputFileName ) - transcoder = av.Transcoder( ouputFile ) - - transcoder.add( inputFileName, 0, "", offset_1 ) - transcoder.add( inputFileName, 0, "", offset_2 ) - - progress = av.ConsoleProgress() - transcoder.process( progress ) - - # get src file - src_inputFile = av.InputFile( inputFileName ) - src_properties = src_inputFile.getProperties() - src_videoStream = src_properties.getVideoProperties()[0] - - # get dst file - dst_inputFile = av.InputFile( outputFileName ) - dst_properties = dst_inputFile.getProperties() - dst_videoStream_1 = dst_properties.getVideoProperties()[0] - dst_videoStream_2 = dst_properties.getVideoProperties()[1] - - # check output duration - assert_equals( src_videoStream.getDuration() + offset_1, dst_videoStream_1.getDuration() ) - assert_equals( src_videoStream.getDuration() + offset_1, dst_videoStream_2.getDuration() ) - assert_almost_equals( src_videoStream.getNbFrames() + ( offset_1 * dst_videoStream_1.getFps() ), dst_videoStream_1.getNbFrames(), delta=0.01 ) - assert_almost_equals( src_videoStream.getNbFrames() + ( offset_1 * dst_videoStream_2.getFps() ), dst_videoStream_2.getNbFrames(), delta=0.01 ) - + """ + Process same stream several times with different offset at the beginning of the process. + """ + inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_MOV_FILE'] + outputFileName = "testMultipleOffsetFromSameStream.mov" + offset_1 = 2 + offset_2 = -2 + + ouputFile = av.OutputFile( outputFileName ) + transcoder = av.Transcoder( ouputFile ) + + transcoder.add( inputFileName, 0, "", offset_1 ) + transcoder.add( inputFileName, 0, "", offset_2 ) + + progress = av.ConsoleProgress() + transcoder.process( progress ) + + # get src file + src_inputFile = av.InputFile( inputFileName ) + src_properties = src_inputFile.getProperties() + src_videoStream = src_properties.getVideoProperties()[0] + + # get dst file + dst_inputFile = av.InputFile( outputFileName ) + dst_properties = dst_inputFile.getProperties() + dst_videoStream_1 = dst_properties.getVideoProperties()[0] + dst_videoStream_2 = dst_properties.getVideoProperties()[1] + + # check output duration + assert_equals( src_videoStream.getDuration() + offset_1, dst_videoStream_1.getDuration() ) + assert_equals( src_videoStream.getDuration() + offset_1, dst_videoStream_2.getDuration() ) + assert_almost_equals( src_videoStream.getNbFrames() + ( offset_1 * dst_videoStream_1.getFps() ), dst_videoStream_1.getNbFrames(), delta=0.01 ) + assert_almost_equals( src_videoStream.getNbFrames() + ( offset_1 * dst_videoStream_2.getFps() ), dst_videoStream_2.getNbFrames(), delta=0.01 ) diff --git a/test/pyTest/testOutputFile.py b/test/pyTest/testOutputFile.py new file mode 100644 index 00000000..e3c4542c --- /dev/null +++ b/test/pyTest/testOutputFile.py @@ -0,0 +1,71 @@ +from nose.tools import * + +from pyAvTranscoder import avtranscoder as av + +av.preloadCodecsAndFormats() +av.Logger.setLogLevel(av.AV_LOG_QUIET) + + +def testCreateOutputFileWithExtension(): + """ + Create an OutputFile with a filename with extension. + """ + ext = "mov" + outputFileName = "testCreateOutputFileWithExtension." + ext + ouputFile = av.OutputFile( outputFileName ) + + assert_equals( ouputFile.getFilename(), outputFileName ) + assert_equals( ouputFile.getFormatName(), ext ) + + +@raises(IOError) +def testCreateOutputFileWithoutExtension(): + """ + Create an OutputFile with a filename without extension. + """ + outputFileName = "testCreateOutputFileWithoutExtension" + ouputFile = av.OutputFile( outputFileName ) + + assert_equals( ouputFile.getFilename(), outputFileName ) + + +def testCreateOutputFileWithoutExtensionWithFormat(): + """ + Create an OutputFile with a filename without extension. + Indicate the format. + """ + format = "mov" + outputFileName = "testCreateOutputFileWithoutExtensionWithFormat" + ouputFile = av.OutputFile( outputFileName, format ) + + assert_equals( ouputFile.getFilename(), outputFileName ) + assert_equals( ouputFile.getFormatName(), format ) + + +def testCreateOutputFileWithoutExtensionWithMimeType(): + """ + Create an OutputFile with a filename without extension. + Indicate the Mime Type. + """ + mimeType = "application/mp4" + outputFileName = "testCreateOutputFileWithoutExtensionWithMimeType" + ouputFile = av.OutputFile( outputFileName, "", mimeType ) + + assert_equals( ouputFile.getFilename(), outputFileName ) + assert_equals( ouputFile.getFormatMimeType(), mimeType ) + + +def testCreateOutputFileWithoutExtensionWithInconsistentFormatAndMimeType(): + """ + Create an OutputFile with a filename without extension. + Indicate inconsistent format and Mime Type. + The OutputFile should by-pass the Mime Type. + """ + format = "mov" + mimeType = "application/mp4" + outputFileName = "testCreateOutputFileWithoutExtensionWithInconsistentFormatAndMimeType" + ouputFile = av.OutputFile( outputFileName, format, mimeType ) + + assert_equals( ouputFile.getFilename(), outputFileName ) + assert_equals( ouputFile.getFormatName(), format ) + diff --git a/test/pyTest/testProperties.py b/test/pyTest/testProperties.py index 98bdbc2a..f8e69c94 100644 --- a/test/pyTest/testProperties.py +++ b/test/pyTest/testProperties.py @@ -2,8 +2,8 @@ # Check if environment is setup to run the tests if os.environ.get('AVTRANSCODER_TEST_AUDIO_WAVE_FILE') is None or os.environ.get('AVTRANSCODER_TEST_VIDEO_MP4_FILE') is None: - from nose.plugins.skip import SkipTest - raise SkipTest("Need to define environment variables AVTRANSCODER_TEST_AUDIO_WAVE_FILE / AVTRANSCODER_TEST_VIDEO_MP4_FILE") + from nose.plugins.skip import SkipTest + raise SkipTest("Need to define environment variables AVTRANSCODER_TEST_AUDIO_WAVE_FILE / AVTRANSCODER_TEST_VIDEO_MP4_FILE") from nose.tools import * @@ -14,112 +14,112 @@ def testAddMetadataDate(): - """ - Add metadata 'date' to the outputFile. - """ - outputFileName = "testAddMetadataDate.wav" + """ + Add metadata 'date' to the outputFile. + """ + outputFileName = "testAddMetadataDate.wav" - ouputFile = av.OutputFile( outputFileName ) - transcoder = av.Transcoder( ouputFile ) + ouputFile = av.OutputFile( outputFileName ) + transcoder = av.Transcoder( ouputFile ) - # rewrap a stream - transcoder.add( os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE'], 0, "") + # rewrap a stream + transcoder.add( os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE'], 0, "") - # add one metadata - metadata_to_check = ("date", "value") - ouputFile.addMetadata( metadata_to_check[0], metadata_to_check[1] ) + # add one metadata + metadata_to_check = ("date", "value") + ouputFile.addMetadata( metadata_to_check[0], metadata_to_check[1] ) - progress = av.NoDisplayProgress() - transcoder.process( progress ) + progress = av.NoDisplayProgress() + transcoder.process( progress ) - inputFile = av.InputFile( outputFileName ) - inputFile.analyse( progress, av.eAnalyseLevelHeader ) - properties = inputFile.getProperties() + inputFile = av.InputFile( outputFileName ) + inputFile.analyse( progress, av.eAnalyseLevelHeader ) + properties = inputFile.getProperties() - assert_in( metadata_to_check, properties.getMetadatas() ) + assert_in( metadata_to_check, properties.getMetadatas() ) def testAddImpossibleMetadata(): - """ - Can't add an impossible metadata to the outputFile. - """ - outputFileName = "testAddMetadataPlop.wav" + """ + Can't add an impossible metadata to the outputFile. + """ + outputFileName = "testAddMetadataPlop.wav" - ouputFile = av.OutputFile( outputFileName ) - transcoder = av.Transcoder( ouputFile ) + ouputFile = av.OutputFile( outputFileName ) + transcoder = av.Transcoder( ouputFile ) - # rewrap a stream - transcoder.add( os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE'], 0, "") + # rewrap a stream + transcoder.add( os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE'], 0, "") - # add one metadata - metadata_to_check = ("undefinedMetadataKey", "undefinedMetadataValue") - ouputFile.addMetadata( metadata_to_check[0], metadata_to_check[1] ) + # add one metadata + metadata_to_check = ("undefinedMetadataKey", "undefinedMetadataValue") + ouputFile.addMetadata( metadata_to_check[0], metadata_to_check[1] ) - progress = av.NoDisplayProgress() - transcoder.process( progress ) + progress = av.NoDisplayProgress() + transcoder.process( progress ) - inputFile = av.InputFile( outputFileName ) - inputFile.analyse( progress, av.eAnalyseLevelHeader ) - properties = inputFile.getProperties() + inputFile = av.InputFile( outputFileName ) + inputFile.analyse( progress, av.eAnalyseLevelHeader ) + properties = inputFile.getProperties() - assert_not_in( metadata_to_check, properties.getMetadatas() ) + assert_not_in( metadata_to_check, properties.getMetadatas() ) def testCheckVideoProperties(): - """ - Check properties of a video stream. - """ - # get src file - inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_MP4_FILE'] - inputFile = av.InputFile( inputFileName ) - properties = inputFile.getProperties() - videoStream = properties.getVideoProperties()[0] - - expectedTotalBitRate = 3249739 - expectedVideoBitRate = 3247981 - - expectedCodecName = 'h264' - expectedWidth = 1920 - expectedHeight = 1080 - expectedNbFrames = 241 - expectedDuration = 10.04 - expectedFps = 24 - - assert_equals( properties.getBitRate(), expectedTotalBitRate ) - assert_equals( videoStream.getBitRate(), expectedVideoBitRate ) - - assert_equals( videoStream.getCodecName(), expectedCodecName ) - assert_equals( videoStream.getWidth(), expectedWidth ) - assert_equals( videoStream.getHeight(), expectedHeight ) - assert_equals( videoStream.getNbFrames(), expectedNbFrames ) - assert_equals( round(videoStream.getDuration(), 2), expectedDuration ) - assert_equals( videoStream.getFps(), expectedFps ) + """ + Check properties of a video stream. + """ + # get src file + inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_MP4_FILE'] + inputFile = av.InputFile( inputFileName ) + properties = inputFile.getProperties() + videoStream = properties.getVideoProperties()[0] + + expectedTotalBitRate = 3249739 + expectedVideoBitRate = 3247981 + + expectedCodecName = 'h264' + expectedWidth = 1920 + expectedHeight = 1080 + expectedNbFrames = 241 + expectedDuration = 10.04 + expectedFps = 24 + + assert_equals( properties.getBitRate(), expectedTotalBitRate ) + assert_equals( videoStream.getBitRate(), expectedVideoBitRate ) + + assert_equals( videoStream.getCodecName(), expectedCodecName ) + assert_equals( videoStream.getWidth(), expectedWidth ) + assert_equals( videoStream.getHeight(), expectedHeight ) + assert_equals( videoStream.getNbFrames(), expectedNbFrames ) + assert_equals( round(videoStream.getDuration(), 2), expectedDuration ) + assert_equals( videoStream.getFps(), expectedFps ) def testCheckAudioProperties(): - """ - Check properties of an audio stream. - """ - # get src file - inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE'] - inputFile = av.InputFile( inputFileName ) - properties = inputFile.getProperties() - audioStream = properties.getAudioProperties()[0] - - expectedTotalBitRate = 4608040 - expectedAudioBitRate = 4608000 - - expectedCodecName = 'pcm_s16le' - expectedSamples = 5760000 - expectedDuration = 20 - expectedChannels = 6 - expectedChannelLayout = '5.1' - expectedSampleRate = 48000 - - assert_equals( properties.getBitRate(), expectedTotalBitRate ) - assert_equals( audioStream.getBitRate(), expectedAudioBitRate ) - - assert_equals( audioStream.getCodecName(), expectedCodecName ) - assert_equals( audioStream.getNbSamples(), expectedSamples ) - assert_equals( round(audioStream.getDuration(), 2), expectedDuration ) - assert_equals( audioStream.getChannels(), expectedChannels ) - assert_equals( audioStream.getChannelLayout(), expectedChannelLayout ) - assert_equals( audioStream.getSampleRate(), expectedSampleRate ) \ No newline at end of file + """ + Check properties of an audio stream. + """ + # get src file + inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE'] + inputFile = av.InputFile( inputFileName ) + properties = inputFile.getProperties() + audioStream = properties.getAudioProperties()[0] + + expectedTotalBitRate = 4608040 + expectedAudioBitRate = 4608000 + + expectedCodecName = 'pcm_s16le' + expectedSamples = 5760000 + expectedDuration = 20 + expectedChannels = 6 + expectedChannelLayout = '5.1' + expectedSampleRate = 48000 + + assert_equals( properties.getBitRate(), expectedTotalBitRate ) + assert_equals( audioStream.getBitRate(), expectedAudioBitRate ) + + assert_equals( audioStream.getCodecName(), expectedCodecName ) + assert_equals( audioStream.getNbSamples(), expectedSamples ) + assert_equals( round(audioStream.getDuration(), 2), expectedDuration ) + assert_equals( audioStream.getChannels(), expectedChannels ) + assert_equals( audioStream.getChannelLayout(), expectedChannelLayout ) + assert_equals( audioStream.getSampleRate(), expectedSampleRate ) \ No newline at end of file diff --git a/test/pyTest/testSetFrame.py b/test/pyTest/testSetFrame.py index e1dc136e..457e9b18 100644 --- a/test/pyTest/testSetFrame.py +++ b/test/pyTest/testSetFrame.py @@ -7,107 +7,107 @@ def testSetVideoFrame(): - """ - Generate a video stream, and set its frame during process. - """ - - # create output - outputFileName = "testSetVideoFrame.mov" - ouputFile = av.OutputFile( outputFileName ) - - # create video frame and codec - inputVideoCodec = av.VideoCodec( av.eCodecTypeEncoder, "mpeg2video" ); - imageDesc = av.VideoFrameDesc( 1920, 1080, "rgb24" ) - inputVideoCodec.setImageParameters( imageDesc ) - - # create transcoder and add a video stream - transcoder = av.Transcoder( ouputFile ) - transcoder.add( "", 0, "mpeg2", inputVideoCodec ) - videoDecoder = transcoder.getStreamTranscoder( 0 ).getCurrentDecoder() - - # start process - ouputFile.beginWrap() - transcoder.preProcessCodecLatency() - p = av.ConsoleProgress() - - # process 10 frames - nbFrames = 10 - for i in range(0, nbFrames): - transcoder.processFrame() - p.progress( i, nbFrames ) - - # set video frame - frame = av.VideoFrame( imageDesc ) - frame.assign(frame.getSize(), i) - videoDecoder.setNextFrame( frame ) - - # end process - ouputFile.endWrap() - - # get dst file of transcode - dst_inputFile = av.InputFile( outputFileName ) - progress = av.NoDisplayProgress() - dst_inputFile.analyse( progress, av.eAnalyseLevelHeader ) - dst_properties = dst_inputFile.getProperties() - dst_videoStream = dst_properties.getVideoProperties()[0] - - assert_equals( "mpeg2video", dst_videoStream.getCodecName() ) - assert_equals( "MPEG-2 video", dst_videoStream.getCodecLongName() ) - assert_equals( 1920, dst_videoStream.getWidth() ) - assert_equals( 1080, dst_videoStream.getHeight() ) - assert_equals( 16, dst_videoStream.getDar().num ) - assert_equals( 9, dst_videoStream.getDar().den ) + """ + Generate a video stream, and set its frame during process. + """ + + # create output + outputFileName = "testSetVideoFrame.mov" + ouputFile = av.OutputFile( outputFileName ) + + # create video frame and codec + inputVideoCodec = av.VideoCodec( av.eCodecTypeEncoder, "mpeg2video" ); + imageDesc = av.VideoFrameDesc( 1920, 1080, "rgb24" ) + inputVideoCodec.setImageParameters( imageDesc ) + + # create transcoder and add a video stream + transcoder = av.Transcoder( ouputFile ) + transcoder.add( "", 0, "mpeg2", inputVideoCodec ) + videoDecoder = transcoder.getStreamTranscoder( 0 ).getCurrentDecoder() + + # start process + ouputFile.beginWrap() + transcoder.preProcessCodecLatency() + p = av.ConsoleProgress() + + # process 10 frames + nbFrames = 10 + for i in range(0, nbFrames): + transcoder.processFrame() + p.progress( i, nbFrames ) + + # set video frame + frame = av.VideoFrame( imageDesc ) + frame.assign(frame.getSize(), i) + videoDecoder.setNextFrame( frame ) + + # end process + ouputFile.endWrap() + + # get dst file of transcode + dst_inputFile = av.InputFile( outputFileName ) + progress = av.NoDisplayProgress() + dst_inputFile.analyse( progress, av.eAnalyseLevelHeader ) + dst_properties = dst_inputFile.getProperties() + dst_videoStream = dst_properties.getVideoProperties()[0] + + assert_equals( "mpeg2video", dst_videoStream.getCodecName() ) + assert_equals( "MPEG-2 video", dst_videoStream.getCodecLongName() ) + assert_equals( 1920, dst_videoStream.getWidth() ) + assert_equals( 1080, dst_videoStream.getHeight() ) + assert_equals( 16, dst_videoStream.getDar().num ) + assert_equals( 9, dst_videoStream.getDar().den ) def testSetAudioFrame(): - """ - Generate a audio stream, and set its frame during process. - """ - - # create output - outputFileName = "testSetAudioFrame.wav" - ouputFile = av.OutputFile( outputFileName ) - - # create video frame and codec - inputAudioCodec = av.AudioCodec( av.eCodecTypeEncoder, "pcm_s24le" ); - audioDesc = av.AudioFrameDesc( 48000, 1, "s32" ) - inputAudioCodec.setAudioParameters( audioDesc ); - - # create transcoder and add a video stream - transcoder = av.Transcoder( ouputFile ) - transcoder.add( "", 0, "wave24b48kmono", inputAudioCodec ) - audioDecoder = transcoder.getStreamTranscoder( 0 ).getCurrentDecoder() - - # start process - ouputFile.beginWrap() - transcoder.preProcessCodecLatency() - p = av.ConsoleProgress() - - # process 10 frames - nbFrames = 10 - for i in range(0, nbFrames): - transcoder.processFrame() - p.progress( i, nbFrames ) - - # set video frame - frame = av.AudioFrame( audioDesc ) - frame.assign(frame.getSize(), i) - audioDecoder.setNextFrame( frame ) - - # end process - ouputFile.endWrap() - - # get dst file of transcode - dst_inputFile = av.InputFile( outputFileName ) - progress = av.NoDisplayProgress() - dst_inputFile.analyse( progress, av.eAnalyseLevelHeader ) - dst_properties = dst_inputFile.getProperties() - dst_audioStream = dst_properties.getAudioProperties()[0] - - assert_equals( "pcm_s24le", dst_audioStream.getCodecName() ) - assert_equals( "PCM signed 24-bit little-endian", dst_audioStream.getCodecLongName() ) - assert_equals( "s32", dst_audioStream.getSampleFormatName() ) - assert_equals( "signed 32 bits", dst_audioStream.getSampleFormatLongName() ) - assert_equals( 48000, dst_audioStream.getSampleRate() ) - assert_equals( 1, dst_audioStream.getChannels() ) + """ + Generate a audio stream, and set its frame during process. + """ + + # create output + outputFileName = "testSetAudioFrame.wav" + ouputFile = av.OutputFile( outputFileName ) + + # create video frame and codec + inputAudioCodec = av.AudioCodec( av.eCodecTypeEncoder, "pcm_s24le" ); + audioDesc = av.AudioFrameDesc( 48000, 1, "s32" ) + inputAudioCodec.setAudioParameters( audioDesc ); + + # create transcoder and add a video stream + transcoder = av.Transcoder( ouputFile ) + transcoder.add( "", 0, "wave24b48kmono", inputAudioCodec ) + audioDecoder = transcoder.getStreamTranscoder( 0 ).getCurrentDecoder() + + # start process + ouputFile.beginWrap() + transcoder.preProcessCodecLatency() + p = av.ConsoleProgress() + + # process 10 frames + nbFrames = 10 + for i in range(0, nbFrames): + transcoder.processFrame() + p.progress( i, nbFrames ) + + # set video frame + frame = av.AudioFrame( audioDesc ) + frame.assign(frame.getSize(), i) + audioDecoder.setNextFrame( frame ) + + # end process + ouputFile.endWrap() + + # get dst file of transcode + dst_inputFile = av.InputFile( outputFileName ) + progress = av.NoDisplayProgress() + dst_inputFile.analyse( progress, av.eAnalyseLevelHeader ) + dst_properties = dst_inputFile.getProperties() + dst_audioStream = dst_properties.getAudioProperties()[0] + + assert_equals( "pcm_s24le", dst_audioStream.getCodecName() ) + assert_equals( "PCM signed 24-bit little-endian", dst_audioStream.getCodecLongName() ) + assert_equals( "s32", dst_audioStream.getSampleFormatName() ) + assert_equals( "signed 32 bits", dst_audioStream.getSampleFormatLongName() ) + assert_equals( 48000, dst_audioStream.getSampleRate() ) + assert_equals( 1, dst_audioStream.getChannels() ) diff --git a/test/pyTest/testTranscoderAdd.py b/test/pyTest/testTranscoderAdd.py index bd147b59..8754e933 100644 --- a/test/pyTest/testTranscoderAdd.py +++ b/test/pyTest/testTranscoderAdd.py @@ -2,8 +2,8 @@ # Check if environment is setup to run the tests if os.environ.get('AVTRANSCODER_TEST_AUDIO_WAVE_FILE') is None: - from nose.plugins.skip import SkipTest - raise SkipTest("Need to define environment variable AVTRANSCODER_TEST_AUDIO_WAVE_FILE") + from nose.plugins.skip import SkipTest + raise SkipTest("Need to define environment variable AVTRANSCODER_TEST_AUDIO_WAVE_FILE") from nose.tools import * @@ -14,23 +14,23 @@ def testAddStreamTranscoder(): - """ - Add a streamTranscoder to the Transcoder, and process rewrap of an audio stream. - """ - # input - inputFile = av.InputFile( os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE'] ) - inputIndex = 0 - inputFile.activateStream( inputIndex ) - - # output - outputFileName = "testAddStreamTranscoder.avi" - ouputFile = av.OutputFile( outputFileName ) - - streamTranscoder = av.StreamTranscoder( inputFile.getStream( inputIndex ), ouputFile ) - transcoder = av.Transcoder( ouputFile ) - transcoder.add( streamTranscoder) - - # process - progress = av.NoDisplayProgress() - transcoder.process( progress ) + """ + Add a streamTranscoder to the Transcoder, and process rewrap of an audio stream. + """ + # input + inputFile = av.InputFile( os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE'] ) + inputIndex = 0 + inputFile.activateStream( inputIndex ) + + # output + outputFileName = "testAddStreamTranscoder.avi" + ouputFile = av.OutputFile( outputFileName ) + + streamTranscoder = av.StreamTranscoder( inputFile.getStream( inputIndex ), ouputFile ) + transcoder = av.Transcoder( ouputFile ) + transcoder.add( streamTranscoder) + + # process + progress = av.NoDisplayProgress() + transcoder.process( progress ) diff --git a/test/pyTest/testTranscoderDummy.py b/test/pyTest/testTranscoderDummy.py index a210603a..0a4c812c 100644 --- a/test/pyTest/testTranscoderDummy.py +++ b/test/pyTest/testTranscoderDummy.py @@ -8,107 +8,107 @@ @raises(RuntimeError) def testTranscodeNoStream(): - """ - Can't process with no stream. - """ - outputFileName = "testTranscodeNoStream.avi" + """ + Can't process with no stream. + """ + outputFileName = "testTranscodeNoStream.avi" - ouputFile = av.OutputFile( outputFileName ) - transcoder = av.Transcoder( ouputFile ) + ouputFile = av.OutputFile( outputFileName ) + transcoder = av.Transcoder( ouputFile ) - progress = av.NoDisplayProgress() - transcoder.process( progress ) + progress = av.NoDisplayProgress() + transcoder.process( progress ) @raises(RuntimeError) def testRewrapDummy(): - """ - Can't rewrap a dummy stream (no sense). - """ - outputFileName = "testRewrapDummy.avi" + """ + Can't rewrap a dummy stream (no sense). + """ + outputFileName = "testRewrapDummy.avi" - ouputFile = av.OutputFile( outputFileName ) - transcoder = av.Transcoder( ouputFile ) + ouputFile = av.OutputFile( outputFileName ) + transcoder = av.Transcoder( ouputFile ) - transcoder.add( "", 0, "") - transcoder.add( "", 0, -1, "") + transcoder.add( "", 0, "") + transcoder.add( "", 0, -1, "") - progress = av.NoDisplayProgress() - transcoder.process( progress ) + progress = av.NoDisplayProgress() + transcoder.process( progress ) @raises(RuntimeError) def testTranscodeDummyExistingProfileWithNoEssenceDesc(): - """ - Can't add a dummy stream with no essence desc (for encoder). - """ - outputFileName = "testTranscodeDummyExistingProfileWithNoEssenceDesc.avi" + """ + Can't add a dummy stream with no essence desc (for encoder). + """ + outputFileName = "testTranscodeDummyExistingProfileWithNoEssenceDesc.avi" - ouputFile = av.OutputFile( outputFileName ) - transcoder = av.Transcoder( ouputFile ) + ouputFile = av.OutputFile( outputFileName ) + transcoder = av.Transcoder( ouputFile ) - transcoder.add( "", 0, "dnxhd120" ) - transcoder.add( "", 0, -1, "dnxhd120" ) + transcoder.add( "", 0, "dnxhd120" ) + transcoder.add( "", 0, -1, "dnxhd120" ) - progress = av.NoDisplayProgress() - transcoder.process( progress ) + progress = av.NoDisplayProgress() + transcoder.process( progress ) @raises(RuntimeError) def testTranscodeDummyNewProfileWithNoEssenceDesc(): - """ - Can't add a dummy stream with no essence desc (for encoder). - """ - outputFileName = "testTranscodeDummyNewProfileWithNoEssenceDesc.avi" + """ + Can't add a dummy stream with no essence desc (for encoder). + """ + outputFileName = "testTranscodeDummyNewProfileWithNoEssenceDesc.avi" - ouputFile = av.OutputFile( outputFileName ) - transcoder = av.Transcoder( ouputFile ) + ouputFile = av.OutputFile( outputFileName ) + transcoder = av.Transcoder( ouputFile ) - newProfile = { - av.avProfileIdentificator : "newAudioPreset", - av.avProfileIdentificatorHuman : "New audio preset", - av.avProfileType : av.avProfileTypeAudio, - } - transcoder.add( "", 0, newProfile ) - transcoder.add( "", 0, -1, newProfile ) + newProfile = { + av.avProfileIdentificator : "newAudioPreset", + av.avProfileIdentificatorHuman : "New audio preset", + av.avProfileType : av.avProfileTypeAudio, + } + transcoder.add( "", 0, newProfile ) + transcoder.add( "", 0, -1, newProfile ) - progress = av.NoDisplayProgress() - transcoder.process( progress ) + progress = av.NoDisplayProgress() + transcoder.process( progress ) def testTranscodeDummyAudio(): - """ - Process one frame with a dummy audio (profile wave24b48kmono). - """ - outputFileName = "testTranscodeDummyAudio.wav" + """ + Process one frame with a dummy audio (profile wave24b48kmono). + """ + outputFileName = "testTranscodeDummyAudio.wav" - ouputFile = av.OutputFile( outputFileName ) - transcoder = av.Transcoder( ouputFile ) + ouputFile = av.OutputFile( outputFileName ) + transcoder = av.Transcoder( ouputFile ) - # add a dummy video stream - audioCodec = av.AudioCodec( av.eCodecTypeEncoder, "pcm_s16le" ) - audioDesc = av.AudioFrameDesc( 48000, 1, "s16" ) - audioCodec.setAudioParameters( audioDesc ) - transcoder.add( "", 0, "wave24b48kmono", audioCodec ) + # add a dummy video stream + audioCodec = av.AudioCodec( av.eCodecTypeEncoder, "pcm_s16le" ) + audioDesc = av.AudioFrameDesc( 48000, 1, "s16" ) + audioCodec.setAudioParameters( audioDesc ) + transcoder.add( "", 0, "wave24b48kmono", audioCodec ) - ouputFile.beginWrap() - transcoder.processFrame() - ouputFile.endWrap() + ouputFile.beginWrap() + transcoder.processFrame() + ouputFile.endWrap() def testTranscodeDummyVideo(): - """ - Process one frame with a dummy video (profile dnxhd120). - """ - outputFileName = "testTranscodeDummyVideo.avi" + """ + Process one frame with a dummy video (profile dnxhd120). + """ + outputFileName = "testTranscodeDummyVideo.avi" - ouputFile = av.OutputFile( outputFileName ) - transcoder = av.Transcoder( ouputFile ) + ouputFile = av.OutputFile( outputFileName ) + transcoder = av.Transcoder( ouputFile ) - # add a dummy video stream - videoCodec = av.VideoCodec( av.eCodecTypeEncoder, "mpeg2video" ) - imageDesc = av.VideoFrameDesc( 1920, 1080, "yuv422p" ) - videoCodec.setImageParameters( imageDesc ) + # add a dummy video stream + videoCodec = av.VideoCodec( av.eCodecTypeEncoder, "mpeg2video" ) + imageDesc = av.VideoFrameDesc( 1920, 1080, "yuv422p" ) + videoCodec.setImageParameters( imageDesc ) - transcoder.add( "", 0, "dnxhd120", videoCodec ) + transcoder.add( "", 0, "dnxhd120", videoCodec ) - ouputFile.beginWrap() - transcoder.processFrame() - ouputFile.endWrap() + ouputFile.beginWrap() + transcoder.processFrame() + ouputFile.endWrap() diff --git a/test/pyTest/testTranscoderRewrap.py b/test/pyTest/testTranscoderRewrap.py index b36539f0..9f439820 100644 --- a/test/pyTest/testTranscoderRewrap.py +++ b/test/pyTest/testTranscoderRewrap.py @@ -2,8 +2,8 @@ # Check if environment is setup to run the tests if os.environ.get('AVTRANSCODER_TEST_AUDIO_WAVE_FILE') is None or os.environ.get('AVTRANSCODER_TEST_VIDEO_AVI_FILE') is None: - from nose.plugins.skip import SkipTest - raise SkipTest("Need to define environment variables AVTRANSCODER_TEST_VIDEO_AVI_FILE and AVTRANSCODER_TEST_AUDIO_WAVE_FILE") + from nose.plugins.skip import SkipTest + raise SkipTest("Need to define environment variables AVTRANSCODER_TEST_VIDEO_AVI_FILE and AVTRANSCODER_TEST_AUDIO_WAVE_FILE") from nose.tools import * @@ -14,83 +14,83 @@ def testRewrapAudioStream(): - """ - Rewrap one audio stream. - """ - # get src file of wrap - inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE'] - src_inputFile = av.InputFile( inputFileName ) - progress = av.NoDisplayProgress() - src_inputFile.analyse( progress ) - src_properties = src_inputFile.getProperties() - src_audioStream = src_properties.getAudioProperties()[0] - - formatList = src_properties.getFormatName().split(",") - outputFileName = "testRewrapAudioStream." + formatList[0] - ouputFile = av.OutputFile( outputFileName ) - - transcoder = av.Transcoder( ouputFile ) - transcoder.add( inputFileName, 0 ) - transcoder.process( progress ) - - # get dst file of wrap - dst_inputFile = av.InputFile( outputFileName ) - dst_inputFile.analyse( progress, av.eAnalyseLevelHeader ) - dst_properties = dst_inputFile.getProperties() - dst_audioStream = dst_properties.getAudioProperties()[0] - - # check format - assert_equals( src_properties.getFormatName(), dst_properties.getFormatName() ) - assert_equals( src_properties.getFormatLongName(), dst_properties.getFormatLongName() ) - assert_equals( src_properties.getStartTime(), dst_properties.getStartTime() ) - assert_equals( src_properties.getDuration(), dst_properties.getDuration() ) - deltaBitRateAudio = dst_properties.getBitRate() * 0.01 - assert_almost_equals( src_properties.getBitRate(), dst_properties.getBitRate(), delta=deltaBitRateAudio ) - assert_equals( src_properties.getPacketSize(), dst_properties.getPacketSize() ) - - # check audio properties - src_propertiesMap = src_audioStream.getPropertiesAsMap() - dst_propertiesMap = dst_audioStream.getPropertiesAsMap() - for key in src_propertiesMap: - assert_equals( src_propertiesMap[key], dst_propertiesMap[key] ) + """ + Rewrap one audio stream. + """ + # get src file of wrap + inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE'] + src_inputFile = av.InputFile( inputFileName ) + progress = av.NoDisplayProgress() + src_inputFile.analyse( progress ) + src_properties = src_inputFile.getProperties() + src_audioStream = src_properties.getAudioProperties()[0] + + formatList = src_properties.getFormatName().split(",") + outputFileName = "testRewrapAudioStream." + formatList[0] + ouputFile = av.OutputFile( outputFileName ) + + transcoder = av.Transcoder( ouputFile ) + transcoder.add( inputFileName, 0 ) + transcoder.process( progress ) + + # get dst file of wrap + dst_inputFile = av.InputFile( outputFileName ) + dst_inputFile.analyse( progress, av.eAnalyseLevelHeader ) + dst_properties = dst_inputFile.getProperties() + dst_audioStream = dst_properties.getAudioProperties()[0] + + # check format + assert_equals( src_properties.getFormatName(), dst_properties.getFormatName() ) + assert_equals( src_properties.getFormatLongName(), dst_properties.getFormatLongName() ) + assert_equals( src_properties.getStartTime(), dst_properties.getStartTime() ) + assert_equals( src_properties.getDuration(), dst_properties.getDuration() ) + deltaBitRateAudio = dst_properties.getBitRate() * 0.01 + assert_almost_equals( src_properties.getBitRate(), dst_properties.getBitRate(), delta=deltaBitRateAudio ) + assert_equals( src_properties.getPacketSize(), dst_properties.getPacketSize() ) + + # check audio properties + src_propertiesMap = src_audioStream.getPropertiesAsMap() + dst_propertiesMap = dst_audioStream.getPropertiesAsMap() + for key in src_propertiesMap: + assert_equals( src_propertiesMap[key], dst_propertiesMap[key] ) def testRewrapVideoStream(): - """ - Rewrap one video stream. - """ - # get src file of wrap - inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE'] - src_inputFile = av.InputFile( inputFileName ) - progress = av.NoDisplayProgress() - src_inputFile.analyse( progress ) - src_properties = src_inputFile.getProperties() - src_videoStream = src_properties.getVideoProperties()[0] - - formatList = src_properties.getFormatName().split(",") - outputFileName = "testRewrapVideoStream." + formatList[0] - ouputFile = av.OutputFile( outputFileName ) - - transcoder = av.Transcoder( ouputFile ) - transcoder.add( inputFileName, 0 ) - transcoder.process( progress ) - - # get dst file of wrap - dst_inputFile = av.InputFile( outputFileName ) - dst_inputFile.analyse( progress ) - dst_properties = dst_inputFile.getProperties() - dst_videoStream = dst_properties.getVideoProperties()[0] - - # check format - assert_equals( src_properties.getFormatName(), dst_properties.getFormatName() ) - assert_equals( src_properties.getFormatLongName(), dst_properties.getFormatLongName() ) - assert_equals( src_properties.getStartTime(), dst_properties.getStartTime() ) - assert_equals( src_properties.getDuration(), dst_properties.getDuration() ) - deltaBitRateVideo = dst_properties.getBitRate() * 0.15 - assert_almost_equals( src_properties.getBitRate(), dst_properties.getBitRate(), delta=deltaBitRateVideo ) - assert_equals( src_properties.getPacketSize(), dst_properties.getPacketSize() ) - - # check audio properties - src_propertiesMap = src_videoStream.getPropertiesAsMap() - dst_propertiesMap = dst_videoStream.getPropertiesAsMap() - for key in src_propertiesMap: - assert_equals( src_propertiesMap[key], dst_propertiesMap[key] ) + """ + Rewrap one video stream. + """ + # get src file of wrap + inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE'] + src_inputFile = av.InputFile( inputFileName ) + progress = av.NoDisplayProgress() + src_inputFile.analyse( progress ) + src_properties = src_inputFile.getProperties() + src_videoStream = src_properties.getVideoProperties()[0] + + formatList = src_properties.getFormatName().split(",") + outputFileName = "testRewrapVideoStream." + formatList[0] + ouputFile = av.OutputFile( outputFileName ) + + transcoder = av.Transcoder( ouputFile ) + transcoder.add( inputFileName, 0 ) + transcoder.process( progress ) + + # get dst file of wrap + dst_inputFile = av.InputFile( outputFileName ) + dst_inputFile.analyse( progress ) + dst_properties = dst_inputFile.getProperties() + dst_videoStream = dst_properties.getVideoProperties()[0] + + # check format + assert_equals( src_properties.getFormatName(), dst_properties.getFormatName() ) + assert_equals( src_properties.getFormatLongName(), dst_properties.getFormatLongName() ) + assert_equals( src_properties.getStartTime(), dst_properties.getStartTime() ) + assert_equals( src_properties.getDuration(), dst_properties.getDuration() ) + deltaBitRateVideo = dst_properties.getBitRate() * 0.15 + assert_almost_equals( src_properties.getBitRate(), dst_properties.getBitRate(), delta=deltaBitRateVideo ) + assert_equals( src_properties.getPacketSize(), dst_properties.getPacketSize() ) + + # check audio properties + src_propertiesMap = src_videoStream.getPropertiesAsMap() + dst_propertiesMap = dst_videoStream.getPropertiesAsMap() + for key in src_propertiesMap: + assert_equals( src_propertiesMap[key], dst_propertiesMap[key] ) diff --git a/test/pyTest/testTranscoderTranscodeAudioMov.py b/test/pyTest/testTranscoderTranscodeAudioMov.py index 9838dab7..0c8eeda3 100644 --- a/test/pyTest/testTranscoderTranscodeAudioMov.py +++ b/test/pyTest/testTranscoderTranscodeAudioMov.py @@ -2,8 +2,8 @@ # Check if environment is setup to run the tests if os.environ.get('AVTRANSCODER_TEST_AUDIO_MOV_FILE') is None: - from nose.plugins.skip import SkipTest - raise SkipTest("Need to define environment variable AVTRANSCODER_TEST_AUDIO_MOV_FILE") + from nose.plugins.skip import SkipTest + raise SkipTest("Need to define environment variable AVTRANSCODER_TEST_AUDIO_MOV_FILE") from nose.tools import * @@ -14,37 +14,37 @@ def testTranscodeMovVariableNbSamplesPerFrame(): - """ - Transcode the audio stream of a MOV file which contains a video stream. - The number of samples per frame can vary to fit the gop size. - AudioTransform must manage these cases. - """ - inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_MOV_FILE'] - outputFileName = "testTranscodeMovVariableNbSamplesPerFrame.wav" - - ouputFile = av.OutputFile( outputFileName ) - transcoder = av.Transcoder( ouputFile ) - - # create custom profile - customProfile = av.ProfileMap() - customProfile[av.avProfileIdentificator] = "customProfile" - customProfile[av.avProfileIdentificatorHuman] = "custom profile" - customProfile[av.avProfileType] = av.avProfileTypeAudio - customProfile[av.avProfileCodec] = "pcm_s24le" - - inputFile = av.InputFile( inputFileName ) - audioStreamIndex = inputFile.getProperties().getAudioProperties()[0].getStreamIndex() - transcoder.add( inputFileName, audioStreamIndex, customProfile ) - - progress = av.ConsoleProgress() - transcoder.process( progress ) - - # get dst file of transcode - dst_inputFile = av.InputFile( outputFileName ) - dst_inputFile.analyse( progress, av.eAnalyseLevelHeader ) - dst_properties = dst_inputFile.getProperties() - dst_audioStream = dst_properties.getAudioProperties()[0] - - assert_equals( "pcm_s24le", dst_audioStream.getCodecName() ) - assert_equals( "PCM signed 24-bit little-endian", dst_audioStream.getCodecLongName() ) + """ + Transcode the audio stream of a MOV file which contains a video stream. + The number of samples per frame can vary to fit the gop size. + AudioTransform must manage these cases. + """ + inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_MOV_FILE'] + outputFileName = "testTranscodeMovVariableNbSamplesPerFrame.wav" + + ouputFile = av.OutputFile( outputFileName ) + transcoder = av.Transcoder( ouputFile ) + + # create custom profile + customProfile = av.ProfileMap() + customProfile[av.avProfileIdentificator] = "customProfile" + customProfile[av.avProfileIdentificatorHuman] = "custom profile" + customProfile[av.avProfileType] = av.avProfileTypeAudio + customProfile[av.avProfileCodec] = "pcm_s24le" + + inputFile = av.InputFile( inputFileName ) + audioStreamIndex = inputFile.getProperties().getAudioProperties()[0].getStreamIndex() + transcoder.add( inputFileName, audioStreamIndex, customProfile ) + + progress = av.ConsoleProgress() + transcoder.process( progress ) + + # get dst file of transcode + dst_inputFile = av.InputFile( outputFileName ) + dst_inputFile.analyse( progress, av.eAnalyseLevelHeader ) + dst_properties = dst_inputFile.getProperties() + dst_audioStream = dst_properties.getAudioProperties()[0] + + assert_equals( "pcm_s24le", dst_audioStream.getCodecName() ) + assert_equals( "PCM signed 24-bit little-endian", dst_audioStream.getCodecLongName() ) diff --git a/test/pyTest/testTranscoderTranscodeAudioWave.py b/test/pyTest/testTranscoderTranscodeAudioWave.py index 82ab2eea..0d3f036a 100644 --- a/test/pyTest/testTranscoderTranscodeAudioWave.py +++ b/test/pyTest/testTranscoderTranscodeAudioWave.py @@ -2,8 +2,8 @@ # Check if environment is setup to run the tests if os.environ.get('AVTRANSCODER_TEST_AUDIO_WAVE_FILE') is None: - from nose.plugins.skip import SkipTest - raise SkipTest("Need to define environment variable AVTRANSCODER_TEST_AUDIO_WAVE_FILE") + from nose.plugins.skip import SkipTest + raise SkipTest("Need to define environment variable AVTRANSCODER_TEST_AUDIO_WAVE_FILE") from nose.tools import * @@ -14,113 +14,113 @@ def testTranscodeWave24b48k5_1(): - """ - Transcode one audio stream (profile wave24b48k5_1). - """ - inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE'] - outputFileName = "testTranscodeWave24b48k5_1.wav" + """ + Transcode one audio stream (profile wave24b48k5_1). + """ + inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE'] + outputFileName = "testTranscodeWave24b48k5_1.wav" - ouputFile = av.OutputFile( outputFileName ) - transcoder = av.Transcoder( ouputFile ) + ouputFile = av.OutputFile( outputFileName ) + transcoder = av.Transcoder( ouputFile ) - transcoder.add( inputFileName, 0, "wave24b48k5_1" ) + transcoder.add( inputFileName, 0, "wave24b48k5_1" ) - progress = av.ConsoleProgress() - transcoder.process( progress ) + progress = av.ConsoleProgress() + transcoder.process( progress ) - # get dst file of transcode - dst_inputFile = av.InputFile( outputFileName ) - dst_inputFile.analyse( progress, av.eAnalyseLevelHeader ) - dst_properties = dst_inputFile.getProperties() - dst_audioStream = dst_properties.getAudioProperties()[0] + # get dst file of transcode + dst_inputFile = av.InputFile( outputFileName ) + dst_inputFile.analyse( progress, av.eAnalyseLevelHeader ) + dst_properties = dst_inputFile.getProperties() + dst_audioStream = dst_properties.getAudioProperties()[0] - assert_equals( "pcm_s24le", dst_audioStream.getCodecName() ) - assert_equals( "PCM signed 24-bit little-endian", dst_audioStream.getCodecLongName() ) - assert_equals( "s32", dst_audioStream.getSampleFormatName() ) - assert_equals( "signed 32 bits", dst_audioStream.getSampleFormatLongName() ) - assert_equals( 48000, dst_audioStream.getSampleRate() ) - assert_equals( 6, dst_audioStream.getChannels() ) + assert_equals( "pcm_s24le", dst_audioStream.getCodecName() ) + assert_equals( "PCM signed 24-bit little-endian", dst_audioStream.getCodecLongName() ) + assert_equals( "s32", dst_audioStream.getSampleFormatName() ) + assert_equals( "signed 32 bits", dst_audioStream.getSampleFormatLongName() ) + assert_equals( 48000, dst_audioStream.getSampleRate() ) + assert_equals( 6, dst_audioStream.getChannels() ) def testTranscodeWave24b48kstereo(): - """ - Transcode one audio stream (profile wave24b48kstereo). - """ - inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE'] - outputFileName = "testTranscodeWave24b48kstereo.wav" + """ + Transcode one audio stream (profile wave24b48kstereo). + """ + inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE'] + outputFileName = "testTranscodeWave24b48kstereo.wav" - ouputFile = av.OutputFile( outputFileName ) - transcoder = av.Transcoder( ouputFile ) + ouputFile = av.OutputFile( outputFileName ) + transcoder = av.Transcoder( ouputFile ) - transcoder.add( inputFileName, 0, "wave24b48kstereo" ) + transcoder.add( inputFileName, 0, "wave24b48kstereo" ) - progress = av.ConsoleProgress() - transcoder.process( progress ) + progress = av.ConsoleProgress() + transcoder.process( progress ) - # get dst file of transcode - dst_inputFile = av.InputFile( outputFileName ) - dst_inputFile.analyse( progress, av.eAnalyseLevelHeader ) - dst_properties = dst_inputFile.getProperties() - dst_audioStream = dst_properties.getAudioProperties()[0] + # get dst file of transcode + dst_inputFile = av.InputFile( outputFileName ) + dst_inputFile.analyse( progress, av.eAnalyseLevelHeader ) + dst_properties = dst_inputFile.getProperties() + dst_audioStream = dst_properties.getAudioProperties()[0] - assert_equals( "pcm_s24le", dst_audioStream.getCodecName() ) - assert_equals( "PCM signed 24-bit little-endian", dst_audioStream.getCodecLongName() ) - assert_equals( "s32", dst_audioStream.getSampleFormatName() ) - assert_equals( "signed 32 bits", dst_audioStream.getSampleFormatLongName() ) - assert_equals( 48000, dst_audioStream.getSampleRate() ) - assert_equals( 2, dst_audioStream.getChannels() ) + assert_equals( "pcm_s24le", dst_audioStream.getCodecName() ) + assert_equals( "PCM signed 24-bit little-endian", dst_audioStream.getCodecLongName() ) + assert_equals( "s32", dst_audioStream.getSampleFormatName() ) + assert_equals( "signed 32 bits", dst_audioStream.getSampleFormatLongName() ) + assert_equals( 48000, dst_audioStream.getSampleRate() ) + assert_equals( 2, dst_audioStream.getChannels() ) def testTranscodeWave24b48kmono(): - """ - Transcode one audio stream (profile wave24b48kmono). - """ - inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE'] - outputFileName = "testTranscodeWave24b48kmono.wav" + """ + Transcode one audio stream (profile wave24b48kmono). + """ + inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE'] + outputFileName = "testTranscodeWave24b48kmono.wav" - ouputFile = av.OutputFile( outputFileName ) - transcoder = av.Transcoder( ouputFile ) + ouputFile = av.OutputFile( outputFileName ) + transcoder = av.Transcoder( ouputFile ) - transcoder.add( inputFileName, 0, "wave24b48kmono" ) + transcoder.add( inputFileName, 0, "wave24b48kmono" ) - progress = av.ConsoleProgress() - transcoder.process( progress ) + progress = av.ConsoleProgress() + transcoder.process( progress ) - # get dst file of transcode - dst_inputFile = av.InputFile( outputFileName ) - dst_inputFile.analyse( progress, av.eAnalyseLevelHeader ) - dst_properties = dst_inputFile.getProperties() - dst_audioStream = dst_properties.getAudioProperties()[0] + # get dst file of transcode + dst_inputFile = av.InputFile( outputFileName ) + dst_inputFile.analyse( progress, av.eAnalyseLevelHeader ) + dst_properties = dst_inputFile.getProperties() + dst_audioStream = dst_properties.getAudioProperties()[0] - assert_equals( "pcm_s24le", dst_audioStream.getCodecName() ) - assert_equals( "PCM signed 24-bit little-endian", dst_audioStream.getCodecLongName() ) - assert_equals( "s32", dst_audioStream.getSampleFormatName() ) - assert_equals( "signed 32 bits", dst_audioStream.getSampleFormatLongName() ) - assert_equals( 48000, dst_audioStream.getSampleRate() ) - assert_equals( 1, dst_audioStream.getChannels() ) + assert_equals( "pcm_s24le", dst_audioStream.getCodecName() ) + assert_equals( "PCM signed 24-bit little-endian", dst_audioStream.getCodecLongName() ) + assert_equals( "s32", dst_audioStream.getSampleFormatName() ) + assert_equals( "signed 32 bits", dst_audioStream.getSampleFormatLongName() ) + assert_equals( 48000, dst_audioStream.getSampleRate() ) + assert_equals( 1, dst_audioStream.getChannels() ) def testTranscodeWave16b48kmono(): - """ - Transcode one audio stream (profile wave16b48kmono). - """ - inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE'] - outputFileName = "testTranscodeWave16b48kmono.wav" - - ouputFile = av.OutputFile( outputFileName ) - transcoder = av.Transcoder( ouputFile ) - - transcoder.add( inputFileName, 0, "wave16b48kmono" ) - - progress = av.ConsoleProgress() - transcoder.process( progress ) - - # get dst file of transcode - dst_inputFile = av.InputFile( outputFileName ) - dst_inputFile.analyse( progress, av.eAnalyseLevelHeader ) - dst_properties = dst_inputFile.getProperties() - dst_audioStream = dst_properties.getAudioProperties()[0] - - assert_equals( "pcm_s16le", dst_audioStream.getCodecName() ) - assert_equals( "PCM signed 16-bit little-endian", dst_audioStream.getCodecLongName() ) - assert_equals( "s16", dst_audioStream.getSampleFormatName() ) - assert_equals( "signed 16 bits", dst_audioStream.getSampleFormatLongName() ) - assert_equals( 48000, dst_audioStream.getSampleRate() ) - assert_equals( 1, dst_audioStream.getChannels() ) + """ + Transcode one audio stream (profile wave16b48kmono). + """ + inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE'] + outputFileName = "testTranscodeWave16b48kmono.wav" + + ouputFile = av.OutputFile( outputFileName ) + transcoder = av.Transcoder( ouputFile ) + + transcoder.add( inputFileName, 0, "wave16b48kmono" ) + + progress = av.ConsoleProgress() + transcoder.process( progress ) + + # get dst file of transcode + dst_inputFile = av.InputFile( outputFileName ) + dst_inputFile.analyse( progress, av.eAnalyseLevelHeader ) + dst_properties = dst_inputFile.getProperties() + dst_audioStream = dst_properties.getAudioProperties()[0] + + assert_equals( "pcm_s16le", dst_audioStream.getCodecName() ) + assert_equals( "PCM signed 16-bit little-endian", dst_audioStream.getCodecLongName() ) + assert_equals( "s16", dst_audioStream.getSampleFormatName() ) + assert_equals( "signed 16 bits", dst_audioStream.getSampleFormatLongName() ) + assert_equals( 48000, dst_audioStream.getSampleRate() ) + assert_equals( 1, dst_audioStream.getChannels() ) diff --git a/test/pyTest/testTranscoderTranscodeVideo.py b/test/pyTest/testTranscoderTranscodeVideo.py index 5e38d7c8..b5f22006 100644 --- a/test/pyTest/testTranscoderTranscodeVideo.py +++ b/test/pyTest/testTranscoderTranscodeVideo.py @@ -2,8 +2,8 @@ # Check if environment is setup to run the tests if os.environ.get('AVTRANSCODER_TEST_VIDEO_AVI_FILE') is None: - from nose.plugins.skip import SkipTest - raise SkipTest("Need to define environment variable AVTRANSCODER_TEST_VIDEO_AVI_FILE") + from nose.plugins.skip import SkipTest + raise SkipTest("Need to define environment variable AVTRANSCODER_TEST_VIDEO_AVI_FILE") from nose.tools import * @@ -14,120 +14,120 @@ def testTranscodeDnxhd120(): - """ - Transcode one video stream (profile dnxhd120). - """ - inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE'] - outputFileName = "testTranscodeDnxhd120.mxf" - - ouputFile = av.OutputFile( outputFileName ) - transcoder = av.Transcoder( ouputFile ) - - transcoder.add( inputFileName, 0, "dnxhd120" ) - - progress = av.ConsoleProgress() - transcoder.process( progress ) - - # get dst file of transcode - dst_inputFile = av.InputFile( outputFileName ) - dst_inputFile.analyse( progress, av.eAnalyseLevelFirstGop ) - dst_properties = dst_inputFile.getProperties() - dst_videoStream = dst_properties.getVideoProperties()[0] - - assert_equals( "dnxhd", dst_videoStream.getCodecName() ) - assert_equals( "VC3/DNxHD", dst_videoStream.getCodecLongName() ) - expectedBitRate = 120000000 - deltaBitRate = expectedBitRate * 0.05 - assert_almost_equals( expectedBitRate, dst_videoStream.getBitRate(), delta=deltaBitRate ) - assert_equals( "yuv422p", dst_videoStream.getPixelProperties().getPixelName() ) - # assert_equals( 1, dst_videoStream.getGopSize() ) # 1 != 12L + """ + Transcode one video stream (profile dnxhd120). + """ + inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE'] + outputFileName = "testTranscodeDnxhd120.mxf" + + ouputFile = av.OutputFile( outputFileName ) + transcoder = av.Transcoder( ouputFile ) + + transcoder.add( inputFileName, 0, "dnxhd120" ) + + progress = av.ConsoleProgress() + transcoder.process( progress ) + + # get dst file of transcode + dst_inputFile = av.InputFile( outputFileName ) + dst_inputFile.analyse( progress, av.eAnalyseLevelFirstGop ) + dst_properties = dst_inputFile.getProperties() + dst_videoStream = dst_properties.getVideoProperties()[0] + + assert_equals( "dnxhd", dst_videoStream.getCodecName() ) + assert_equals( "VC3/DNxHD", dst_videoStream.getCodecLongName() ) + expectedBitRate = 120000000 + deltaBitRate = expectedBitRate * 0.05 + assert_almost_equals( expectedBitRate, dst_videoStream.getBitRate(), delta=deltaBitRate ) + assert_equals( "yuv422p", dst_videoStream.getPixelProperties().getPixelName() ) + # assert_equals( 1, dst_videoStream.getGopSize() ) # 1 != 12L def testTranscodeDnxhd185(): - """ - Transcode one video stream (profile dnxhd185). - """ - inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE'] - outputFileName = "testTranscodeDnxhd185.mxf" - - ouputFile = av.OutputFile( outputFileName ) - transcoder = av.Transcoder( ouputFile ) - - transcoder.add( inputFileName, 0, "dnxhd185" ) - - progress = av.ConsoleProgress() - transcoder.process( progress ) - - # get dst file of transcode - dst_inputFile = av.InputFile( outputFileName ) - dst_inputFile.analyse( progress, av.eAnalyseLevelHeader ) - dst_properties = dst_inputFile.getProperties() - dst_videoStream = dst_properties.getVideoProperties()[0] - - assert_equals( "dnxhd", dst_videoStream.getCodecName() ) - assert_equals( "VC3/DNxHD", dst_videoStream.getCodecLongName() ) - expectedBitRate = 185000000 - deltaBitRate = expectedBitRate * 0.05 - assert_almost_equals( expectedBitRate, dst_videoStream.getBitRate(), delta=deltaBitRate ) - assert_equals( "yuv422p", dst_videoStream.getPixelProperties().getPixelName() ) - # assert_equals( 1, dst_videoStream.getGopSize() ) # 1 != 12L + """ + Transcode one video stream (profile dnxhd185). + """ + inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE'] + outputFileName = "testTranscodeDnxhd185.mxf" + + ouputFile = av.OutputFile( outputFileName ) + transcoder = av.Transcoder( ouputFile ) + + transcoder.add( inputFileName, 0, "dnxhd185" ) + + progress = av.ConsoleProgress() + transcoder.process( progress ) + + # get dst file of transcode + dst_inputFile = av.InputFile( outputFileName ) + dst_inputFile.analyse( progress, av.eAnalyseLevelHeader ) + dst_properties = dst_inputFile.getProperties() + dst_videoStream = dst_properties.getVideoProperties()[0] + + assert_equals( "dnxhd", dst_videoStream.getCodecName() ) + assert_equals( "VC3/DNxHD", dst_videoStream.getCodecLongName() ) + expectedBitRate = 185000000 + deltaBitRate = expectedBitRate * 0.05 + assert_almost_equals( expectedBitRate, dst_videoStream.getBitRate(), delta=deltaBitRate ) + assert_equals( "yuv422p", dst_videoStream.getPixelProperties().getPixelName() ) + # assert_equals( 1, dst_videoStream.getGopSize() ) # 1 != 12L def testTranscodeDnxhd185x(): - """ - Transcode one video stream (profile dnxhd185x). - """ - inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE'] - outputFileName = "testTranscodeDnxhd185x.mxf" - - ouputFile = av.OutputFile( outputFileName ) - transcoder = av.Transcoder( ouputFile ) - - transcoder.add( inputFileName, 0, "dnxhd185x" ) - - progress = av.ConsoleProgress() - transcoder.process( progress ) - - # get dst file of transcode - dst_inputFile = av.InputFile( outputFileName ) - dst_inputFile.analyse( progress, av.eAnalyseLevelHeader ) - dst_properties = dst_inputFile.getProperties() - dst_videoStream = dst_properties.getVideoProperties()[0] - - assert_equals( "dnxhd", dst_videoStream.getCodecName() ) - assert_equals( "VC3/DNxHD", dst_videoStream.getCodecLongName() ) - expectedBitRate = 185000000 - deltaBitRate = expectedBitRate * 0.05 - assert_almost_equals( expectedBitRate, dst_videoStream.getBitRate(), delta=deltaBitRate ) - assert_equals( "yuv422p10le", dst_videoStream.getPixelProperties().getPixelName() ) - # assert_equals( 1, dst_videoStream.getGopSize() ) # 1 != 12L + """ + Transcode one video stream (profile dnxhd185x). + """ + inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE'] + outputFileName = "testTranscodeDnxhd185x.mxf" + + ouputFile = av.OutputFile( outputFileName ) + transcoder = av.Transcoder( ouputFile ) + + transcoder.add( inputFileName, 0, "dnxhd185x" ) + + progress = av.ConsoleProgress() + transcoder.process( progress ) + + # get dst file of transcode + dst_inputFile = av.InputFile( outputFileName ) + dst_inputFile.analyse( progress, av.eAnalyseLevelHeader ) + dst_properties = dst_inputFile.getProperties() + dst_videoStream = dst_properties.getVideoProperties()[0] + + assert_equals( "dnxhd", dst_videoStream.getCodecName() ) + assert_equals( "VC3/DNxHD", dst_videoStream.getCodecLongName() ) + expectedBitRate = 185000000 + deltaBitRate = expectedBitRate * 0.05 + assert_almost_equals( expectedBitRate, dst_videoStream.getBitRate(), delta=deltaBitRate ) + assert_equals( "yuv422p10le", dst_videoStream.getPixelProperties().getPixelName() ) + # assert_equals( 1, dst_videoStream.getGopSize() ) # 1 != 12L def testTranscodeYUV420(): - """ - Process one video stream (custom profile of encoding, with pixel format YUV420). - """ - inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE'] - outputFileName = "testTranscodeYUV420.avi" - - ouputFile = av.OutputFile( outputFileName ) - transcoder = av.Transcoder( ouputFile ) - - # create custom profile - customProfile = av.ProfileMap() - customProfile[av.avProfileIdentificator] = "customProfile" - customProfile[av.avProfileIdentificatorHuman] = "custom profile" - customProfile[av.avProfileType] = av.avProfileTypeVideo - customProfile[av.avProfileCodec] = "mpeg2video" - customProfile[av.avProfilePixelFormat] = "yuv420p" - - transcoder.add( inputFileName, 0, customProfile ) - - progress = av.ConsoleProgress() - transcoder.process( progress ) - - # get dst file of transcode - dst_inputFile = av.InputFile( outputFileName ) - dst_inputFile.analyse( progress, av.eAnalyseLevelHeader ) - dst_properties = dst_inputFile.getProperties() - dst_videoStream = dst_properties.getVideoProperties()[0] - - assert_equals( "mpeg2video", dst_videoStream.getCodecName() ) - assert_equals( "yuv420p", dst_videoStream.getPixelProperties().getPixelName() ) + """ + Process one video stream (custom profile of encoding, with pixel format YUV420). + """ + inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE'] + outputFileName = "testTranscodeYUV420.avi" + + ouputFile = av.OutputFile( outputFileName ) + transcoder = av.Transcoder( ouputFile ) + + # create custom profile + customProfile = av.ProfileMap() + customProfile[av.avProfileIdentificator] = "customProfile" + customProfile[av.avProfileIdentificatorHuman] = "custom profile" + customProfile[av.avProfileType] = av.avProfileTypeVideo + customProfile[av.avProfileCodec] = "mpeg2video" + customProfile[av.avProfilePixelFormat] = "yuv420p" + + transcoder.add( inputFileName, 0, customProfile ) + + progress = av.ConsoleProgress() + transcoder.process( progress ) + + # get dst file of transcode + dst_inputFile = av.InputFile( outputFileName ) + dst_inputFile.analyse( progress, av.eAnalyseLevelHeader ) + dst_properties = dst_inputFile.getProperties() + dst_videoStream = dst_properties.getVideoProperties()[0] + + assert_equals( "mpeg2video", dst_videoStream.getCodecName() ) + assert_equals( "yuv420p", dst_videoStream.getPixelProperties().getPixelName() )