Copying MPEG-4 AVC H264 stream without re encoding
Hello,

I'm using Ubiquiti G3 cam. From what I can read in VLC, output S1 is a H264 - MPEG-4 AVC (part 10) format with a resolution of 640x360 at 30FPS which is perfect for my typical usage. So I'm trying to just copy the stream without re encoding. Here is my configuration (I tried multiple ones with limited success.

I get very crazy images. Time to time, one frame is decent, then the next is blurry again.
I really don't understand what's wrong here. Spent a full day on this...

Any help would be more than welcome guys. 

<img width="497" alt="Screenshot 2020-04-12 19 53 52" src="https://user-images.githubusercontent.com/38879842/79076072-7e8a9880-7cf7-11ea-93d2-a256fb32622b.png">
<img width="545" alt="Screenshot 2020-04-12 19 53 36" src="https://user-images.githubusercontent.com/38879842/79076075-84807980-7cf7-11ea-8ed7-a33d534c7156.png">
<img width="1437" alt="Screenshot 2020-04-12 19 53 00" src="https://user-images.githubusercontent.com/38879842/79076076-877b6a00-7cf7-11ea-9b4d-8ef34022ac3a.png">
<img width="1437" alt="Screenshot 2020-04-12 19 52 32" src="https://user-images.githubusercontent.com/38879842/79076078-8b0ef100-7cf7-11ea-951d-a74043e21ff7.png">

I get this
[rtp @ 0x1130750] Sending NAL 1 of len 234 M=1
[libx264 @ 0x11bd830] frame= 404 QP=9.77 NAL=2 Slice:P Poc:308 I:0    P:334  SKIP:586  size=4943 bytes
[rtp @ 0x1130750] Sending NAL 1 of len 1940 M=0
[rtp @ 0x1130750] NAL size 1940 > 1290
[rtp @ 0x1130750] Sending NAL 1 of len 2187 M=0
[rtp @ 0x1130750] NAL size 2187 > 1290
[rtp @ 0x1130750] Sending NAL 1 of len 81 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 722 M=1
[libx264 @ 0x11bd830] frame= 405 QP=12.74 NAL=2 Slice:P Poc:310 I:0    P:20   SKIP:900  size=151 bytes
[rtp @ 0x1130750] Sending NAL 1 of len 49 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 38 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 22 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 29 M=1
[libx264 @ 0x11bd830]
frame= 406 QP=12.38 NAL=2 Slice:P Poc:312 I:0    P:8    SKIP:912  size=118 bytes
[rtp @ 0x1130750] Sending NAL 1 of len 26 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 30 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 19 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 30 M=1
[libx264 @ 0x11bd830] frame= 407 QP=12.71 NAL=2 Slice:P Poc:314 I:0    P:5    SKIP:915  size=110 bytes
[rtp @ 0x1130750] Sending NAL 1 of len 20 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 26 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 28 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 23 M=1
[libx264 @ 0x11bd830] frame= 408 QP=12.82 NAL=2 Slice:P Poc:316 I:0    P:11   SKIP:909  size=131 bytes
[rtp @ 0x1130750] Sending NAL 1 of len 20 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 47 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 28 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 23 M=1
[libx264 @ 0x11bd830] frame= 409 QP=10.57 NAL=2 Slice:P Poc:318 I:0    P:145  SKIP:775  size=1825 bytes
[rtp @ 0x1130750] Sending NAL 1 of len 601 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 883 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 173 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 155 M=1
[libx264 @ 0x11bd830] frame= 410 QP=9.63 NAL=2 Slice:P Poc:320 I:0    P:250  SKIP:670  size=2858 bytes
[rtp @ 0x1130750] Sending NAL 1 of len 1087 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 1152 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 241 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 365 M=1
[libx264 @ 0x11bd830] frame= 411 QP=12.56 NAL=2 Slice:P Poc:322 I:0    P:20   SKIP:900  size=155 bytes
[rtp @ 0x1130750] Sending NAL 1 of len 28 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 45 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 32 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 37 M=1
[libx264 @ 0x11bd830] frame= 412 QP=9.35 NAL=2 Slice:P Poc:324 I:0    P:107  SKIP:813  size=2392 bytes
[rtp @ 0x1130750] Sending NAL 1 of len 818 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 1432 M=0
[rtp @ 0x1130750] NAL size 1432 > 1290
[rtp @ 0x1130750] Sending NAL 1 of len 86 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 43 M=1
[libx264 @ 0x11bd830] frame= 413 QP=9.91 NAL=2 Slice:P Poc:326 I:0    P:152  SKIP:768  size=1669 bytes
[rtp @ 0x1130750] Sending NAL 1 of len 573 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 530 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 138 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 415 M=1
[libx264 @ 0x11bd830] frame= 414 QP=12.14 NAL=2 Slice:P Poc:328 I:0    P:19   SKIP:901  size=157 bytes
[rtp @ 0x1130750] Sending NAL 1 of len 37 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 38 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 32 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 37 M=1
[libx264 @ 0x11bd830] frame= 415 QP=7.93 NAL=2 Slice:P Poc:330 I:0    P:90   SKIP:830  size=1306 bytes
[rtp @ 0x1130750] Sending NAL 1 of len 826 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 205 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 146 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 116 M=1
[libx264 @ 0x11bd830] frame= 416 QP=8.59 NAL=2 Slice:P Poc:332 I:0    P:159  SKIP:761  size=4284 bytes
[rtp @ 0x1130750] Sending NAL 1 of len 1920 M=0
[rtp @ 0x1130750] NAL size 1920 > 1290
[rtp @ 0x1130750] Sending NAL 1 of len 292 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 126 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 1933 M=1
[rtp @ 0x1130750] NAL size 1933 > 1290
[libx264 @ 0x11bd830] frame= 417 QP=10.56 NAL=2 Slice:P Poc:334 I:0    P:68   SKIP:852  size=724 bytes
[rtp @ 0x1130750] Sending NAL 1 of len 330 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 173 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 78 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 130 M=1
[libx264 @ 0x11bd830] frame= 418 QP=12.37 NAL=2 Slice:P Poc:336 I:0    P:12   SKIP:908  size=132 bytes
[rtp @ 0x1130750] Sending NAL 1 of len 26 M=0
    Last message repeated 1 times
[rtp @ 0x1130750] Sending NAL 1 of len 30 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 37 M=1
[libx264 @ 0x11bd830] frame= 419 QP=11.00 NAL=2 Slice:P Poc:338 I:0    P:70   SKIP:850  size=1244 bytes
[rtp @ 0x1130750] Sending NAL 1 of len 257 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 647 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 59 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 268 M=1
[h264 @ 0x1132230] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
[libx264 @ 0x11bd830] frame= 420 QP=11.83 NAL=2 Slice:P Poc:340 I:0    P:80   SKIP:840  size=1485 bytes
[rtp @ 0x1130750] Sending NAL 1 of len 386 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 765 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 68 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 253 M=1
frame=  421 fps= 19 q=9.0 size=     710kB time=00:00:21.00 bitrate= 277.2kbits/s dup=240 drop=54 speed=0.944x
[h264 @ 0x1149ba0] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
Clipping frame in rate conversion by 0.333321
[libx264 @ 0x11bd830] frame= 421 QP=12.54 NAL=2 Slice:P Poc:342 I:0    P:67   SKIP:853  size=1370 bytes
[rtp @ 0x1130750] Sending NAL 1 of len 197 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 824 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 96 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 240 M=1
[h264 @ 0x114dff0] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
Past duration 0.666664 too large
[libx264 @ 0x11bd830] frame= 422 QP=12.73 NAL=2 Slice:P Poc:344 I:0    P:63   SKIP:857  size=1382 bytes
[rtp @ 0x1130750] Sending NAL 1 of len 233 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 780 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 109 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 247 M=1
[h264 @ 0x11cc140] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
Clipping frame in rate conversion by 0.486443
[libx264 @ 0x11bd830] frame= 423 QP=18.87 NAL=2 Slice:P Poc:346 I:56   P:735  SKIP:129  size=17303 bytes
[rtp @ 0x1130750] Sending NAL 1 of len 3927 M=0
[rtp @ 0x1130750] NAL size 3927 > 1290
[rtp @ 0x1130750] Sending NAL 1 of len 4581 M=0
[rtp @ 0x1130750] NAL size 4581 > 1290
[rtp @ 0x1130750] Sending NAL 1 of len 4315 M=0
[rtp @ 0x1130750] NAL size 4315 > 1290
[rtp @ 0x1130750] Sending NAL 1 of len 4467 M=1
[rtp @ 0x1130750] NAL size 4467 > 1290
[h264 @ 0x11061d0] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
[2020-4-12 20:11:15] [Camera] Snapshot from Camera jardin at 480x270
ffmpeg -i http://192.168.0.82/snap.jpeg -t 1 -s 480x270 -f image2 -
[2020-4-12 20:11:15] [DoorBird] Snapshot from DoorBird at 480x270
[libx264 @ 0x11bd830] frame= 424 QP=18.19 NAL=2 Slice:P Poc:348 I:11   P:551  SKIP:358  size=7210 bytes
[rtp @ 0x1130750] Sending NAL 1 of len 1903 M=0
[rtp @ 0x1130750] NAL size 1903 > 1290
[rtp @ 0x1130750] Sending NAL 1 of len 1741 M=0
[rtp @ 0x1130750] NAL size 1741 > 1290
[rtp @ 0x1130750] Sending NAL 1 of len 1347 M=0
[rtp @ 0x1130750] NAL size 1347 > 1290
[rtp @ 0x1130750] Sending NAL 1 of len 2206 M=1
[rtp @ 0x1130750] NAL size 2206 > 1290
[h264 @ 0x1132230] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
[libx264 @ 0x11bd830] frame= 425 QP=20.79 NAL=2 Slice:P Poc:350 I:0    P:75   SKIP:845  size=575 bytes
[rtp @ 0x1130750] Sending NAL 1 of len 50 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 289 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 102 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 121 M=1
[h264 @ 0x1149ba0] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
[libx264 @ 0x11bd830] frame= 426 QP=18.24 NAL=2 Slice:P Poc:352 I:1    P:191  SKIP:728  size=1518 bytes
[rtp @ 0x1130750] Sending NAL 1 of len 270 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 602 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 227 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 406 M=1
[h264 @ 0x114dff0] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
[h264 @ 0x11cc140] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
*** dropping frame 427 from stream 0 at ts 425
[libx264 @ 0x11bd830] frame= 427 QP=17.87 NAL=2 Slice:P Poc:354 I:0    P:268  SKIP:652  size=2443 bytes
[rtp @ 0x1130750] Sending NAL 1 of len 361 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 1029 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 388 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 652 M=1
frame=  428 fps= 19 q=18.0 size=     742kB time=00:00:21.35 bitrate= 284.7kbits/[h264 @ 0x11061d0] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
[libx264 @ 0x11bd830] frame= 428 QP=17.18 NAL=2 Slice:P Poc:356 I:0    P:270  SKIP:650  size=2235 bytes
[rtp @ 0x1130750] Sending NAL 1 of len 390 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 910 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 383 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 539 M=1
[h264 @ 0x1132230] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
[h264 @ 0x1149ba0] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
*** dropping frame 429 from stream 0 at ts 427
[libx264 @ 0x11bd830] frame= 429 QP=18.14 NAL=2 Slice:P Poc:358 I:0    P:160  SKIP:760  size=1558 bytes
[rtp @ 0x1130750] Sending NAL 1 of len 110 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 873 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 254 M=0
[rtp @ 0x1130750] Sending NAL 1 of len 308 M=1
frame=  430 fps= 19 q=18.0 Lsize=     746kB time=00:00:21.45 bitrate= 284.8kbits/s dup=240 drop=56 speed=0.933x
video:737kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.189785%
Input file #0 (rtsp://192.168.0.82:554/s1):
  Input stream #0:0 (audio): 258 packets read (94046 bytes);
  Input stream #0:1 (video): 253 packets read (565282 bytes);
247 frames decoded;
  Total: 511 packets (659328 bytes) demuxed
Output file #0 (srtp://192.168.0.99:51850?rtcpport=51850&localrtcpport=51850&pkt_size=1316):
  Output stream #0:0 (video): 430 frames encoded; 430 packets muxed (754590 bytes);
  Total: 430 packets (754590 bytes) muxed
247 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0x11be0d0] Statistics: 0 seeks, 902 writeouts
[libx264 @ 0x11bd830] frame I:2     Avg QP:28.26  size: 17368
[libx264 @ 0x11bd830] frame P:428   Avg QP:15.21  size:  1682
[libx264 @ 0x11bd830] mb I  I16..4:  4.7% 69.9% 25.4%
[libx264 @ 0x11bd830] mb P  I16..4:  0.1%  0.1%  0.1%  P16..4: 13.4%  0.6%  1.2%  0.0%  0.0%    skip:84.4%
[libx264 @ 0x11bd830] 8x8 transform intra:56.6% inter:36.5%
[libx264 @ 0x11bd830] coded y,uvDC,uvAC intra: 62.6% 74.9% 47.0% inter: 6.2% 8.6% 3.8%
[libx264 @ 0x11bd830] i16 v,h,dc,p: 75%  4% 13%  9%
[libx264 @ 0x11bd830] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 36%  8% 22%  5%  7%  4%  7%  4%  6%
[libx264 @ 0x11bd830] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 15% 12% 26%  9% 13%  5%  9%  5%  6%
[libx264 @ 0x11bd830] i8c dc,h,v,p: 48% 14% 33%  5%
[libx264 @ 0x11bd830] Weighted P-Frames: Y:0.2% UV:0.0%
[libx264 @ 0x11bd830] ref P L0: 92.8%  2.3%  4.3%  0.7%  0.0%
[libx264 @ 0x11bd830] kb/s:280.78
Exiting normally, received signal 15.
