0

When I do it like this,

-c:v copy -preset ultrafast -cfr 20 -tune zerolatency

and it doesn't work I know that this is excpected because the video codec is copied and all the other parameters such as -preset, -cfr and so on are ignored.

However, when I do it like this,

-c:v libx264 -preset ultrafast -cfr 20 -tune zerolatency

it doesn't work either because my camera is already streaming in libx264, it says dup! dup! dup! which means duplicate as far as I understand, one libx264 duplicates another libx264 and just shuts up and stops streaming. I think this is also understandable because you cannot convert / transcode from libx264 to libx264.

Now the question is how do I set / fine tune my libx264 streaming camera's parameters to this?

-preset ultrafast -crf 20 -tune zerolatency

It doesn't work via -c:v copy and it does not work via -c:v. Is it impossible at all? Would appreciate any comments / input / suggestions. Many thanks!

Here is the log:

     built with gcc 8 (Debian 8.3.0-6)
  configuration: --prefix=/usr --extra-version='1~deb10u1' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --ena    ble-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libblur    ay --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme -    -enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable    -librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-l    ibvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx     --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
[tcp @ 0x55ea771b6e80] Starting connection attempt to 1.1.1 port 554
[tcp @ 0x55ea771b6e80] Successfully connected to 1.1.1.1 port 554
[rtsp @ 0x55ea771b4c00] SDP:
v=0
o=StreamingServer 3331435948 1116907222000 IN IP4 1.1.1.1
s=10
c=IN IP4 0.0.0.0
t=0 0
a=control:*
m=video 0 RTP/AVP 96
a=control:trackID=0
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1;profile-level-id=42002A;sprop-parameter-sets=Z0IAKpY1QPAET8s3AQEBAg==,aM48gA==
a=framesize:96 1920-1080
m=audio 0 RTP/AVP 8
a=control:trackID=1
a=rtpmap:8 PCMA/8000/1
a=ptime:20
a=fmtp:8 packetization-mode=1

[rtsp @ 0x55ea771b4c00] setting jitter buffer size to 0
    Last message repeated 1 times
[h264 @ 0x55ea771b8940] Reinit context to 1920x1088, pix_fmt: yuvj420p
Guessed Channel Layout for Input Stream #0.1 : mono
  Metadata:
    title           : 10
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: h264 (Baseline), 1 reference frame, yuvj420p(pc, bt709, progressive, left), 1920x1080 (1920x1088), 29.97 tbr, 90k tbn, 180k tbc
    Stream #0:1: Audio: pcm_alaw, 8000 Hz, mono, s16, 64 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (pcm_alaw (native) -> aac (native))
Press [q] to stop, [?] for help
[graph_1_in_0_1 @ 0x55ea772dd4c0] tb:1/8000 samplefmt:s16 samplerate:8000 chlayout:0x4
[format_out_0_1 @ 0x55ea7735a4c0] auto-inserting filter 'auto_resampler_0' between the filter 'Parsed_anull_0' and the filter 'format_out_0_1'
[auto_resampler_0 @ 0x55ea772de440] ch:1 chl:mono fmt:s16 r:8000Hz -> ch:1 chl:mono fmt:fltp r:8000Hz
[aac @ 0x55ea771d34c0] Too many bits 8832.000000 > 6144 per frame requested, clamping to max
[h264 @ 0x55ea771d4040] Reinit context to 1920x1088, pix_fmt: yuvj420p
[graph 0 input from stream 0:0 @ 0x55ea772ddf80] w:1920 h:1080 pixfmt:yuvj420p tb:1/90000 fr:30000/1001 sar:0/1 sws_param:flags=2
[libx264 @ 0x55ea771d8700] using cpu capabilities: MMX2 SSE2 SSE3 Cache64
[libx264 @ 0x55ea771d8700] profile High, level 4.0
[libx264 @ 0x55ea771d8700] 264 - core 155 r2917 0a84d98 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - 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 th    reads=3 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 op    en_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.0    0
[segment @ 0x55ea771bc340] Selected stream id:0 type:video
[segment @ 0x55ea771bc340] Opening '/usr/local/nginx/html/hls/mystream0.ts' for writing
[mpegts @ 0x55ea777e5180] muxrate VBR, pcr every 2 pkts, sdt every 200, pat/pmt every 40 pkts
Output #0, segment, to '/usr/local/nginx/html/hls/mystream%01d.ts':
  Metadata:
    title           : 10
    encoder         : Lavf58.20.100
    Stream #0:0: Video: h264 (libx264), 1 reference frame, yuvj420p(pc, left), 1920x1080, q=-1--1, 29.97 fps, 90k tbn, 29.97 tbc
    Metadata:
      encoder         : Lavc58.35.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, delay 1024, 48 kb/s
    Metadata:
      encoder         : Lavc58.35.100 aac
