Streaming Jpeg to RTSP

Hi I’m trying to send multiple images (.jpeg) to RTSP. The images are written by a program in a directory named “images” and at the same time I want to stream them as they are written in the file. The images are saved as img.0000.jpeg and the number is increased when new images are created. I tried to do this using the test-readme example of GStreamer lib.
I set my factory like this :
gst_rtsp_media_factory_set_launch(factory, "( multifilesrc location=\"images.img.%04d.jpeg\" start-index=0 stop-index=0 caps=\"image/jpeg,width=640,height=512,type=video,framerate=\(fraction\)1/1\" ! identity ! jpegdec ! videoconvert ! videoscale ! videorate ! x264enc ! rtph264pay name=pay0 pt=96)");

I’m trying to read this file using VLC at the address “rtsp://127.0.0.1:8554/test” and it failed.
I also tried to read using GStreamer with this command :
gst-launch-1.0 rtspsrc location=rtsp://localhost:8554/test latency=100 ! queue ! rtph264depay ! h264parse ! avdec_h264 ! videoconvert ! videoscale ! video/x-raw,width=640,height=480 ! autovideosink

And i get this error :
Setting pipeline to PAUSED …
Pipeline is live and does not need PREROLL …
Progress: (open) Opening Stream
Progress: (connect) Connecting to rtsp://localhost:8554/test
Progress: (open) Retrieving server options
Progress: (open) Retrieving media info
ERROR: from element /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0: Unhandled error
Additional debug info:
…/gst/rtsp/gstrtspsrc.c(6564): gst_rtspsrc_send (): /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0:
Service Unavailable (503)
ERROR: pipeline doesn’t want to preroll.
Setting pipeline to PAUSED …
Setting pipeline to READY …
Setting pipeline to NULL …
Freeing pipeline …

Does anyone know what I am doing wrong here ?
Thanks in advance if anyone can help out :)

Hi,
Please try test-launch:


See if this can launch your pipeline succesfully.

Hi,
Thanks, this

$ ./test-launch ‘videotestsrc ! nvvidconv ! nvv4l2h264enc ! h264parse ! queue ! rtph264pay name=pay0 pt=96 audiotestsrc ! voaacenc ! queue ! rtpmp4apay pt=97 name=pay1’

is working and i can see it using VLC.
But when i try to do the same using test-launch and my pipeline

multifilesrc location=“images.img.%04d.jpeg” start-index=0 stop-index=0 caps=“image/jpeg,width=640,height=512,type=video,framerate=(fraction)1/1” ! identity ! jpegdec ! videoconvert ! videoscale ! videorate ! x264enc ! rtph264pay name=pay0 pt=96

VLC cannot open it.
So I suppose there is something wrong with my pipeline but i don’t know what. When i launch it gives me no error on server side.

Thanks in advance if anyone has an idea of what is wrong

The main problem may be using stop-index=0, so it stops as soon as it has started.
You may try to directly stream in JPG format with something like:

test-launch "multifilesrc location=img_%05d.jpg start-index=0 caps=image/jpeg,framerate=1/1 ! jpegparse ! rtpjpegpay name=pay0 "

If you want to transcode into H264, you would try HW jpeg decoding and HW h264 encoding with something like:

test-launch "multifilesrc location=img_%05d.jpg start-index=0 caps=image/jpeg,framerate=1/1 ! jpegparse ! nvv4l2decoder mjpeg=1 ! nvv4l2h264enc ! h264parse ! rtph264pay name=pay0 "

Hi,
Somehow framerate=1/1 seems not good. Please try framerate=10/1.

/test-launch "multifilesrc location=img_%05d.jpg caps=image/jpeg,framerate=10/1 ! jpegparse ! nvv4l2decoder mjpeg=1 ! nvvidconv ! nvv4l2h264enc ! rtph264pay name=pay0 pt=96"

Hi,

I tried this :

test-launch "multifilesrc location=img_%05d.jpg start-index=0 caps=image/jpeg,framerate=1/1 ! jpegparse ! rtpjpegpay name=pay0 "

I can launch without error but VLC isn’t able to read it I don’t know why. So I tried to read it using gst-launch like this :

gst-launch-1.0 rtspsrc location=rtsp://localhost:8554/test rtpjpegdepay ! jpegparse ! autovideosink

And it gives me this error :

