If I do this ffmpeg -f dshow -video_size 720x480 -framerate 29.97 -i video="Roxio Video Capture USB":audio="Line (Roxio Video Capture USB)" -c:v mjpeg -c:a pcm_s16le -map 0:v -map 0:a -f fifo -fifo_format nut -drop_pkts_on_overflow 1 tcp://localhost:6600

I can connect to TCP from a player only once. The NUT headers are in the FIFO and part of the video stream is dropped so I stay close to real-time, but if I disconnect I've lost the nut headers and no player will reconnect even though the TCP port is still sending data. Is there any way, BESIDES USING MPEG Transport Stream, to resend the headers?


Although probably not best practice, this seems to do the trick:

Take a NUT file, same codec and dimensions; ffmpeg -i nutfile1.nut -frames 2 -c:a copy -c:v copy -f nut nutheader.nut

And then a little piping hijinks:

nc 6600 | cat nutheader.nut - | ffmpeg -i pipe:0 -c:a copy -c:v copy -map 0:a -map 0:v -f fifo -fifo-format nut -drop_pkts_on_overflow 1 pipe:1 | nc -L -p 6601

You get a 'discontinuous DTS' when you connect the first time and headers are duplicated, but whatever.

And you get one 'packet damaged' when you start the standard input after the headers, but it immediately and with extremely low latency resynchronizes.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.