*** 1 dup!
    Last message repeated 8 times
No more output streams to write to, finishing.
[segment @ 0x55ea771bc340] segment:'/usr/local/nginx/html/hls/mystream0.ts' starts with packet stream:1 pts:0 pts_time:0 frame:0
[segment @ 0x55ea771bc340] segment:'/usr/local/nginx/html/hls/mystream0.ts' starts with packet stream:0 pts:11520 pts_time:0.128 frame:0
[segment @ 0x55ea771bc340] Opening '/usr/local/nginx/html/hls/mystream.m3u8.tmp' for writing
[segment @ 0x55ea771bc340] EXT-X-MEDIA-SEQUENCE:0
[AVIOContext @ 0x55ea777e5780] Statistics: 0 seeks, 1 writeouts
[segment @ 0x55ea771bc340] segment:'/usr/local/nginx/html/hls/mystream0.ts' count:0 ended
[AVIOContext @ 0x55ea77827a80] Statistics: 0 seeks, 7 writeouts
frame=   29 fps=7.5 q=-1.0 Lsize=N/A time=00:00:01.02 bitrate=N/A dup=9 drop=0 speed=0.266x
video:1490kB audio:6kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Input file #0 (rtsp://admina:klaipedaville77@85.232.142.131:554/111):
  Input stream #0:0 (video): 20 packets read (1179137 bytes); 20 frames decoded;
  Input stream #0:1 (audio): 48 packets read (7680 bytes); 48 frames decoded (7680 samples);
  Total: 68 packets (1186817 bytes) demuxed
Output file #0 (/usr/local/nginx/html/hls/mystream%01d.ts):
  Output stream #0:0 (video): 29 frames encoded; 29 packets muxed (1526031 bytes);
  Output stream #0:1 (audio): 8 frames encoded (7680 samples); 9 packets muxed (5798 bytes);
  Total: 38 packets (1531829 bytes) muxed
[libx264 @ 0x55ea771d8700] frame I:1     Avg QP:25.19  size:405054
[libx264 @ 0x55ea771d8700] frame P:18    Avg QP:28.35  size: 61978
[libx264 @ 0x55ea771d8700] frame B:10    Avg QP:33.01  size:   469
[libx264 @ 0x55ea771d8700] consecutive B-frames: 34.5% 55.2% 10.3%  0.0%
[libx264 @ 0x55ea771d8700] mb I  I16..4: 28.3%  7.3% 64.3%
[libx264 @ 0x55ea771d8700] mb P  I16..4:  0.4%  0.0%  0.5%  P16..4: 54.5%  0.5%  5.3%  0.0%  0.0%    skip:38.8%
[libx264 @ 0x55ea771d8700] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  6.0%  0.1%  0.0%  direct: 0.0%  skip:93.9%  L0:32.2% L1:67.5% BI: 0.2%
[libx264 @ 0x55ea771d8700] 8x8 transform intra:6.5% inter:2.3%
[libx264 @ 0x55ea771d8700] coded y,uvDC,uvAC intra: 95.7% 36.3% 7.1% inter: 25.7% 0.6% 0.0%
[libx264 @ 0x55ea771d8700] i16 v,h,dc,p:  2%  2% 82% 14%
[libx264 @ 0x55ea771d8700] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 30% 22%  3%  2%  3%  4%  3%  6%
[libx264 @ 0x55ea771d8700] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 15% 18% 15%  7%  9%  7% 13%  7%  9%
[libx264 @ 0x55ea771d8700] i8c dc,h,v,p: 42% 25% 20% 13%
[libx264 @ 0x55ea771d8700] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x55ea771d8700] ref P L0: 94.6%  4.7%  0.5%  0.1%
[libx264 @ 0x55ea771d8700] ref B L0: 99.6%  0.4%
[libx264 @ 0x55ea771d8700] kb/s:12610.91
[aac @ 0x55ea771d34c0] Qavg: 149.630
  • 1
    Share full command and log. dup! happens because of timestamp gaps, not because of source codec. – Gyan Apr 15 at 18:10
  • Well, the command is really simple ffmpeg -re -i website.com/hls/mystream.m3u8 -vcodec libx264 -preset ultrafast -tune zerolatency -acodec aac -f flv rtmp://a.rtmp.youtube.com/live2/key – Dennis Apr 16 at 4:47
  • Log missing. What makes you think the parameters are ignored? – Gyan Apr 16 at 7:07
  • because when I specify the parameters it drops almost instantly and does not show/see the parameters in its "side data", but when I do not set any parameters and do it plain simple like this -vcodec copy -acodec aac it works fine. – Dennis Apr 16 at 9:33
  • Share full log. – Gyan Apr 16 at 9:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.