Définition du pipeline à PAUSED…
Le pipeline est actif et n’a pas besoin de phase PREROLL…
Contexte de l’élément « autovideosink0-actual-sink-vaapi » : gst.vaapi.Display=context, gst.vaapi.Display=(GstVaapiDisplay)"(GstVaapiDisplayGLX)\ vaapidisplayglx1";
Progression : (open) Opening Stream
Progression : (connect) Connecting to rtsp://localhost:8554/test
Progression : (open) Retrieving server options
Progression : (open) Retrieving media info
ERREUR : de l’élément /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0 : Unhandled error
Information de débogage supplémentaire :
gstrtspsrc.c(6161): gst_rtspsrc_send (): /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0:
Service Unavailable (503)
ERREUR : le pipeline refuse de passer en phase de préparation.
Définition du pipeline à PAUSED…
Définition du pipeline à READY (prêt)…
Définition du pipeline à NULL…
Libération du pipeline…

I also get this error with the others launch commands.

Then I tried this :

gst-launch-1.0 multifilesrc location=img.%04d.jpg caps=“image/jpeg,framerate=1/1” ! jpegdec ! videoscale ! videoconvert ! autovideosink

And it’s working even with the framerate=1/1, but when i tried to send this to rtsp like that :

gst-launch-1.0 multifilesrc location=img.%04d.jpg caps=“image/jpeg,framerate=1/1” ! jpegdec ! x264enc ! h264parse ! rtph264pay pt=96 name=pay0

I got this error :

Définition du pipeline à PAUSED…
Le pipeline a terminé la phase PREROLL…
Passage du pipeline à la phase PLAYING…
New clock: GstSystemClock
Redistribution de latence…
ERREUR : de l’élément /GstPipeline:pipeline0/GstMultiFileSrc:multifilesrc0 : Internal data stream error.
Information de débogage supplémentaire :
gstbasesrc.c(3055): gst_base_src_loop (): /GstPipeline:pipeline0/GstMultiFileSrc:multifilesrc0:
streaming stopped, reason not-linked (-1)
Execution ended after 0:00:00.084566129
Définition du pipeline à PAUSED…
Définition du pipeline à READY (prêt)…
Définition du pipeline à NULL…
Libération du pipeline…

I don’t know what is wrong with multifilesrc in this case. Also I tried with a single image just using multifilesrc location=img.jpg and it also failed.
Also just sending images would fit my needs as I see your proposition.
Is this :

test-launch "multifilesrc location=img_%05d.jpg start-index=0 caps=image/jpeg,framerate=1/1 ! jpegparse ! rtpjpegpay name=pay0 "

working for you ? And if yes how do you read it ?

Thanks again helping me to solve my problem.

Just checked now on Xavier, with multifilesrc you would have to add identity sync=true to get it working:

test-launch "multifilesrc location=tmp/img_%05d.jpg loop=1 caps=image/jpeg,framerate=1/1 ! jpegparse ! identity sync=true ! rtpjpegpay name=pay0 "

.

For transcoding into H264, I would advise not using nvv4l2decoder mjpeg=1 in this case because it logs an error such as this one:

host1x 13e10000.host1x: nvhost_syncpt_wait_timeout: invalid syncpoint id 0

so it can quickly fill syslog. You would use nvjpegdec instead.
I see some artifacts each second with nvv4l2h264enc, so I’d suggest using omxh264enc not showing this.
So you would just try:

test-launch "multifilesrc location=tmp/img_%05d.jpg loop=1 caps=image/jpeg,framerate=30/1 ! jpegparse ! identity sync=true ! nvjpegdec ! omxh264enc insert-vui=true insert-sps-pps=1 ! h264parse ! rtph264pay name=pay0 "

For anyone from NVIDIA wanting to investigate, the syncpoint error can be seen with:

gst-launch-1.0 videotestsrc ! jpegenc ! image/jpeg,framerate=30/1 ! nvv4l2decoder mjpeg=1 ! nvv4l2h264enc ! fakesink

The periodic encoding artifact:

gst-launch-1.0 videotestsrc ! nvvidconv ! nvv4l2h264enc ! nvv4l2decoder ! nvvidconv ! xvimagesink
1 Like

Thanks a lot ! This works very well !

Also here the images are written to disk and if the stream lasts longs it can generates a lot of images. Do you know if there is a way to put a single image in a buffer img.jpg and program will overwrite a new image on it and stream this using gstreamer.
I know that is possible to pass an image to a pipe but then it receives EOS and stop playing, the solution to make it lasts longer is to add imagefreeze but then there is always the same image displayed. I dont know if there is a way to refresh the stream even using imagefreeze.