ffmpeg在退出是,偶尔崩溃

在rockchip上调试ffmpeg,播10次左右会一有一次在退出时,出现segment fault。

查了很久,释放流程都是对的。

最后增加延时做调试手段,看具体在那里出现;不在出现崩溃。最后锁定应该是在videoctx释放的时候需要增加延时。

MTV_LOGI("Decode thread Exit4");
  	if(is->audio_swr_ctx)
  	{
  		swr_close(is->audio_swr_ctx);
  		swr_free(&is->audio_swr_ctx);
  		is->audio_swr_ctx=NULL;
  	}
  	MTV_LOGI("Decode thread Exit5");
  	if( is->audio_ctx)
  	{
  		  		
  			avcodec_close(is->audio_ctx);
  			avcodec_free_context(&is->audio_ctx);
  			is->audio_ctx=NULL;
  			packet_queue_exit(&is->audioq);
  			
  	}
  	MTV_LOGI("Decode thread Exit6");
DecodeThread_Error5:		
		if(is->video_ctx)
		{
    	avcodec_close(is->video_ctx);
    	
  	}
  	SDL_Delay(100);
DecodeThread_Error4:  
		MTV_LOGI("Decode thread Exit7");  
		 if(is->hw_device_ctx)
	  {
	 		av_buffer_unref(&is->hw_device_ctx); 
    	is->hw_device_ctx=NULL;
  	} 
  	SDL_Delay(100);
DecodeThread_Error3:  
		MTV_LOGI("Decode thread Exit8"); 
		if(is->video_ctx)
		{
	    avcodec_free_context(&is->video_ctx);
	    is->video_ctx=NULL;
  	}
  	MTV_LOGI("Decode thread Exit9");
  	//SDL_Delay(100);
  	packet_queue_exit(&is->videoq);
  	//SDL_Delay(100);
  	MTV_LOGI("Decode thread Exit10");
  	//SDL_Delay(100);
DecodeThread_Error2:
		MTV_LOGI("Decode thread Exit11");
		//SDL_Delay(100);
    avformat_close_input(&is->pFormatCtx);    
    ///SDL_Delay(100);
    is->pFormatCtx=NULL;
    MTV_LOGI("All Decode Data release");

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值