The two things that are CPU intensive in this pipeline are the jpegdec and the jpegenc.
You probably don’t really need that if you receive JPEG data already.
Does ... ! jpegparse ! avimux ! filesink location=... not work?
On a side note, it is 2024 and no one should be creating AVI files any more, I would suggest matroskamux min-index-interval=5000000000 if you don’t have any strong preferences (I’m not sure if the min-index-interval is required here, just making sure that it won’t create too many seek table entries, since JPEG is a keyframe only format).
The other thing that’s suboptimal with this pipeline is that you’re apparently just sending bits of raw JPEG data across the network.
If you have control over both the sender and the receiver I would suggest you use rtpjpegpay on the sender side and then rtpjpegdepay on the receiver side.
Putting the framerate here in the caps shouldn’t really make any difference (although it might be written into the matroska header), what actually counts are the timestamps on the buffers.
The sender determines the framerate at which it sends the data.
If you want to change the framerate you can do that using the videorate element with e.g. ... ! videorate ! image/jpeg,framerate=5/1 ! ... which willl insert/drop frames and retimestamp them to match the target framerate.
This remaining pipeline shouldn’t use very much CPU in any case.