Closed mpisat closed 1 year ago
Screenshot: https://imgur.com/a/say8mb1
I have to say this is the worst way to transcode videos for 3 outputs as ffmpeg has to decode it 3 times! Exec is better option where I can decode once, transcode 3 times and push all at once.
Logs
tail -n 30 -f ./objs/srs.log
[2023-06-30 14:26:56.855][Trace][13960][12092189] connect app, tcUrl=rtmp://127.0.0.1:19356/live?vhost=__defaultVhost__, pageUrl=, swfUrl=, schema=rtmp, vhost=__defaultVhost__, port=19356, app=live, args=null
[2023-06-30 14:26:56.855][Trace][13960][12092189] protocol in.buffer=0, in.ack=0, out.ack=0, in.chunk=128, out.chunk=128
[2023-06-30 14:26:56.943][Trace][13960][66b9929l] client identified, type=fmle-publish, vhost=__defaultVhost__, app=live, stream=test_720p, param=, duration=0ms
[2023-06-30 14:26:56.943][Trace][13960][66b9929l] connected stream, tcUrl=rtmp://127.0.0.1:19356/live?vhost=__defaultVhost__, pageUrl=, swfUrl=, schema=rtmp, vhost=__defaultVhost__, port=19356, app=live, stream=test_720p, param=, args=null
[2023-06-30 14:26:56.943][Trace][13960][66b9929l] new source, stream_url=/live/test_720p
[2023-06-30 14:26:56.943][Trace][13960][66b9929l] source url=/live/test_720p, ip=127.0.0.1, cache=1, is_edge=0, source_id=/
[2023-06-30 14:26:56.944][Trace][13960][4j818939] client identified, type=fmle-publish, vhost=__defaultVhost__, app=live, stream=test_540p, param=, duration=0ms
[2023-06-30 14:26:56.944][Trace][13960][4j818939] connected stream, tcUrl=rtmp://127.0.0.1:19356/live?vhost=__defaultVhost__, pageUrl=, swfUrl=, schema=rtmp, vhost=__defaultVhost__, port=19356, app=live, stream=test_540p, param=, args=null
[2023-06-30 14:26:56.944][Trace][13960][4j818939] new source, stream_url=/live/test_540p
[2023-06-30 14:26:56.944][Trace][13960][4j818939] source url=/live/test_540p, ip=127.0.0.1, cache=1, is_edge=0, source_id=/
[2023-06-30 14:26:56.944][Trace][13960][12092189] client identified, type=fmle-publish, vhost=__defaultVhost__, app=live, stream=test_360p, param=, duration=0ms
[2023-06-30 14:26:56.944][Trace][13960][12092189] connected stream, tcUrl=rtmp://127.0.0.1:19356/live?vhost=__defaultVhost__, pageUrl=, swfUrl=, schema=rtmp, vhost=__defaultVhost__, port=19356, app=live, stream=test_360p, param=, args=null
[2023-06-30 14:26:56.944][Trace][13960][12092189] new source, stream_url=/live/test_360p
[2023-06-30 14:26:56.944][Trace][13960][12092189] source url=/live/test_360p, ip=127.0.0.1, cache=1, is_edge=0, source_id=/
[2023-06-30 14:26:57.031][Trace][13960][66b9929l] ignore disabled exec for vhost=__defaultVhost__
[2023-06-30 14:26:57.032][Trace][13960][66b9929l] start publish mr=0/350, p1stpt=20000, pnt=5000, tcp_nodelay=0
[2023-06-30 14:26:57.032][Trace][13960][4j818939] ignore disabled exec for vhost=__defaultVhost__
[2023-06-30 14:26:57.032][Trace][13960][4j818939] start publish mr=0/350, p1stpt=20000, pnt=5000, tcp_nodelay=0
[2023-06-30 14:26:57.032][Trace][13960][12092189] ignore disabled exec for vhost=__defaultVhost__
[2023-06-30 14:26:57.032][Trace][13960][12092189] start publish mr=0/350, p1stpt=20000, pnt=5000, tcp_nodelay=0
[2023-06-30 14:26:57.151][Trace][13960][12092189] got metadata, width=640, height=360, vcodec=7, acodec=10
[2023-06-30 14:26:57.151][Trace][13960][12092189] 49B video sh, codec(7, profile=Main, level=3, 640x360, 0kbps, 0.0fps, 0.0s)
[2023-06-30 14:26:57.151][Trace][13960][12092189] 7B audio sh, codec(10, profile=LC, 2channels, 0kbps, 44100HZ), flv(16bits, 2channels, 44100HZ)
[2023-06-30 14:26:57.155][Trace][13960][4j818939] got metadata, width=960, height=540, vcodec=7, acodec=10
[2023-06-30 14:26:57.155][Trace][13960][4j818939] 49B video sh, codec(7, profile=Main, level=3.1, 960x540, 0kbps, 0.0fps, 0.0s)
[2023-06-30 14:26:57.155][Trace][13960][4j818939] 7B audio sh, codec(10, profile=LC, 2channels, 0kbps, 44100HZ), flv(16bits, 2channels, 44100HZ)
[2023-06-30 14:26:57.159][Trace][13960][66b9929l] got metadata, width=1280, height=720, vcodec=7, acodec=10
[2023-06-30 14:26:57.159][Trace][13960][66b9929l] 48B video sh, codec(7, profile=Main, level=3.1, 1280x720, 0kbps, 0.0fps, 0.0s)
[2023-06-30 14:26:57.159][Trace][13960][66b9929l] 7B audio sh, codec(10, profile=LC, 2channels, 0kbps, 44100HZ), flv(16bits, 2channels, 44100HZ)
[2023-06-30 14:26:58.445][Trace][13960][58v28819] Hybrid cpu=1.00%,12MB, cid=11,2, timer=62,0,0, clock=0,49,1,0,0,0,0,0,0, free=1, objs=(pkt:0,raw:0,fua:0,msg:2,oth:0,buf:0)
[2023-06-30 14:27:03.446][Trace][13960][58v28819] Hybrid cpu=2.00%,15MB, cid=11,2, timer=62,0,0, clock=0,49,1,0,0,0,0,0,0, free=1, objs=(pkt:0,raw:0,fua:0,msg:2,oth:0,buf:0)
[2023-06-30 14:27:05.325][Trace][13960][71f55nk0] -> PLA time=10025911, msgs=27, okbps=1508,0,0, ikbps=2,0,0, mw=350/8
[2023-06-30 14:27:07.065][Trace][13960][4u102p2p] RTMP client ip=183.88.110.87:64611, fd=16
[2023-06-30 14:27:07.249][Trace][13960][4u102p2p] complex handshake success
[2023-06-30 14:27:07.429][Trace][13960][4u102p2p] connect app, tcUrl=rtmp://fr.redacteddomain.com:19356/live, pageUrl=, swfUrl=, schema=rtmp, vhost=fr.redacteddomain.com, port=19356, app=live, args=null
[2023-06-30 14:27:07.429][Trace][13960][4u102p2p] protocol in.buffer=0, in.ack=0, out.ack=0, in.chunk=128, out.chunk=128
[2023-06-30 14:27:08.005][Trace][13960][4u102p2p] ignore AMF0/AMF3 command message.
[2023-06-30 14:27:08.419][Trace][13960][4u102p2p] ignore AMF0/AMF3 command message.
[2023-06-30 14:27:08.419][Trace][13960][4u102p2p] client identified, type=rtmp-play, vhost=fr.redacteddomain.com, app=live, stream=test_720p, param=, duration=-1ms
[2023-06-30 14:27:08.419][Trace][13960][4u102p2p] connected stream, tcUrl=rtmp://fr.redacteddomain.com:19356/live, pageUrl=, swfUrl=, schema=rtmp, vhost=__defaultVhost__, port=19356, app=live, stream=test_720p, param=, args=null
[2023-06-30 14:27:08.419][Trace][13960][4u102p2p] source url=/live/test_720p, ip=183.88.110.87, cache=1, is_edge=0, source_id=66b9929l/66b9929l
[2023-06-30 14:27:08.419][Trace][13960][4u102p2p] dispatch cached gop success. count=25, duration=370
[2023-06-30 14:27:08.419][Trace][13960][4u102p2p] create consumer, active=1, queue_size=0.00, jitter=30000000
[2023-06-30 14:27:08.420][Trace][13960][4u102p2p] set fd=16, SO_SNDBUF=87040=>175000, buffer=350ms
[2023-06-30 14:27:08.420][Trace][13960][4u102p2p] start play smi=0ms, mw_sleep=350, mw_msgs=8, realtime=0, tcp_nodelay=0
[2023-06-30 14:27:08.447][Trace][13960][58v28819] Hybrid cpu=1.00%,17MB, cid=11,2, timer=61,0,0, clock=0,41,6,1,0,0,0,0,0, objs=(pkt:0,raw:0,fua:0,msg:616,oth:0,buf:0)
[2023-06-30 14:27:13.447][Trace][13960][58v28819] Hybrid cpu=2.00%,18MB, cid=11,2, timer=61,0,0, clock=0,41,6,1,0,0,0,0,0, objs=(pkt:0,raw:0,fua:0,msg:616,oth:0,buf:0)
[2023-06-30 14:27:16.171][Trace][13960][4u102p2p] -> PLA time=7354966, msgs=25, okbps=1800,0,0, ikbps=3,0,0, mw=350/8
[2023-06-30 14:27:17.032][Trace][13960][66b9929l] <- CPB time=0, okbps=1,0,0, ikbps=1882,0,0, mr=0/350, p1stpt=20000, pnt=5000
[2023-06-30 14:27:18.448][Trace][13960][58v28819] Hybrid cpu=2.00%,18MB, cid=11,2, timer=61,0,0, clock=0,41,6,1,0,0,0,0,0, objs=(pkt:0,raw:0,fua:0,msg:616,oth:0,buf:0)
[2023-06-30 14:27:23.449][Trace][13960][58v28819] Hybrid cpu=1.00%,18MB, cid=1,0, timer=61,0,0, clock=0,41,6,1,1,0,0,0,0, objs=(pkt:0,raw:0,fua:0,msg:837,oth:0,buf:0)
[2023-06-30 14:27:24.760][Trace][13960][x40wwqtb] <- CPB time=24997320, okbps=1,1,0, ikbps=1536,1536,0, mr=0/350, p1stpt=20000, pnt=5000
[2023-06-30 14:27:26.167][Trace][13960][4u102p2p] -> PLA time=17360877, msgs=25, okbps=1928,0,0, ikbps=1,0,0, mw=350/8
[2023-06-30 14:27:28.449][Trace][13960][58v28819] Hybrid cpu=2.00%,18MB, cid=1,0, timer=61,0,0, clock=0,41,6,1,1,0,0,0,0, objs=(pkt:0,raw:0,fua:0,msg:837,oth:0,buf:0)
[2023-06-30 14:27:33.450][Trace][13960][58v28819] Hybrid cpu=2.99%,18MB, cid=1,0, timer=62,0,0, clock=0,40,7,1,1,0,0,0,0, objs=(pkt:0,raw:0,fua:0,msg:850,oth:0,buf:0)
[2023-06-30 14:27:34.761][Trace][13960][x40wwqtb] <- CPB time=34991037, okbps=0,1,0, ikbps=1553,1536,0, mr=0/350, p1stpt=20000, pnt=5000
[2023-06-30 14:27:36.234][Trace][13960][71f55nk0] -> PLA time=40921703, msgs=28, okbps=1589,1604,0, ikbps=0,0,0, mw=350/8
[2023-06-30 14:27:36.798][Trace][13960][x40wwqtb] -> ENC time=53507608, encoders=3, input=__defaultVhost__/live/test
[2023-06-30 14:27:38.451][Trace][13960][58v28819] Hybrid cpu=2.00%,18MB, cid=1,0, timer=62,0,0, clock=0,40,7,1,1,0,0,0,0, objs=(pkt:0,raw:0,fua:0,msg:850,oth:0,buf:0)
[2023-06-30 14:27:38.880][Trace][13960][x40wwqtb] send SIGTERM to pid=14000
[2023-06-30 14:27:39.146][Warn][13960][66b9929l][11] VIDEO: stream not monotonically increase, please open mix_correct.
[2023-06-30 14:27:39.149][Trace][13960][66b9929l] cleanup when unpublish
[2023-06-30 14:27:39.149][Trace][13960][66b9929l] TCP: before dispose resource(RtmpConn)(0x565041722650), conns=8, zombies=0, ign=0, inz=0, ind=0
[2023-06-30 14:27:39.149][Warn][13960][66b9929l][4] client disconnect peer. ret=1009
[2023-06-30 14:27:39.149][Trace][13960][6t17ei1f] TCP: clear zombies=1 resources, conns=8, removing=0, unsubs=0
[2023-06-30 14:27:39.149][Trace][13960][66b9929l] TCP: disposing #0 resource(RtmpConn)(0x565041722650), conns=8, disposing=1, zombies=0
[2023-06-30 14:27:39.163][Trace][13960][71f55nk0] TCP: before dispose resource(RtmpConn)(0x56504169eb40), conns=7, zombies=0, ign=0, inz=0, ind=0
[2023-06-30 14:27:39.163][Warn][13960][71f55nk0][32] client disconnect peer. ret=1009
[2023-06-30 14:27:39.163][Trace][13960][6t17ei1f] TCP: clear zombies=1 resources, conns=7, removing=0, unsubs=0
[2023-06-30 14:27:39.163][Trace][13960][71f55nk0] TCP: disposing #0 resource(RtmpConn)(0x56504169eb40), conns=7, disposing=1, zombies=0
[2023-06-30 14:27:39.177][Trace][13960][x40wwqtb] SIGTERM stop process pid=14000 ok.
[2023-06-30 14:27:39.177][Trace][13960][x40wwqtb] send SIGTERM to pid=14001
[2023-06-30 14:27:40.231][Trace][13960][x40wwqtb] SIGKILL stop process pid=14001 ok.
[2023-06-30 14:27:40.231][Trace][13960][x40wwqtb] send SIGTERM to pid=14002
[2023-06-30 14:27:40.231][Trace][13960][5q07115v] TCP: before dispose resource(RtmpConn)(0x5650417033c0), conns=6, zombies=0, ign=0, inz=0, ind=0
[2023-06-30 14:27:40.231][Warn][13960][5q07115v][4] client disconnect peer. ret=1007
[2023-06-30 14:27:40.231][Trace][13960][4j818939] cleanup when unpublish
[2023-06-30 14:27:40.232][Trace][13960][4j818939] TCP: before dispose resource(RtmpConn)(0x5650416a8240), conns=6, zombies=1, ign=0, inz=0, ind=0
[2023-06-30 14:27:40.232][Warn][13960][4j818939][4] client disconnect peer. ret=1007
[2023-06-30 14:27:40.232][Trace][13960][6t17ei1f] TCP: clear zombies=2 resources, conns=6, removing=0, unsubs=0
[2023-06-30 14:27:40.232][Trace][13960][5q07115v] TCP: disposing #0 resource(RtmpConn)(0x5650417033c0), conns=6, disposing=2, zombies=0
[2023-06-30 14:27:40.232][Trace][13960][4j818939] TCP: disposing #1 resource(RtmpConn)(0x5650416a8240), conns=5, disposing=2, zombies=0
used config:
listen 19356;
max_connections 1000;
vhost __defaultVhost__ {
transcode {
enabled on;
ffmpeg /usr/local/bin/ffmpeg; # Path to your FFmpeg executable
engine 720p {
enabled on;
vcodec libx264;
vbitrate 2000k; # 720p at 2000 kbps
vfps 25;
vwidth 1280;
vheight 720;
vthreads 12;
vprofile main;
vpreset medium;
vparams {
}
acodec aac;
abitrate 128k;
asample_rate 44100;
achannels 2;
aparams {
}
output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_720p;
}
engine 540p {
enabled on;
vcodec libx264;
vbitrate 1200k; # 540p at 1200 kbps
vfps 25;
vwidth 960;
vheight 540;
vthreads 12;
vprofile main;
vpreset medium;
vparams {
}
acodec aac;
abitrate 128k;
asample_rate 44100;
achannels 2;
aparams {
}
output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_540p;
}
engine 360p {
enabled on;
vcodec libx264;
vbitrate 550k; # 360p at 550 kbps
vfps 25;
vwidth 640;
vheight 360;
vthreads 12;
vprofile main;
vpreset medium;
vparams {
}
acodec aac;
abitrate 128k;
asample_rate 44100;
achannels 2;
aparams {
}
output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_360p;
}
}
}
ffmpeg log file.
cat ffmpeg-encoder-__defaultVhost__-live-test-720p.log
process ppid=21668, cid=o6ti38q0, pid=21733, in=0, out=1, err=2
process binary=/usr/local/bin/ffmpeg, cli: /usr/local/bin/ffmpeg -f flv -i rtmp://127.0.0.1:19356/live?vhost=__defaultVhost__/test -vcodec libx264 -b:v 2000000 -r 25.00 -s 1280x720 -aspect 1280:720 -threads 12 -profile:v main -preset medium -acodec aac -b:a 128000 -ar 44100 -ac 2 -f flv -y rtmp://127.0.0.1:19356/live?vhost=__defaultVhost__/test_720p 1 > ./objs/ffmpeg-encoder-__defaultVhost__-live-test-720p.log 2 > ./objs/ffmpeg-encoder-__defaultVhost__-live-test-720p.log
process actual cli: /usr/local/bin/ffmpeg -f flv -i rtmp://127.0.0.1:19356/live?vhost=__defaultVhost__/test -vcodec libx264 -b:v 2000000 -r 25.00 -s 1280x720 -aspect 1280:720 -threads 12 -profile:v main -preset medium -acodec aac -b:a 128000 -ar 44100 -ac 2 -f flv -y rtmp://127.0.0.1:19356/live?vhost=__defaultVhost__/test_720p
ffmpeg version 4.4-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 8 (Debian 8.3.0-6)
configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-libgme --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi --enable-libzimg
libavutil 56. 70.100 / 56. 70.100
libavcodec 58.134.100 / 58.134.100
libavformat 58. 76.100 / 58. 76.100
libavdevice 58. 13.100 / 58. 13.100
libavfilter 7.110.100 / 7.110.100
libswscale 5. 9.100 / 5. 9.100
libswresample 3. 9.100 / 3. 9.100
libpostproc 55. 9.100 / 55. 9.100
Input #0, flv, from 'rtmp://127.0.0.1:19356/live?vhost=__defaultVhost__/test':
Metadata:
|RtmpSampleAccess: true
fileSize : 0
audiochannels : 2
2.1 : false
3.1 : false
4.0 : false
4.1 : false
5.1 : false
7.1 : false
encoder : obs-output module (libobs version 29.1.3)
server : SRS/4.0.268(Leo)
server_version : 4.0.268
Duration: N/A, start: 0.000000, bitrate: 1634 kb/s
Stream #0:0: Data: none
Stream #0:1: Audio: aac (LC), 44100 Hz, stereo, fltp, 98 kb/s
Stream #0:2: Video: h264 (Constrained Baseline), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 1536 kb/s, 30 fps, 30 tbr, 1k tbn, 60 tbc
Stream mapping:
Stream #0:2 -> #0:0 (h264 (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 0x5e77500] using SAR=1/1
[libx264 @ 0x5e77500] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x5e77500] profile Main, level 3.1, 4:2:0, 8-bit
[libx264 @ 0x5e77500] 264 - core 161 r3048 b86ae3c - H.264/MPEG-4 AVC codec - Copyleft 2003-2021 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 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=abr mbtree=1 bitrate=2000 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, flv, to 'rtmp://127.0.0.1:19356/live?vhost=__defaultVhost__/test_720p':
Metadata:
|RtmpSampleAccess: true
fileSize : 0
audiochannels : 2
2.1 : false
3.1 : false
4.0 : false
4.1 : false
5.1 : false
7.1 : false
server_version : 4.0.268
server : SRS/4.0.268(Leo)
encoder : Lavf58.76.100
Stream #0:0: Video: h264 ([7][0][0][0] / 0x0007), yuv420p(tv, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 2000 kb/s, 25 fps, 1k tbn
Metadata:
encoder : Lavc58.134.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/2000000 buffer size: 0 vbv_delay: N/A
Stream #0:1: Audio: aac (LC) ([10][0][0][0] / 0x000A), 44100 Hz, stereo, fltp, 128 kb/s
Metadata:
encoder : Lavc58.134.100 aac
frhb64652ds objs # q=23.0 size= 3111kB time=00:00:15.30 bitrate=1665.6kbits/s dup=0 drop=74 speed= 1.1x
What is the latency?
Try adding the following parameter to ffmpeg:
-c:v libx264 -x264-params 'preset=ultrafast:bframes=0:tune=zerolatency'
Latency is over 4-5 seconds (transcoded vs source) I'll try zerolatency preset options.
Latency is over 4-5 seconds (transcoded vs source) I'll try zerolatency preset options.
Is the options work well?
Latency is 6 seconds between origin and transcoded version.
# conf/ffmpeg.transcode.conf
listen 19356;
max_connections 1000;
http_api {
enabled on;
listen 1985; # Specify the desired port for the HTTP API
crossdomain on;
raw_api {
enabled off;
allow_reload off;
allow_query off;
allow_update off;
}
}
vhost __defaultVhost__ {
exec {
enabled on;
publish /usr/local/bin/ffmpeg -hide_banner -loglevel error -fflags nobuffer -flags low_delay -re -i [url] -c:v libx264 -x264-params 'preset=ultrafast:bframes=0:tune=zerolatency' -b:v 2000k -vf 'scale=1280:720:force_original_aspect_ratio=decrease' -async 1 -vsync 1 -c:a aac -b:a 96k -f flv rtmp://127.0.0.1:[port]/[app]?vhost=transcode.local/[stream]_720p -c:v libx264 -x264-params 'preset=ultrafast:bframes=0:tune=zerolatency' -b:v 1200k -vf 'scale=960:540:force_original_aspect_ratio=decrease' -c:a aac -b:a 96k -f flv rtmp://127.0.0.1:[port]/[app]?vhost=transcode.local/[stream]_540p -c:v libx264 -x264-params 'preset=ultrafast:bframes=0:tune=zerolatency' -b:v 550k -vf 'scale=640:360:force_original_aspect_ratio=decrease' -c:a aac -b:a 96k -f flv rtmp://127.0.0.1:[port]/[app]?vhost=transcode.local/[stream]_360p;
}
}
vhost transcode.local {
exec {
enabled off;
}
}
Latency is 6 seconds between origin and transcoded version.
# conf/ffmpeg.transcode.conf listen 19356; max_connections 1000; http_api { enabled on; listen 1985; # Specify the desired port for the HTTP API crossdomain on; raw_api { enabled off; allow_reload off; allow_query off; allow_update off; } } vhost __defaultVhost__ { exec { enabled on; publish /usr/local/bin/ffmpeg -hide_banner -loglevel error -fflags nobuffer -flags low_delay -re -i [url] -c:v libx264 -x264-params 'preset=ultrafast:bframes=0:tune=zerolatency' -b:v 2000k -vf 'scale=1280:720:force_original_aspect_ratio=decrease' -async 1 -vsync 1 -c:a aac -b:a 96k -f flv rtmp://127.0.0.1:[port]/[app]?vhost=transcode.local/[stream]_720p -c:v libx264 -x264-params 'preset=ultrafast:bframes=0:tune=zerolatency' -b:v 1200k -vf 'scale=960:540:force_original_aspect_ratio=decrease' -c:a aac -b:a 96k -f flv rtmp://127.0.0.1:[port]/[app]?vhost=transcode.local/[stream]_540p -c:v libx264 -x264-params 'preset=ultrafast:bframes=0:tune=zerolatency' -b:v 550k -vf 'scale=640:360:force_original_aspect_ratio=decrease' -c:a aac -b:a 96k -f flv rtmp://127.0.0.1:[port]/[app]?vhost=transcode.local/[stream]_360p; } } vhost transcode.local { exec { enabled off; } }
![]()
You should not use the -re
option in ffmpeg command line.
In my test, it works well
Description
There is a huge latency between origin stream and transcoded stream in SRS4. I tested with both transcode option and exec method. I also tested original stream to compare.
SRS Version: srs-server-4.0-r4
SRS Log:
also tested with
Replay
Please describe how to replay the bug?
Step 1: publish a video with OBS using a microtimer with rtmp protocol
Step 2: play transcoded video with ffplay -fflags nobuffer -flags low_delay -i rtmp://xx.domain.com:19356/live/test_720p
Step 3: compare timestamp with OBS and transcoded video playback from srs
Expect
When I test timestamp on original video which is .../live/test and what I see on my OBS, it is under 500 ms which is awesome. However, for transcoded video, time difference is above 10 seconds without ffmpeg -re option, and with ffmpeg -re option it is 4 to 5 seconds which is unacceptable.
When I use a similar method in mediamtx (formerly known as rtsp-simple-server) it works just fine and the latency is minimal.
My server specs: i7-9700K and 64G ram, cpu utilization is around 25% of total system so it's not from ffmpeg transcoding.