title: ffmpeg stream offset command (-itsoffset) not working
body: <p>I would really appreciate if someone could give some pointers regarding the use of itsoffset with ffmpeg.  I have read a number of posts on this subject, some of them explain very clearly how to re-synchronize audio and video with -itsoffset, but I haven't been able to make it work.
  My avi file is encoded with ffmpeg, in two passes, using the following command for the second pass:</p>
  
  <pre><code>ffmpeg -i whole-vts_01.avs -pass 2 -y -vcodec libxvid -vtag XVID -b:v 1300K -g 240 -trellis 2 -mbd rd -flags +mv4+aic -acodec ac3 -ac 2 -ar 48000 -b:a 128k output.avi
  </code></pre>
  
  <p>For whatever reason, I end up with a 1 sec delay in the video (or the audio is 1 sec early). It doesn't happen too often but I see it from time to time.
  Among other attempts, I have tried the following:</p>
  
  <pre><code>(1) ffmpeg -i output.avi -itsoffset 00:00:01.0 -i output.avi -vcodec copy -acodec copy -map 0:0 -map 1:1 output-resynched.avi
  (2) ffmpeg -i output.avi -itsoffset 00:00:01.0 -i output.ac3 -vcodec copy -acodec copy -map 0:0 -map 1:0 output-resynched2.avi
  (3) ffmpeg -itsoffset -00:00:01.00 -i output.avi output-resynched8.avi
  (4) ffmpeg -i output.avi -itsoffset -1.0 -i output.avi -vcodec copy -acodec copy -map 0:1 -map 1:0 output-resynched13.avi
  </code></pre>
  
  <p>Here are the results:</p>
  
  <ol>
  <li>Audio garbled and only 5m 35 s long vs. 1h 41m.</li>
  <li>(Output.ac3 is audio component of output.avi) Video and audio
  identical to original, offset didn't work </li>
  <li>Audio did get shifted, but original encoding parameters replaced with default ones (as expected).    </li>
  <li>Audio garbled and only 9m 56s long vs. 1h 41m.</li>
  </ol>
  
  <p>I see that many people explain, and apparently use the process described above, but it doesn't seem to be working for me.  Am I missing something obvious?  I would very much like to be able to use -itsoffset as it is cleaner than my workaround solution.</p>
  
  <p>FWIW, here is a different, and longer way of obtaining the desired result:</p>
  
  <p>First create a shifted video only file using -ss:</p>
  
  <pre><code>ffmpeg -i output.avi -ss 1.0 -vcodec copy -an oupput_videoshifted.avi
  </code></pre>
  
  <p>Then extract the audio:</p>
  
  <pre><code>ffmpeg -i output.avi -vn -acodec copy outputaudioonly.ac3
  </code></pre>
  
  <p>And finally remux both components:</p>
  
  <pre><code>ffmpeg -i output_videoshifted.avi -i output_audioonly.ac3 -vcodec copy -acodec copy -map 0:0 -map 1:0 output-resynched14.avi
  </code></pre>
  
  <p>The process works, is fast enough, but I would really prefer to use the one pass -itsoffset solution.</p>