samleoqh / IssueTracker

Personal daily programming issue tracking
MIT License
0 stars 0 forks source link

freeze/hang inside avcodec_encode_video2() at random #3

Open samleoqh opened 7 years ago

samleoqh commented 7 years ago

during encoding frame, when calling coding avcodec_encode_video2() , it hangs sometimes / freezed at random position (#500 to #30000 frame), not every time, no any regulation, just stop there not any return, stuck this function call. win10 64bit, ffmpeg latest version

samleoqh commented 7 years ago

test 2 solutions 1) remove the "zerolatency" setting of "tune", call av_opt_set() 2) or set thread = 1, prevent multi thread, ctx->thread_count=1

also try to call avcodec_flush_buffers(vidCodeCtx) before encode, seemed not work.

samleoqh commented 7 years ago

useful link: http://stackoverflow.com/questions/33624016/why-sliced-thread-affect-so-much-on-realtime-encoding-using-ffmpeg-x264 i just guess it's the thread conflict caused the stuck inside avcodec_encode_video2(),

when i fix the thread_count =1, no stuck happened, but the encoding speed become lower

samleoqh commented 7 years ago

static int x264_param_apply_tune( x264_param_t param, const char tune ) { ....

   else if( !strncasecmp( s, "zerolatency", 11 ) )//关闭b帧
    {
        param->rc.i_lookahead = 0;
        param->i_sync_lookahead = 0;
        param->i_bframe = 0; // 关闭b帧
        param->b_sliced_threads = 1;  // 限制slice thread
        param->b_vfr_input = 0;
        param->rc.b_mb_tree = 0;
    }

}