@@ -135,7 +135,7 @@ bool CFFMPEG_InputStream::openURL(
135135 if (avformat_open_input (&ctx->pFormatCtx , url.c_str (), nullptr , &options) != 0 )
136136 {
137137 ctx->pFormatCtx = nullptr ;
138- std::cerr << " [CFFMPEG_InputStream::openURL] Cannot open video: " << url << std::endl ;
138+ std::cerr << " [CFFMPEG_InputStream::openURL] Cannot open video: " << url << " \n " ;
139139 return false ;
140140 }
141141
@@ -144,7 +144,7 @@ bool CFFMPEG_InputStream::openURL(
144144 {
145145 std::cerr << " [CFFMPEG_InputStream::openURL] Couldn't find stream "
146146 " information: "
147- << url << std::endl ;
147+ << url << " \n " ;
148148 return false ;
149149 }
150150
@@ -171,7 +171,7 @@ bool CFFMPEG_InputStream::openURL(
171171 }
172172 if (ctx->videoStream == -1 )
173173 {
174- std::cerr << " [CFFMPEG_InputStream::openURL] Didn't find a video stream: " << url << std::endl ;
174+ std::cerr << " [CFFMPEG_InputStream::openURL] Didn't find a video stream: " << url << " \n " ;
175175 return false ;
176176 }
177177
@@ -187,7 +187,7 @@ bool CFFMPEG_InputStream::openURL(
187187#endif
188188 if (codec == nullptr )
189189 {
190- std::cerr << " [CFFMPEG_InputStream::openURL] Codec not found: " << url << std::endl ;
190+ std::cerr << " [CFFMPEG_InputStream::openURL] Codec not found: " << url << " \n " ;
191191 return false ;
192192 }
193193
@@ -197,7 +197,7 @@ bool CFFMPEG_InputStream::openURL(
197197 {
198198 std::cerr << " [CFFMPEG_InputStream::openURL] Cannot alloc avcodec "
199199 " context for: "
200- << url << std::endl ;
200+ << url << " \n " ;
201201 return false ;
202202 }
203203
@@ -207,7 +207,7 @@ bool CFFMPEG_InputStream::openURL(
207207 {
208208 std::cerr << " [CFFMPEG_InputStream::openURL] Failed "
209209 " avcodec_parameters_to_context() for: "
210- << url << std::endl ;
210+ << url << " \n " ;
211211 return false ;
212212 }
213213
@@ -218,7 +218,7 @@ bool CFFMPEG_InputStream::openURL(
218218 // Open codec
219219 if (avcodec_open2 (ctx->pCodecCtx , codec, nullptr ) < 0 )
220220 {
221- std::cerr << " [CFFMPEG_InputStream::openURL] avcodec_open2() failed for: " << url << std::endl ;
221+ std::cerr << " [CFFMPEG_InputStream::openURL] avcodec_open2() failed for: " << url << " \n " ;
222222 return false ;
223223 }
224224
@@ -231,7 +231,7 @@ bool CFFMPEG_InputStream::openURL(
231231 {
232232 std::cerr << " [CFFMPEG_InputStream::openURL] Could not alloc memory "
233233 " for frame buffers: "
234- << url << std::endl ;
234+ << url << " \n " ;
235235 return false ;
236236 }
237237
@@ -247,7 +247,7 @@ bool CFFMPEG_InputStream::openURL(
247247 {
248248 std::cerr << " [CFFMPEG_InputStream::openURL] av_image_get_buffer_size "
249249 " error code: "
250- << numBytes << std::endl ;
250+ << numBytes << " \n " ;
251251 return false ;
252252 }
253253
@@ -278,8 +278,7 @@ void CFFMPEG_InputStream::close()
278278 // Close the codec
279279 if (ctx->pCodecCtx )
280280 {
281- avcodec_close (ctx->pCodecCtx );
282- ctx->pCodecCtx = nullptr ;
281+ avcodec_free_context (&ctx->pCodecCtx );
283282 }
284283
285284 // Close the video file
@@ -356,9 +355,9 @@ bool CFFMPEG_InputStream::retrieveFrame(mrpt::img::CImage& out_img, int64_t& out
356355 int ret = avcodec_send_packet (ctx->pCodecCtx , &packet);
357356 if (ret < 0 )
358357 {
359- std::cerr << std::endl
360- << " [CFFMPEG_InputStream] avcodec_send_packet error code=" << ret << std::endl
361- << std::endl ;
358+ std::cerr << " \n "
359+ << " [CFFMPEG_InputStream] avcodec_send_packet error code=" << ret << " \n "
360+ << " \n " ;
362361 return false ;
363362 }
364363 while (ret >= 0 )
@@ -370,11 +369,11 @@ bool CFFMPEG_InputStream::retrieveFrame(mrpt::img::CImage& out_img, int64_t& out
370369 return false ;
371370 else if (ret < 0 )
372371 {
373- std::cerr << std::endl
372+ std::cerr << " \n "
374373 << " [CFFMPEG_InputStream] avcodec_receive_frame "
375374 " error code="
376- << ret << std::endl
377- << std::endl ;
375+ << ret << " \n "
376+ << " \n " ;
378377 return false ;
379378 }
380379
@@ -401,8 +400,8 @@ bool CFFMPEG_InputStream::retrieveFrame(mrpt::img::CImage& out_img, int64_t& out
401400
402401 // std::cout << "[retrieveFrame] Generating image: " <<
403402 // ctx->pCodecPars->width << "x" << ctx->pCodecPars->height
404- // << std::endl ; std::cout << " linsize: " <<
405- // ctx->pFrameRGB->linesize[0] << std::endl ;
403+ // << "\n" ; std::cout << " linsize: " <<
404+ // ctx->pFrameRGB->linesize[0] << "\n" ;
406405
407406 if (ctx->pFrameRGB ->linesize [0 ] != ((m_grab_as_grayscale ? 1 : 3 ) * width))
408407 THROW_EXCEPTION (" FIXME: linesize!=width case not handled yet." );
0 commit comments