<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head><body><div>apologies again for top posting. first take the original critcal packets, either sudio or video, decode them to determine the ecoder settings you need to mimic. it would be specifying profile level and size for vid, and sample rate with channle layout for audio. apply them to the opening encoder contexts. of couse then, the processing frames are the right size and rates. if you need to change color space or down sample to mono for echo cancellation, you need to return to the original formats and then encode. your concern about changed sps and pps is specific to the continer.  you appear to be targeting mp4, in which case closing the file after processing some segment should work for you. watch your timestamps so that they do not lose context when psssing through the processsing</div><div><br></div><div><br></div><div><br></div><div id="composer_signature"><div style="font-size:85%;color:#575757" dir="auto">Sent from my T-Mobile 4G LTE Device</div></div><div><br></div><div style="font-size:100%;color:#000000"><!-- originalMessage --><div>-------- Original message --------</div><div>From: YIRAN LI <mrfun.china@gmail.com> </div><div>Date: 4/12/17  6:06 PM  (GMT-08:00) </div><div>To: "This list is about using libavcodec, libavformat, libavutil, libavdevice and libavfilter." <libav-user@ffmpeg.org> </div><div>Subject: Re: [Libav-user] re-encoding and transcode (codec copy) on same      file. </div><div><br></div></div><div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_extra"><br><div class="gmail_quote">2017-04-12 0:55 GMT+10:00 Andy Shaules <span dir="ltr"><<a href="mailto:bowljoman@gmail.com" target="_blank">bowljoman@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000"><div><div class="h5">
    <div class="m_7542727182704681097moz-cite-prefix">On 4/10/2017 4:37 PM, YIRAN LI wrote:<br>
    </div>
    <blockquote type="cite">
      <div dir="ltr">
        <div style="font-family:georgia,serif"><br>
        </div>
        <div class="gmail_extra"><br>
          <div class="gmail_quote">2017-04-10 7:16 GMT+10:00 bowljoman <span dir="ltr"><<a href="mailto:bowljoman@gmail.com" target="_blank">bowljoman@gmail.com</a>></span>:<br>
            <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div>
                <div><br>
                </div>
                <div>sorry if this client top posts, but to answer, you
                  can do 1 of 2 things. assume it is different and
                  insert it before returning to the unprocessed clip. or
                  you can check if they are different by doing a
                  comparison.</div>
                <div><br>
                </div>
                <div><br>
                </div>
              </div>
            </blockquote>
            <div style="font-family:georgia,serif">​Thanks
              for your suggestion. Let's say if original H.264 video
              stream has AVCC bitstream, no matter you encode 1st part
              with Annex-b or AVCC, as long as it's different from
              orginal format, I won't be able to do codec copy using
              readpacket/writepacket, right?</div>
            <div style="font-family:georgia,serif"><br>
            </div>
            <div style="font-family:georgia,serif">Thanks</div>
            <div style="font-family:georgia,serif">​</div>
            <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div>
                <div id="m_7542727182704681097m_4628897242784796917composer_signature">
                  <div style="font-size:85%;color:#575757" dir="auto">Sent
                    from my T-Mobile 4G LTE Device</div>
                </div>
                <span>
                  <div><br>
                  </div>
                  <div style="font-size:100%;color:#000000">
                    <div>-------- Original message --------</div>
                    <div>From: YIRAN LI <<a href="mailto:mrfun.china@gmail.com" target="_blank">mrfun.china@gmail.com</a>> </div>
                    <div>Date: 4/7/17 3:15 PM (GMT-08:00) </div>
                    <div>To: "This list is about using libavcodec,
                      libavformat, libavutil, libavdevice and
                      libavfilter." <<a href="mailto:libav-user@ffmpeg.org" target="_blank">libav-user@ffmpeg.org</a>>,
                      FFmpeg user questions <<a href="mailto:ffmpeg-user@ffmpeg.org" target="_blank">ffmpeg-user@ffmpeg.org</a>> </div>
                    <div>Subject: [Libav-user] re-encoding and transcode
                      (codec copy) on same file. </div>
                    <div><br>
                    </div>
                  </div>
                  <div dir="ltr">
                    <div style="font-family:georgia,serif">Hi guys,</div>
                    <div style="font-family:georgia,serif"><br>
                    </div>
                    <div style="font-family:georgia,serif">I'm
                      investigating if it's possible to do editing and
                      transcode on same file.</div>
                    <div style="font-family:georgia,serif"><br>
                    </div>
                    <div style="font-family:georgia,serif">I mean use
                      -vcodec copy, we can readout packets and write
                      them directly into output file without
                      re-encoding. But if it's possible, for example if
                      I have a 2 mins video, re-encode 1st min because
                      there're some effects applied to that region but
                      copy 2nd part?</div>
                    <div style="font-family:georgia,serif"><br>
                    </div>
                    <div style="font-family:georgia,serif">My concern
                      is, for example we know H.264 has extradata, if I
                      re-encode first part but keep 2nd part, how if new
                      extradata is different from old extradta?</div>
                    <div style="font-family:georgia,serif"><br>
                    </div>
                    <div style="font-family:georgia,serif">Anyone have
                      suggestion on this? and any other possible
                      problems doing this?</div>
                    <div style="font-family:georgia,serif"><br>
                    </div>
                    <div style="font-family:georgia,serif">Thanks</div>
                  </div>
                </span></div>
              <br>
              ______________________________<wbr>_________________<br>
              Libav-user mailing list<br>
              <a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
              <a href="http://ffmpeg.org/mailman/listinfo/libav-user" rel="noreferrer" target="_blank">http://ffmpeg.org/mailman/list<wbr>info/libav-user</a><br>
              <br>
            </blockquote>
          </div>
          <br>
        </div>
      </div>
      <br>
      <fieldset class="m_7542727182704681097mimeAttachmentHeader"></fieldset>
      <br>
      <pre>______________________________<wbr>_________________
Libav-user mailing list
<a class="m_7542727182704681097moz-txt-link-abbreviated" href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a>
<a class="m_7542727182704681097moz-txt-link-freetext" href="http://ffmpeg.org/mailman/listinfo/libav-user" target="_blank">http://ffmpeg.org/mailman/<wbr>listinfo/libav-user</a>
</pre>
    </blockquote>
    </div></div><p>It doesnt matter what the inputs are. just convert them to one or
      the other type. the final stream can be assembled with all avc or
      avcc packets. choose one or the other.<br></p></div></blockquote><div><br></div><div class="gmail_default" style="font-family:georgia,serif">​Thanks for reply.</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">I did some research yesterday and I think no matter packets in the file is in starting code (annex-b) or size​ (avcc) mode, I can always detect and convert it to another mode.</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">The problem is, if I re-encode a part and keep another part, how can I guarantee the SPS/PPS values for 2 parts are same? If they are different, even if they are in packets (in-band) instead of in global header, is such a file standard compliant ?</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">Thanks</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000"><p>
    </p>
  </div>

<br>______________________________<wbr>_________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org">Libav-user@ffmpeg.org</a><br>
<a href="http://ffmpeg.org/mailman/listinfo/libav-user" rel="noreferrer" target="_blank">http://ffmpeg.org/mailman/<wbr>listinfo/libav-user</a><br>
<br></blockquote></div><br></div></div>
</body></html>