title: distorted video during ffmpeg h264 video with audio recording
body: <p>I am continuously recording a video with audio from an ip camera using ffmpeg. I am getting a distorted video when I get in to the picture. If the background is still, the video looks normal, but as soon as I step in to the picture, I see myself only being distorted while the background stays intact. If anyone went through this issue, I would really appreciate your help. Here is a command that I am using:</p>
  
  <pre><code>ffmpeg -i rtsp://admin:admin@192.168.1.9/mpeg4 -map 0 -c:v libx264 -c:a aac -pix_fmt yuv420p -f segment -segment_time 60 -segment_wrap 10 -reset_timestamps 1 %d.mp4
  </code></pre>
  
  <p>This is a ffmpeg command output:</p>
  
  <pre><code>ffmpeg version 3.4.1 Copyright (c) 2000-2017 the FFmpeg developers
  
  built with Apple LLVM version 9.0.0 (clang-900.0.39.2)
  
   configuration: --prefix=/usr/local/Cellar/ffmpeg/3.4.1 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfontconfig --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma --enable-nonfree
  
  libavutil      55. 78.100 / 55. 78.100
  
  libavcodec     57.107.100 / 57.107.100
  
  libavformat    57. 83.100 / 57. 83.100
  
  libavdevice    57. 10.100 / 57. 10.100
  
  libavfilter     6.107.100 /  6.107.100
  
  libavresample   3.  7.  0 /  3.  7.  0
  
  libswscale      4.  8.100 /  4.  8.100
  
  libswresample   2.  9.100 /  2.  9.100
  
  libpostproc    54.  7.100 / 54.  7.100
  </code></pre>
  
  <p>Guessed Channel Layout for Input Stream #0.1 : mono</p>
  
  <pre><code>Input #0, rtsp, from 'rtsp://admin:admin@192.168.1.9/mpeg4':
  </code></pre>
  
  <p>Metadata:</p>
  
  <pre><code>title           : My MPEG4 Session
  
  comment         : My MPEG4 info
  </code></pre>
  
  <p>Duration: N/A, start: 0.000000, bitrate: N/A</p>
  
  <pre><code>Stream #0:0: Video: mpeg4 (Simple Profile), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 30 tbr, 90k tbn, 30k tbc
  
  Stream #0:1: Audio: pcm_mulaw, 8000 Hz, mono, s16, 64 kb/s
  </code></pre>
  
  <p>Stream mapping:</p>
  
  <pre><code>Stream #0:0 -&gt; #0:0 (mpeg4 (native) -&gt; h264 (libx264))
  
  Stream #0:1 -&gt; #0:1 (pcm_mulaw (native) -&gt; aac (native))
  
  Press [q] to stop, [?] for help
  
  [aac @ 0x7fc303000600] Too many bits 8832.000000 &gt; 6144 per frame requested, clamping to max
  
  [libx264 @ 0x7fc301846800] using SAR=1/1
  
  [libx264 @ 0x7fc301846800] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
  
  [libx264 @ 0x7fc301846800] profile High, level 3.0
  
  [libx264 @ 0x7fc301846800] 264 - core 148 r2795 aaa9aa8 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
  
  [segment @ 0x7fc301844400] Opening '0.mp4' for writing
  </code></pre>
  
  <p>Output #0, segment, to '%d.mp4':</p>
  
  <p>Metadata:</p>
  
  <pre><code>title           : My MPEG4 Session
  
  comment         : My MPEG4 info
  
  encoder         : Lavf57.83.100
  
  Stream #0:0: Video: h264 (libx264), yuv420p, 640x480 [SAR 1:1 DAR 4:3], q=-1--1, 30 fps, 15360 tbn, 30 tbc
  
  Metadata:
  
    encoder         : Lavc57.107.100 libx264
  
  Side data:
  
    cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
  
  Stream #0:1: Audio: aac (LC), 8000 Hz, mono, fltp, 48 kb/s
  
  Metadata:
  
    encoder         : Lavc57.107.100 aac
  
  frame=   57 fps=0.0 q=29.0 size=N/A time=00:00:02.04 bitrate=N/A dup=22 drop=0 sframe=   73 fps= 68 q=29.0 size=N/A time=00:00:02.56 bitrate=N/A dup=22 drop=0 s
  
  frame=   89 fps= 54 q=29.0 size=N/A time=00:00:03.07 bitrate=N/A dup=22 drop=0 sframe=  106 fps= 48 q=29.0 size=N/A time=00:00:03.58 bitrate=N/A dup=22 drop=0 s
  
  frame=  122 fps= 45 q=29.0 size=N/A time=00:00:04.09 bitrate=N/A dup=22 drop=0 sframe=  137 fps= 42 q=29.0 size=N/A time=00:00:04.48 bitrate=N/A dup=22 drop=0 s
  
  frame=  151 fps= 40 q=29.0 size=N/A time=00:00:04.97 bitrate=N/A dup=22 drop=0 s
  
  frame=  156 fps= 37 q=-1.0 Lsize=N/A time=00:00:05.48 bitrate=N/A dup=22 drop=0 speed= 1.3x  
  </code></pre>
  
  <p>Update: It works fine in vlc player. I am adding a link to the destorted video: <a href="https://drive.google.com/file/d/1QCc7XUbePBI3v1h0sNQgU0guHA2AwgRT/view?usp=sharing" rel="nofollow noreferrer">https://drive.google.com/file/d/1QCc7XUbePBI3v1h0sNQgU0guHA2AwgRT/view?usp=sharing</a></p>