File tree Expand file tree Collapse file tree 3 files changed +13
-3
lines changed
src/AvTranscoder/mediaProperty Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -167,7 +167,10 @@ size_t AudioProperties::getNbSamples() const
167
167
{
168
168
if ( ! _formatContext )
169
169
throw std::runtime_error ( " unknown format context" );
170
- return _formatContext->streams [_streamIndex]->nb_frames ;
170
+ size_t nbSamples = _formatContext->streams [_streamIndex]->nb_frames ;
171
+ if (nbSamples == 0 )
172
+ nbSamples = getSampleRate () * getChannels () * getDuration ();
173
+ return nbSamples;
171
174
}
172
175
173
176
size_t AudioProperties::getTicksPerFrame () const
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ class AvExport AudioProperties : public StreamProperties
26
26
size_t getSampleRate () const ;
27
27
size_t getChannels () const ;
28
28
size_t getBitRate () const ; // /< 0 if unknown
29
- size_t getNbSamples () const ; // /< 0 if unknown
29
+ size_t getNbSamples () const ;
30
30
31
31
size_t getTicksPerFrame () const ;
32
32
Original file line number Diff line number Diff line change @@ -50,7 +50,14 @@ def testNbSamplesAudioTranscode():
50
50
ouputFile = av .OutputFile ( outputFileName )
51
51
transcoder = av .Transcoder ( ouputFile )
52
52
53
- transcoder .add ( inputFileName , 0 , "wave24b48kmono" )
53
+ # create custom profile
54
+ customProfile = av .ProfileMap ()
55
+ customProfile [av .avProfileIdentificator ] = "customProfile"
56
+ customProfile [av .avProfileIdentificatorHuman ] = "custom profile"
57
+ customProfile [av .avProfileType ] = av .avProfileTypeAudio
58
+ customProfile [av .avProfileCodec ] = "pcm_s16le"
59
+
60
+ transcoder .add ( inputFileName , 0 , customProfile )
54
61
55
62
progress = av .ConsoleProgress ()
56
63
transcoder .process ( progress )
You can’t perform that action at this time.
0 commit comments