Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix: number of samples computing into AudioProperties#318

New issue

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

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

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletionsrc/AvTranscoder/properties/AudioProperties.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -140,7 +140,7 @@ size_t AudioProperties::getNbSamples() const
throwstd::runtime_error("unknown format context");
size_t nbSamples = _formatContext->streams[_streamIndex]->nb_frames;
if(nbSamples ==0)
nbSamples =getSampleRate() *getNbChannels() *getDuration();
nbSamples =getSampleRate() *getDuration();
return nbSamples;
}

Expand Down
2 changes: 1 addition & 1 deletionsrc/AvTranscoder/properties/AudioProperties.hpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,7 +22,7 @@ class AvExport AudioProperties : public StreamProperties
size_tgetBitRate()const;///< in bits/s, 0 if unknown
size_tgetSampleRate()const;
size_tgetNbChannels()const;
size_tgetNbSamples()const;///<All the channels are included.
size_tgetNbSamples()const;///<For one channel.

size_tgetTicksPerFrame()const;

Expand Down
36 changes: 33 additions & 3 deletionstest/pyTest/testNbSamples.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,12 +10,12 @@
from pyAvTranscoder import avtranscoder as av


deftestNbSamplesAudioRewrap():
deftestNbSamplesAudioRewrapFromWav():
"""
Rewrap one audio stream, check nb samples.
Rewrap one audio stream from WAV file, check nb samples.
"""
inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE']
outputFileName = "testNbSamplesAudioRewrap.wav"
outputFileName = "testNbSamplesAudioRewrapFromWav.wav"

ouputFile = av.OutputFile( outputFileName )
transcoder = av.Transcoder( ouputFile )
Expand All@@ -36,6 +36,35 @@ def testNbSamplesAudioRewrap():
dst_audioStream = dst_properties.getAudioProperties()[0]

assert_equals( src_audioStream.getNbSamples(), dst_audioStream.getNbSamples() )
assert_equals( src_audioStream.getNbSamples(), src_audioStream.getSampleRate() * src_audioStream.getDuration() )

def testNbSamplesAudioRewrapFromMov():
"""
Rewrap one audio stream from MOV file, check nb samples.
"""
inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_MOV_FILE']
outputFileName = "testNbSamplesAudioRewrapFromMov.wav"

ouputFile = av.OutputFile( outputFileName )
transcoder = av.Transcoder( ouputFile )

transcoder.addStream( av.InputStreamDesc(inputFileName, 1) )

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 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(), src_audioStream.getSampleRate() * src_audioStream.getDuration() )

def testNbSamplesAudioTranscode():
"""
Expand DownExpand Up@@ -70,3 +99,4 @@ def testNbSamplesAudioTranscode():
dst_audioStream = dst_properties.getAudioProperties()[0]

assert_equals( src_audioStream.getNbSamples(), dst_audioStream.getNbSamples() )
assert_equals( src_audioStream.getNbSamples(), src_audioStream.getSampleRate() * src_audioStream.getDuration() )
4 changes: 2 additions & 2 deletionstest/pyTest/testOffset.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -103,7 +103,7 @@ def testRewrapAudioPositiveOffset():

# check output duration
assert_equals(src_audioStream.getDuration()+offset,dst_audioStream.getDuration() )
assert_equals(src_audioStream.getNbSamples()+ (offset*dst_audioStream.getSampleRate()*dst_audioStream.getNbChannels()),dst_audioStream.getNbSamples() )
assert_equals(src_audioStream.getNbSamples()+ (offset*dst_audioStream.getSampleRate() ),dst_audioStream.getNbSamples() )


deftestRewrapAudioNegativeOffset():
Expand DownExpand Up@@ -134,7 +134,7 @@ def testRewrapAudioNegativeOffset():

# check output duration
assert_equals(src_audioStream.getDuration()+offset,dst_audioStream.getDuration() )
assert_equals(src_audioStream.getNbSamples()+ (offset*dst_audioStream.getSampleRate()*dst_audioStream.getNbChannels()),dst_audioStream.getNbSamples() )
assert_equals(src_audioStream.getNbSamples()+ (offset*dst_audioStream.getSampleRate() ),dst_audioStream.getNbSamples() )


# # The output video stream has not the correct duration.
Expand Down
5 changes: 3 additions & 2 deletionstest/pyTest/testProperties.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -150,11 +150,11 @@ def testCheckAudioProperties():
expectedAudioBitRate = 4608000

expectedCodecName = 'pcm_s16le'
expectedSamples = 5760000
expectedDuration = 20
expectedChannels = 6
expectedChannelLayout = '5.1'
expectedSampleRate = 48000
expectedSamples = expectedSampleRate * expectedDuration;

assert_equals( properties.getBitRate(), expectedTotalBitRate )
assert_equals( audioStream.getBitRate(), expectedAudioBitRate )
Expand All@@ -177,4 +177,5 @@ def testCheckFilePropertiesAsJson():

import json
# json.loads method throws a ValueError if it is not a valid JSON.
json.loads(inputFile.getProperties().allPropertiesAsJson())
jsonProps = json.loads(inputFile.getProperties().allPropertiesAsJson())
print(jsonProps)

[8]ページ先頭

©2009-2025 Movatter.jp