0

The issue: I need to convert an h.264 stream streamed over RTP into MJPEG, but for very convoluted reasons I am required to use the libjpeg-turbo library, not the mjpeg encoder that comes with ffmpeg. So the only thing FFMPEG needs to do is convert the h.264 RTP stream to rawvideo in RGBA and output to a socket where I then manually do the transcoding.

However, libjpeg-turbo only expects complete frames, meaning I need to collect rawvideo packet fragments and somehow synchronize them. Putting incoming raw video fragments into a buffer as they come results in heavily broken images.

Is there some way of saving the header information of the initial h.264 RTP packets? The command I'm currently using is very straightforward:

-i rtsp://: -vcodec rawvideo -f rawvideo udp://:

  • ffmpeg should only flush output in full frames. Your command snippet does not show any conversion to RGBA so I suspect it's simply a matter of pixel format incompatibility. – Gyan Sep 14 '21 at 04:20
  • That doesn't sound right, it's clearly fragmented just parsing the packets (ie if i just do vcodec copy). Also i added the rgba pixel format and the overall frame is still garbled – SOSparachuter1 Sep 14 '21 at 04:30
  • The frames output by the RTP server is themselves fragmented (chunks of around 2000 bytes) – SOSparachuter1 Sep 14 '21 at 04:37
  • The input fragmentation has no bearing on the output. ffmpeg can only decode a packet once it's complete. The rawvideo encoder will only emit full frames. Show full command and a screenshot of what garbled frame you see. – Gyan Sep 14 '21 at 04:41
  • I see. Full command is: -i rtsp://127.0.0.1:554 -vcodec rawvideo -pix_fmt rgba -an -f rawvideo udp://127.0.0.1:4568 My work computer is off atm so I can't show a screenshot of the frame, but it's easy to describe: certain parts of the frame are perfectly complete (I can tell what the image should be), almost like a randomly shuffled puzzle. Others are more randomly mixed up. – SOSparachuter1 Sep 14 '21 at 04:55
  • That sounds like your UDP receiver has not fully re-ordered the fragments received to assemble the packet in correct sequence. – Gyan Sep 14 '21 at 06:22

0 Answers0