    if (s->remuxing) {
      avformat_alloc_output_context2(&s->ofmt_ctx, NULL, NULL, s->vid_path);
      assert(s->ofmt_ctx);
  
  #ifdef QCOM2
      s->ofmt_ctx->oformat->flags = AVFMT_TS_NONSTRICT;
  #endif
      s->out_stream = avformat_new_stream(s->ofmt_ctx, NULL);
      assert(s->out_stream);
  
      // set codec correctly
      av_register_all();
 
</s>
    if (s->remuxing) {
      avformat_alloc_output_context2(&s->ofmt_ctx, NULL, NULL, s->vid_path);
      assert(s->ofmt_ctx);
  



      s->out_stream = avformat_new_stream(s->ofmt_ctx, NULL);
      assert(s->out_stream);
  
      // set codec correctly
      av_register_all();
keep keep keep keep replace replace replace keep keep keep keep keep
 Fix random encoder lockups (#2707)

* gbk

* surrrely not

* finalize

* such nuance, such nuisance

* this is done automatically

* add back

* give back 0

* simplify

Co-authored-by: Comma Device <device@comma.ai>
selfdrive/loggerd/encoder.c