@@ -28,23 +28,6 @@ namespace ffmpegcpp
2828 }
2929
3030 codecContext->framerate = stream->avg_frame_rate ;
31- }
32-
33- InputStream::~InputStream ()
34- {
35- CleanUp ();
36- }
37-
38- void InputStream::ConfigureCodecContext ()
39- {
40- // does nothing by default
41- }
42-
43- void InputStream::Open (FrameSink* frameSink)
44- {
45- output = frameSink->CreateStream ();
46-
47- const AVCodec* codec = codecContext->codec ;
4831
4932 // Copy codec parameters from input stream to output codec context
5033 int ret;
@@ -76,6 +59,21 @@ namespace ffmpegcpp
7659 }
7760 }
7861
62+ InputStream::~InputStream ()
63+ {
64+ CleanUp ();
65+ }
66+
67+ void InputStream::ConfigureCodecContext ()
68+ {
69+ // does nothing by default
70+ }
71+
72+ void InputStream::Open (FrameSink* frameSink)
73+ {
74+ output = frameSink->CreateStream ();
75+ }
76+
7977 void InputStream::CleanUp ()
8078 {
8179 if (codecContext != nullptr )
@@ -158,13 +156,26 @@ namespace ffmpegcpp
158156 // push the frame to the next stage.
159157 // The time_base is filled in in the codecContext after the first frame is decoded
160158 // so we can fetch it from there.
161- output->WriteFrame (frame, metaData);
159+ if (output == nullptr )
160+ {
161+ // No frame sink specified - just release the frame again.
162+ }
163+ else
164+ {
165+ output->WriteFrame (frame, metaData);
166+ }
167+ ++nFramesProcessed;
162168 }
163169 }
164170
171+ int InputStream::GetFramesProcessed ()
172+ {
173+ return nFramesProcessed;
174+ }
175+
165176 void InputStream::Close ()
166177 {
167- output->Close ();
178+ if (output != nullptr ) output->Close ();
168179 }
169180
170181 bool InputStream::IsPrimed ()
0 commit comments