#11132: TCP multi-client mode does not work
-------------------------------------+-------------------------------------
             Reporter:               |                     Type:  defect
  GermanGeraskin                     |
               Status:  new          |                 Priority:  normal
            Component:               |                  Version:
  undetermined                       |  unspecified
             Keywords:  tcp, multi-  |               Blocked By:
  client                             |
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
-------------------------------------+-------------------------------------
 ### What I was trying to accomplish
 I am trying to transfer video data via TCP connection.

 ### The problem I encountered
 FFmpeg resets the TCP connection if the *multi-client* mode is used
 (`listen=2`).

 The [documentation](https://ffmpeg.org/ffmpeg-all.html#toc-tcp) states the
 following:
 > listen=2|1|0
 >   Listen for an incoming connection. 0 disables listen, 1 enables listen
 in single client mode, 2 enables listen in multi-client mode. Default
 value is 0.

 ### The exact command line I am using

 ffmpeg **server**:

 ```shell
 ./ffmpeg \
 -v 9 \
 -loglevel 99 \
 -f rawvideo \
 -video_size 1920x1080 \
 -pixel_format yuv420p \
 -framerate 25 \
 -i 'tcp://127.0.0.1:19010?listen=2' \
 -pix_fmt yuv420p \
 -c:v h264_nvenc \
 -preset p4 \
 -rc vbr \
 -cq 30 \
 -an \
 -f flv \
 rtmp://127.0.0.1:1935/temp/qqq
 ```


 ffmpeg **client**:

 ```shell
 ./ffmpeg \
 -v 9 \
 -loglevel 99 \
 -f decklink \
 -format_code Hp25 \
 -i 'DeckLink Quad (1)' \
 -pix_fmt yuv420p \
 -r 25 \
 -f rawvideo \
 tcp://127.0.0.1:19010?tcp_nodelay=1
 ```


 ### Console output

 ffmpeg **server**:

 ```shell
  ./ffmpeg \
 > -v 9 \
 > -loglevel 99 \
 > -f rawvideo \
 > -video_size 1920x1080 \
 > -pixel_format yuv420p \
 > -framerate 25 \
 > -i 'tcp://127.0.0.1:19010?listen=2' \
 > -pix_fmt yuv420p \
 > -c:v h264_nvenc \
 > -preset p4 \
 > -rc vbr \
 > -cq 30 \
 > -an \
 > -f flv \
 > rtmp://127.0.0.1:1935/temp/qqq
 ffmpeg version n7.0.2 Copyright (c) 2000-2024 the FFmpeg developers
   built with gcc 11 (Ubuntu 11.4.0-1ubuntu1~22.04)
   configuration: --pkg-config-flags=--static --extra-
 cflags=-I/usr/include/DeckLink --extra-libs='-lpthread -lm -ldl' --ld=g++
 --enable-gpl --enable-nonfree --enable-pthreads --enable-avfilter
 --enable-libx264 --enable-nvenc --enable-decklink --enable-ffplay
 --enable-libzmq --enable-gnutls --enable-libass --enable-libfdk-aac
 --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-
 libvorbis --enable-libvpx --enable-libx264 --enable-libx265
   libavutil      59.  8.100 / 59.  8.100
   libavcodec     61.  3.100 / 61.  3.100
   libavformat    61.  1.100 / 61.  1.100
   libavdevice    61.  1.100 / 61.  1.100
   libavfilter    10.  1.100 / 10.  1.100
   libswscale      8.  1.100 /  8.  1.100
   libswresample   5.  1.100 /  5.  1.100
   libpostproc    58.  1.100 / 58.  1.100
 Splitting the commandline.
 Reading option '-v' ... matched as option 'v' (set logging level) with
 argument '9'.
 Reading option '-loglevel' ... matched as option 'loglevel' (set logging
 level) with argument '99'.
 Reading option '-f' ... matched as option 'f' (force container format
 (auto-detected otherwise)) with argument 'rawvideo'.
 Reading option '-video_size' ... matched as AVOption 'video_size' with
 argument '1920x1080'.
 Reading option '-pixel_format' ... matched as AVOption 'pixel_format' with
 argument 'yuv420p'.
 Reading option '-framerate' ... matched as AVOption 'framerate' with
 argument '25'.
 Reading option '-i' ... matched as input url with argument
 'tcp://127.0.0.1:19010?listen=2'.
 Reading option '-pix_fmt' ... matched as option 'pix_fmt' (set pixel
 format) with argument 'yuv420p'.
 Reading option '-c:v' ... matched as option 'c' (select encoder/decoder
 ('copy' to copy stream without reencoding)) with argument 'h264_nvenc'.
 Reading option '-preset' ... matched as AVOption 'preset' with argument
 'p4'.
 Reading option '-rc' ... matched as AVOption 'rc' with argument 'vbr'.
 Reading option '-cq' ... matched as AVOption 'cq' with argument '30'.
 Reading option '-an' ... matched as option 'an' (disable audio) with
 argument '1'.
 Reading option '-f' ... matched as option 'f' (force container format
 (auto-detected otherwise)) with argument 'flv'.
 Reading option 'rtmp://127.0.0.1:1935/temp/qqq' ... matched as output url.
 Finished splitting the commandline.
 Parsing a group of options: global .
 Applying option v (set logging level) with argument 9.
 Successfully parsed a group of options.
 Parsing a group of options: input url tcp://127.0.0.1:19010?listen=2.
 Applying option f (force container format (auto-detected otherwise)) with
 argument rawvideo.
 Successfully parsed a group of options.
 Opening an input file: tcp://127.0.0.1:19010?listen=2.
 [rawvideo @ 0x555b20ecc040] Opening 'tcp://127.0.0.1:19010?listen=2' for
 reading
 [tcp @ 0x555b20ecc8c0] No default whitelist set
 [rawvideo @ 0x555b20ecc040] Before avformat_find_stream_info() pos: 0
 bytes read:0 seeks:0 nb_streams:1
 [rawvideo @ 0x555b20ecc040] stream 0: start_time: NOPTS duration: NOPTS
 [rawvideo @ 0x555b20ecc040] format: start_time: NOPTS duration: NOPTS
 (estimate from bit rate) bitrate=622080 kb/s
 [rawvideo @ 0x555b20ecc040] After avformat_find_stream_info() pos: 0 bytes
 read:0 seeks:0 frames:0
 Input #0, rawvideo, from 'tcp://127.0.0.1:19010?listen=2':
   Duration: N/A, bitrate: 622080 kb/s
   Stream #0:0, 0, 1/25: Video: rawvideo, 1 reference frame (I420 /
 0x30323449), yuv420p, 1920x1080, 0/1, 622080 kb/s, 25 tbr, 25 tbn
 Successfully opened the file.
 Parsing a group of options: output url rtmp://127.0.0.1:1935/temp/qqq.
 Applying option pix_fmt (set pixel format) with argument yuv420p.
 Applying option c:v (select encoder/decoder ('copy' to copy stream without
 reencoding)) with argument h264_nvenc.
 Applying option an (disable audio) with argument 1.
 Applying option f (force container format (auto-detected otherwise)) with
 argument flv.
 Successfully parsed a group of options.
 Opening an output file: rtmp://127.0.0.1:1935/temp/qqq.
 [out#0/flv @ 0x555b20edecc0] No explicit maps, mapping streams
 automatically...
 [vost#0:0/h264_nvenc @ 0x555b20edf980] Created video stream from input
 stream 0:0
 [rtmp @ 0x555b20f00240] No default whitelist set
 [tcp @ 0x555b20effdc0] No default whitelist set
 [tcp @ 0x555b20effdc0] Original list of addresses:
 [tcp @ 0x555b20effdc0] Address 127.0.0.1 port 1935
 [tcp @ 0x555b20effdc0] Interleaved list of addresses:
 [tcp @ 0x555b20effdc0] Address 127.0.0.1 port 1935
 [tcp @ 0x555b20effdc0] Starting connection attempt to 127.0.0.1 port 1935
 [tcp @ 0x555b20effdc0] Successfully connected to 127.0.0.1 port 1935
 [rtmp @ 0x555b20f00240] Handshaking...
 [rtmp @ 0x555b20f00240] Type answer 3
 [rtmp @ 0x555b20f00240] Server version 3.0.1.1
 [rtmp @ 0x555b20f00240] Proto = rtmp, path = /temp/qqq, app = temp, fname
 = qqq
 [rtmp @ 0x555b20f00240] Window acknowledgement size = 2500000
 [rtmp @ 0x555b20f00240] Max sent, unacked = 2500000
 [rtmp @ 0x555b20f00240] New incoming chunk size = 4096
 [rtmp @ 0x555b20f00240] Releasing stream...
 [rtmp @ 0x555b20f00240] FCPublish stream...
 [rtmp @ 0x555b20f00240] Creating stream...
 [rtmp @ 0x555b20f00240] Sending publish command for 'qqq'
 Successfully opened the file.
 Stream mapping:
   Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (h264_nvenc))
 [vost#0:0/h264_nvenc @ 0x555b20edf980] Starting thread...
 [vf#0:0 @ 0x555b20efc540] Starting thread...
 [vist#0:0/rawvideo @ 0x555b20ede5c0] [dec:rawvideo @ 0x555b20efe100]
 Starting thread...
 [in#0/rawvideo @ 0x555b20ecbd00] Starting thread...
 Press [q] to stop, [?] for help
 [in#0/rawvideo @ 0x555b20ecbd00] Error during demuxing: Transport endpoint
 is not connected
 [in#0/rawvideo @ 0x555b20ecbd00] Terminating thread with return code 0
 (success)
 [vist#0:0/rawvideo @ 0x555b20ede5c0] [dec:rawvideo @ 0x555b20efe100]
 Decoder thread received EOF packet
 [vist#0:0/rawvideo @ 0x555b20ede5c0] [dec:rawvideo @ 0x555b20efe100]
 Decoder returned EOF, finishing
 [vist#0:0/rawvideo @ 0x555b20ede5c0] [dec:rawvideo @ 0x555b20efe100]
 Terminating thread with return code 0 (success)
 detected 40 logical cores
 [graph 0 input from stream 0:0 @ 0x7f6a4c003900] Setting 'video_size' to
 value '1920x1080'
 [graph 0 input from stream 0:0 @ 0x7f6a4c003900] Setting 'pix_fmt' to
 value '0'
 [graph 0 input from stream 0:0 @ 0x7f6a4c003900] Setting 'time_base' to
 value '1/25'
 [graph 0 input from stream 0:0 @ 0x7f6a4c003900] Setting 'pixel_aspect' to
 value '0/1'
 [graph 0 input from stream 0:0 @ 0x7f6a4c003900] Setting 'colorspace' to
 value '2'
 [graph 0 input from stream 0:0 @ 0x7f6a4c003900] Setting 'range' to value
 '0'
 [graph 0 input from stream 0:0 @ 0x7f6a4c003900] Setting 'frame_rate' to
 value '25/1'
 [graph 0 input from stream 0:0 @ 0x7f6a4c003900] w:1920 h:1080
 pixfmt:yuv420p tb:1/25 fr:25/1 sar:0/1 csp:unknown range:unknown
 [format @ 0x7f6a4c005340] Setting 'pix_fmts' to value 'yuv420p'
 [AVFilterGraph @ 0x7f6a4c000fc0] query_formats: 4 queried, 9 merged, 0
 already done, 0 delayed
 [out_0_0 @ 0x7f6a4c005040] EOF on sink link out_0_0:default.
 [vf#0:0 @ 0x555b20efc540] Filtergraph returned EOF, finishing
 [vf#0:0 @ 0x555b20efc540] All consumers returned EOF
 [vost#0:0/h264_nvenc @ 0x555b20edf980] No filtered frames for output
 stream, trying to initialize anyway.
 [h264_nvenc @ 0x555b20edfec0] Loaded lib: libcuda.so.1
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuInit
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuDriverGetVersion
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuDeviceGetCount
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuDeviceGet
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuDeviceGetAttribute
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuDeviceGetName
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuDeviceComputeCapability
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuCtxCreate_v2
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuCtxGetCurrent
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuCtxSetLimit
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuCtxPushCurrent_v2
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuCtxPopCurrent_v2
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuCtxDestroy_v2
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuMemAlloc_v2
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuMemAllocPitch_v2
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuMemAllocManaged
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuMemsetD8Async
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuMemFree_v2
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuMemcpy
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuMemcpyAsync
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuMemcpy2D_v2
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuMemcpy2DAsync_v2
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuMemcpyHtoD_v2
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuMemcpyHtoDAsync_v2
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuMemcpyDtoH_v2
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuMemcpyDtoHAsync_v2
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuMemcpyDtoD_v2
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuMemcpyDtoDAsync_v2
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuGetErrorName
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuGetErrorString
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuCtxGetDevice
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuDevicePrimaryCtxRetain
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuDevicePrimaryCtxRelease
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuDevicePrimaryCtxSetFlags
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuDevicePrimaryCtxGetState
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuDevicePrimaryCtxReset
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuStreamCreate
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuStreamQuery
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuStreamSynchronize
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuStreamDestroy_v2
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuStreamAddCallback
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuStreamWaitEvent
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuEventCreate
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuEventDestroy_v2
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuEventSynchronize
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuEventQuery
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuEventRecord
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuLaunchKernel
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuLinkCreate
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuLinkAddData
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuLinkComplete
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuLinkDestroy
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuModuleLoadData
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuModuleUnload
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuModuleGetFunction
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuModuleGetGlobal
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuTexObjectCreate
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuTexObjectDestroy
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuGLGetDevices_v2
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuGraphicsGLRegisterImage
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuGraphicsUnregisterResource
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuGraphicsMapResources
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuGraphicsUnmapResources
 [h264_nvenc @ 0x555b20edfec0] Loaded sym:
 cuGraphicsSubResourceGetMappedArray
 [h264_nvenc @ 0x555b20edfec0] Loaded sym:
 cuGraphicsResourceGetMappedPointer_v2
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuDeviceGetUuid
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuDeviceGetUuid_v2
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuDeviceGetLuid
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuDeviceGetByPCIBusId
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuDeviceGetPCIBusId
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuImportExternalMemory
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuDestroyExternalMemory
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuExternalMemoryGetMappedBuffer
 [h264_nvenc @ 0x555b20edfec0] Loaded sym:
 cuExternalMemoryGetMappedMipmappedArray
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuMipmappedArrayGetLevel
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuMipmappedArrayDestroy
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuImportExternalSemaphore
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuDestroyExternalSemaphore
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuSignalExternalSemaphoresAsync
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuWaitExternalSemaphoresAsync
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuArrayCreate_v2
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuArray3DCreate_v2
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuArrayDestroy
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuEGLStreamProducerConnect
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuEGLStreamProducerDisconnect
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuEGLStreamConsumerDisconnect
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuEGLStreamProducerPresentFrame
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: cuEGLStreamProducerReturnFrame
 [h264_nvenc @ 0x555b20edfec0] Loaded lib: libnvidia-encode.so.1
 [h264_nvenc @ 0x555b20edfec0] Loaded sym: NvEncodeAPICreateInstance
 [h264_nvenc @ 0x555b20edfec0] Loaded sym:
 NvEncodeAPIGetMaxSupportedVersion
 [h264_nvenc @ 0x555b20edfec0] Loaded Nvenc version 12.2
 [h264_nvenc @ 0x555b20edfec0] Nvenc initialized successfully
 [h264_nvenc @ 0x555b20edfec0] Calling dl_fn->cuda_dl->cuInit(0)
 [h264_nvenc @ 0x555b20edfec0] Calling
 dl_fn->cuda_dl->cuDeviceGetCount(&nb_devices)
 [h264_nvenc @ 0x555b20edfec0] 2 CUDA capable devices found
 [h264_nvenc @ 0x555b20edfec0] Calling
 dl_fn->cuda_dl->cuDeviceGet(&cu_device, idx)
 [h264_nvenc @ 0x555b20edfec0] Calling
 dl_fn->cuda_dl->cuDeviceGetName(name, sizeof(name), cu_device)
 [h264_nvenc @ 0x555b20edfec0] Calling
 dl_fn->cuda_dl->cuDeviceComputeCapability(&major, &minor, cu_device)
 [h264_nvenc @ 0x555b20edfec0] [ GPU #0 - < Quadro P2000 > has Compute SM
 6.1 ]
 [h264_nvenc @ 0x555b20edfec0] Calling
 dl_fn->cuda_dl->cuCtxCreate(&ctx->cu_context_internal, 0, cu_device)
 [h264_nvenc @ 0x555b20edfec0] Calling
 dl_fn->cuda_dl->cuCtxPopCurrent(&dummy)
 [h264_nvenc @ 0x555b20edfec0] supports NVENC
 [h264_nvenc @ 0x555b20edfec0] CQ(7680) mode enabled.
 [h264_nvenc @ 0x555b20edfec0] Calling
 dl_fn->cuda_dl->cuCtxPushCurrent(ctx->cu_context)
 [h264_nvenc @ 0x555b20edfec0] Calling
 dl_fn->cuda_dl->cuCtxPopCurrent(&dummy)
 [h264_nvenc @ 0x555b20edfec0] Calling
 dl_fn->cuda_dl->cuCtxPushCurrent(ctx->cu_context)
 [h264_nvenc @ 0x555b20edfec0] Calling
 dl_fn->cuda_dl->cuCtxPopCurrent(&dummy)
 Output #0, flv, to 'rtmp://127.0.0.1:1935/temp/qqq':
   Metadata:
     encoder         : Lavf61.1.100
   Stream #0:0, 0, 1/1000: Video: h264 (Main), 1 reference frame
 ([7][0][0][0] / 0x0007), yuv420p(progressive), 1920x1080, 0/1, q=2-31, 25
 fps, 1k tbn
       Metadata:
         encoder         : Lavc61.3.100 h264_nvenc
       Side data:
         cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
 [out#0/flv @ 0x555b20edecc0] Starting thread...
 [vost#0:0/h264_nvenc @ 0x555b20edf980] Encoder thread received EOF
 [h264_nvenc @ 0x555b20edfec0] Calling
 dl_fn->cuda_dl->cuCtxPushCurrent(ctx->cu_context)
 [h264_nvenc @ 0x555b20edfec0] Calling
 dl_fn->cuda_dl->cuCtxPopCurrent(&dummy)
 [vost#0:0/h264_nvenc @ 0x555b20edf980] Terminating thread with return code
 0 (success)
 [vf#0:0 @ 0x555b20efc540] Terminating thread with return code 0 (success)
 [out#0/flv @ 0x555b20edecc0] All streams finished
 [out#0/flv @ 0x555b20edecc0] Terminating thread with return code 0
 (success)
 [flv @ 0x555b20edee00] Failed to update header with correct duration.
 [flv @ 0x555b20edee00] Failed to update header with correct filesize.
 [AVIOContext @ 0x555b20f01140] Statistics: 303 bytes written, 0 seeks, 2
 writeouts
 [rtmp @ 0x555b20f00240] UnPublishing stream...
 [rtmp @ 0x555b20f00240] Deleting stream...
 [out#0/flv @ 0x555b20edecc0] Output file #0
 (rtmp://127.0.0.1:1935/temp/qqq):
 [out#0/flv @ 0x555b20edecc0]   Output stream #0:0 (video): 0 frames
 encoded; 0 packets muxed (0 bytes);
 [out#0/flv @ 0x555b20edecc0]   Total: 0 packets (0 bytes) muxed
 [out#0/flv @ 0x555b20edecc0] video:0KiB audio:0KiB subtitle:0KiB other
 streams:0KiB global headers:0KiB muxing overhead: unknown
 [out#0/flv @ 0x555b20edecc0] Output file is empty, nothing was
 encoded(check -ss / -t / -frames parameters if used)
 frame=    0 fps=0.0 q=0.0 Lsize=       0KiB time=N/A bitrate=N/A speed=N/A
 [h264_nvenc @ 0x555b20edfec0] Calling
 dl_fn->cuda_dl->cuCtxPushCurrent(ctx->cu_context)
 [h264_nvenc @ 0x555b20edfec0] Calling
 dl_fn->cuda_dl->cuCtxPopCurrent(&dummy)
 [h264_nvenc @ 0x555b20edfec0] Calling
 dl_fn->cuda_dl->cuCtxDestroy(ctx->cu_context_internal)
 [h264_nvenc @ 0x555b20edfec0] Nvenc unloaded
 [in#0/rawvideo @ 0x555b20ecbd00] Input file #0
 (tcp://127.0.0.1:19010?listen=2):
 [in#0/rawvideo @ 0x555b20ecbd00]   Input stream #0:0 (video): 0 packets
 read (0 bytes); 0 frames decoded; 0 decode errors;
 [in#0/rawvideo @ 0x555b20ecbd00]   Total: 0 packets (0 bytes) demuxed
 [AVIOContext @ 0x555b20edcd80] Statistics: 0 bytes read, 0 seeks
 ```


 ffmpeg **client**:

 ```shell
  ./ffmpeg \
 > -v 9 \
 > -loglevel 99 \
 > -f decklink \
 > -format_code Hp25 \
 > -i 'DeckLink Quad (1)' \
 > -pix_fmt yuv420p \
 > -r 25 \
 > -f rawvideo \
 > tcp://127.0.0.1:19010?tcp_nodelay=1
 ffmpeg version n7.0.2 Copyright (c) 2000-2024 the FFmpeg developers
   built with gcc 11 (Ubuntu 11.4.0-1ubuntu1~22.04)
   configuration: --pkg-config-flags=--static --extra-
 cflags=-I/usr/include/DeckLink --extra-libs='-lpthread -lm -ldl' --ld=g++
 --enable-gpl --enable-nonfree --enable-pthreads --enable-avfilter
 --enable-libx264 --enable-nvenc --enable-decklink --enable-ffplay
 --enable-libzmq --enable-gnutls --enable-libass --enable-libfdk-aac
 --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-
 libvorbis --enable-libvpx --enable-libx264 --enable-libx265
   libavutil      59.  8.100 / 59.  8.100
   libavcodec     61.  3.100 / 61.  3.100
   libavformat    61.  1.100 / 61.  1.100
   libavdevice    61.  1.100 / 61.  1.100
   libavfilter    10.  1.100 / 10.  1.100
   libswscale      8.  1.100 /  8.  1.100
   libswresample   5.  1.100 /  5.  1.100
   libpostproc    58.  1.100 / 58.  1.100
 Splitting the commandline.
 Reading option '-v' ... matched as option 'v' (set logging level) with
 argument '9'.
 Reading option '-loglevel' ... matched as option 'loglevel' (set logging
 level) with argument '99'.
 Reading option '-f' ... matched as option 'f' (force container format
 (auto-detected otherwise)) with argument 'decklink'.
 Reading option '-format_code' ... matched as AVOption 'format_code' with
 argument 'Hp25'.
 Reading option '-i' ... matched as input url with argument 'DeckLink Quad
 (1)'.
 Reading option '-pix_fmt' ... matched as option 'pix_fmt' (set pixel
 format) with argument 'yuv420p'.
 Reading option '-r' ... matched as option 'r' (override input
 framerate/convert to given output framerate (Hz value, fraction or
 abbreviation)) with argument '25'.
 Reading option '-f' ... matched as option 'f' (force container format
 (auto-detected otherwise)) with argument 'rawvideo'.
 Reading option 'tcp://127.0.0.1:19010?tcp_nodelay=1' ... matched as output
 url.
 Finished splitting the commandline.
 Parsing a group of options: global .
 Applying option v (set logging level) with argument 9.
 Successfully parsed a group of options.
 Parsing a group of options: input url DeckLink Quad (1).
 Applying option f (force container format (auto-detected otherwise)) with
 argument decklink.
 Successfully parsed a group of options.
 Opening an input file: DeckLink Quad (1).
 [decklink @ 0x55e3e8fcff40] Trying to find mode for frame size 0x0, frame
 timing 0/0, field order 0, direction 0, format code Hp25
 [decklink @ 0x55e3e8fcff40] Found Decklink mode 1920 x 1080 with rate
 25.00
 [decklink @ 0x55e3e8fcff40] Using 2 input audio channels
 [decklink @ 0x55e3e8fcff40] Frame received (#1) - No input signal detected
 - Frames dropped 1
 [decklink @ 0x55e3e8fcff40] Probe buffer size limit of 5000000 bytes
 reached
 [decklink @ 0x55e3e8fcff40] stream 0: start_time: 0 duration: NOPTS
 [decklink @ 0x55e3e8fcff40] stream 1: start_time: 0 duration: NOPTS
 [decklink @ 0x55e3e8fcff40] format: start_time: 0 duration: NOPTS
 (estimate from bit rate) bitrate=830976 kb/s
 [aist#0:0/pcm_s16le @ 0x55e3e8fef240] Guessed Channel Layout: stereo
 Input #0, decklink, from 'DeckLink Quad (1)':
   Duration: N/A, start: 0.000000, bitrate: 830976 kb/s
   Stream #0:0, 1, 1/1000000: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536
 kb/s
   Stream #0:1, 2, 1/1000000: Video: rawvideo, 1 reference frame (UYVY /
 0x59565955), uyvy422(progressive), 1920x1080, 0/1, 829440 kb/s, 25 tbr,
 1000k tbn
 Successfully opened the file.
 Parsing a group of options: output url
 tcp://127.0.0.1:19010?tcp_nodelay=1.
 Applying option pix_fmt (set pixel format) with argument yuv420p.
 Applying option r (override input framerate/convert to given output
 framerate (Hz value, fraction or abbreviation)) with argument 25.
 Applying option f (force container format (auto-detected otherwise)) with
 argument rawvideo.
 Successfully parsed a group of options.
 Opening an output file: tcp://127.0.0.1:19010?tcp_nodelay=1.
 [out#0/rawvideo @ 0x55e3e8ff5040] No explicit maps, mapping streams
 automatically...
 [vost#0:0/rawvideo @ 0x55e3e8ff5a80] Created video stream from input
 stream 0:1
 [tcp @ 0x55e3e901a780] No default whitelist set
 [tcp @ 0x55e3e901a780] Original list of addresses:
 [tcp @ 0x55e3e901a780] Address 127.0.0.1 port 19010
 [tcp @ 0x55e3e901a780] Interleaved list of addresses:
 [tcp @ 0x55e3e901a780] Address 127.0.0.1 port 19010
 [tcp @ 0x55e3e901a780] Starting connection attempt to 127.0.0.1 port 19010
 [tcp @ 0x55e3e901a780] Successfully connected to 127.0.0.1 port 19010
 Successfully opened the file.
 Stream mapping:
   Stream #0:1 -> #0:0 (rawvideo (native) -> rawvideo (native))
 [vost#0:0/rawvideo @ 0x55e3e8ff5a80] Starting thread...
 [vf#0:0 @ 0x55e3e8ff0c80] Starting thread...
 [vist#0:1/rawvideo @ 0x55e3e8ff4580] [dec:rawvideo @ 0x55e3e8ff28c0]
 Starting thread...
 [in#0/decklink @ 0x55e3e8fcfbc0] Starting thread...
 Press [q] to stop, [?] for help
 [rawvideo @ 0x55e3e90192c0] PACKET SIZE: 4147200, STRIDE: 3840
     Last message repeated 1 times
 detected 40 logical cores
 [graph 0 input from stream 0:1 @ 0x7f89a0003b40] Setting 'video_size' to
 value '1920x1080'
 [graph 0 input from stream 0:1 @ 0x7f89a0003b40] Setting 'pix_fmt' to
 value '15'
 [graph 0 input from stream 0:1 @ 0x7f89a0003b40] Setting 'time_base' to
 value '1/1000000'
 [graph 0 input from stream 0:1 @ 0x7f89a0003b40] Setting 'pixel_aspect' to
 value '0/1'
 [graph 0 input from stream 0:1 @ 0x7f89a0003b40] Setting 'colorspace' to
 value '2'
 [graph 0 input from stream 0:1 @ 0x7f89a0003b40] Setting 'range' to value
 '0'
 [graph 0 input from stream 0:1 @ 0x7f89a0003b40] Setting 'frame_rate' to
 value '25000/1000'
 [graph 0 input from stream 0:1 @ 0x7f89a0003b40] w:1920 h:1080
 pixfmt:uyvy422 tb:1/1000000 fr:25000/1000 sar:0/1 csp:unknown
 range:unknown
 [format @ 0x7f89a0005500] Setting 'pix_fmts' to value 'yuv420p'
 [auto_scale_0 @ 0x7f89a00070c0] w:iw h:ih flags:'' interl:0
 [format @ 0x7f89a0005500] auto-inserting filter 'auto_scale_0' between the
 filter 'Parsed_null_0' and the filter 'format'
 [AVFilterGraph @ 0x7f89a00011c0] query_formats: 4 queried, 6 merged, 3
 already done, 0 delayed
 [auto_scale_0 @ 0x7f89a00070c0] w:1920 h:1080 fmt:uyvy422 csp:unknown
 range:unknown sar:0/1 -> w:1920 h:1080 fmt:yuv420p csp:unknown
 range:unknown sar:0/1 flags:0x00000004
 [graph 0 input from stream 0:1 @ 0x7f89a0003b40] video frame properties
 congruent with link at pts_time: 0
 Output #0, rawvideo, to 'tcp://127.0.0.1:19010?tcp_nodelay=1':
   Metadata:
     encoder         : Lavf61.1.100
   Stream #0:0, 0, 1/25: Video: rawvideo, 1 reference frame (I420 /
 0x30323449), yuv420p(progressive), 1920x1080, 0/1, q=2-31, 622080 kb/s, 25
 fps, 25 tbn
       Metadata:
         encoder         : Lavc61.3.100 rawvideo
 [out#0/rawvideo @ 0x55e3e8ff5040] Starting thread...
 [rawvideo @ 0x55e3e90192c0] PACKET SIZE: 4147200, STRIDE: 3840
     Last message repeated 9 times
 [decklink @ 0x55e3e8fcff40] Frame received (#13) - Input returned - Frames
 dropped 2peed=0.72x
 [decklink @ 0x55e3e8fcff40] Unknown meta data DID = 0x51 SDID = 0x52
 [rawvideo @ 0x55e3e90192c0] PACKET SIZE: 4147200, STRIDE: 3840
 [decklink @ 0x55e3e8fcff40] Unknown meta data DID = 0x51 SDID = 0x52
 [rawvideo @ 0x55e3e90192c0] PACKET SIZE: 4147200, STRIDE: 3840
 [decklink @ 0x55e3e8fcff40] Unknown meta data DID = 0x51 SDID = 0x52
 [rawvideo @ 0x55e3e90192c0] PACKET SIZE: 4147200, STRIDE: 3840
 [decklink @ 0x55e3e8fcff40] Unknown meta data DID = 0x51 SDID = 0x52
 [rawvideo @ 0x55e3e90192c0] PACKET SIZE: 4147200, STRIDE: 3840
 [decklink @ 0x55e3e8fcff40] Unknown meta data DID = 0x51 SDID = 0x52
 [rawvideo @ 0x55e3e90192c0] PACKET SIZE: 4147200, STRIDE: 3840
 [decklink @ 0x55e3e8fcff40] Unknown meta data DID = 0x51 SDID = 0x52
 [rawvideo @ 0x55e3e90192c0] PACKET SIZE: 4147200, STRIDE: 3840
 [decklink @ 0x55e3e8fcff40] Unknown meta data DID = 0x51 SDID = 0x52
 [rawvideo @ 0x55e3e90192c0] PACKET SIZE: 4147200, STRIDE: 3840
 [decklink @ 0x55e3e8fcff40] Unknown meta data DID = 0x51 SDID = 0x52
 [rawvideo @ 0x55e3e90192c0] PACKET SIZE: 4147200, STRIDE: 3840
 [decklink @ 0x55e3e8fcff40] Unknown meta data DID = 0x51 SDID = 0x52
 [rawvideo @ 0x55e3e90192c0] PACKET SIZE: 4147200, STRIDE: 3840
 [vost#0:0/rawvideo @ 0x55e3e8ff5a80] Error submitting a packet to the
 muxer: Connection reset by peer
     Last message repeated 1 times
 [out#0/rawvideo @ 0x55e3e8ff5040] Error muxing a packet
 [out#0/rawvideo @ 0x55e3e8ff5040] Task finished with error code: -104
 (Connection reset by peer)
 [out#0/rawvideo @ 0x55e3e8ff5040] Terminating thread with return code -104
 (Connection reset by peer)
 [decklink @ 0x55e3e8fcff40] Unknown meta data DID = 0x51 SDID = 0x52
 [in#0/decklink @ 0x55e3e8fcfbc0] Terminating thread with return code 0
 (success)
 [vist#0:1/rawvideo @ 0x55e3e8ff4580] [dec:rawvideo @ 0x55e3e8ff28c0]
 Decoder thread received EOF packet
 [vist#0:1/rawvideo @ 0x55e3e8ff4580] [dec:rawvideo @ 0x55e3e8ff28c0]
 Decoder returned EOF, finishing
 [vist#0:1/rawvideo @ 0x55e3e8ff4580] [dec:rawvideo @ 0x55e3e8ff28c0]
 Terminating thread with return code 0 (success)
 [out_0_0 @ 0x7f89a00051c0] EOF on sink link out_0_0:default.
 [vf#0:0 @ 0x55e3e8ff0c80] Filtergraph returned EOF, finishing
 [vf#0:0 @ 0x55e3e8ff0c80] All consumers returned EOF
 [vost#0:0/rawvideo @ 0x55e3e8ff5a80] Encoder thread received EOF
 [vost#0:0/rawvideo @ 0x55e3e8ff5a80] Terminating thread with return code 0
 (success)
 [vf#0:0 @ 0x55e3e8ff0c80] Terminating thread with return code 0 (success)
 [out#0/rawvideo @ 0x55e3e8ff5040] Error writing trailer: Connection reset
 by peer
 [AVIOContext @ 0x55e3e8fef640] Statistics: 1769472 bytes written, 0 seeks,
 95 writeouts
 [out#0/rawvideo @ 0x55e3e8ff5040] Error closing file: Connection reset by
 peer
 [out#0/rawvideo @ 0x55e3e8ff5040] Output file #0
 (tcp://127.0.0.1:19010?tcp_nodelay=1):
 [out#0/rawvideo @ 0x55e3e8ff5040]   Output stream #0:0 (video): 21 frames
 encoded; 1 packets muxed (3110400 bytes);
 [out#0/rawvideo @ 0x55e3e8ff5040]   Total: 1 packets (3110400 bytes) muxed
 [out#0/rawvideo @ 0x55e3e8ff5040] video:3038KiB audio:0KiB subtitle:0KiB
 other streams:0KiB global headers:0KiB muxing overhead: unknown
 frame=    1 fps=0.0 q=-0.0 Lsize=    1728KiB time=00:00:00.36
 bitrate=39321.6kbits/s speed=0.445x
 [in#0/decklink @ 0x55e3e8fcfbc0] Input file #0 (DeckLink Quad (1)):
 [in#0/decklink @ 0x55e3e8fcfbc0]   Input stream #0:1 (video): 22 packets
 read (91238400 bytes); 21 frames decoded; 0 decode errors;
 [in#0/decklink @ 0x55e3e8fcfbc0]   Total: 22 packets (91238400 bytes)
 demuxed
 Conversion failed!
 ```


 ### Sufficient information

 - The same command using *single client* mode (`listen=1`) works fine.
 - I tested in `ffmpeg` versions `n7.0.2` and `n4.4`. They behave the same
 way.
 - When two `tcp` inputs are in use, the `ffmpeg` does NOT start listening
 the second input until the first input establishes connection.
   So it is impossible for `ffmpeg` client to connect to the second input
 of the `ffmpeg` server.
-- 
Ticket URL: <https://trac.ffmpeg.org/ticket/11132>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
_______________________________________________
FFmpeg-trac mailing list
FFmpeg-trac@avcodec.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-trac

To unsubscribe, visit link above, or email
ffmpeg-trac-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to