GStreamer - MJPEG stream for file

I have a problem saving the MJPEG stream to a file. When I pass MJPEG using such a pipeline:

 gst-launch filesrc location=thirdmovie640x360.mp4 ! decodebin2 name=dec \ ! queue ! ffmpegcolorspace ! jpegenc ! queue ! avimux name=mux \ ! udpsink host=192.168.0.2 port=5000 

I can play this stream on my second machine using a pipeline like this:

 gst-launch -v udpsrc port=5000 ! jpegdec ! autovideosink 

However, how can I save the MJPEG stream to a file (without transcoding!) That can be played on some kind of media player? Could you recommend some kind of conveyor?


I found such a pipeline to save the output stream as a matroska file:

 gst-launch udpsrc port=5000 ! multipartdemux ! jpegparse ! jpegdec \ ! ffmpegcolorspace ! matroskamux ! filesink location=output.mkv 

How to change it to save mp4 file? Such a pipeline:

 gst-launch udpsrc port=5000 ! multipartdemux ! jpegparse ! jpegdec \ ! ffmpegcolorspace ! mp4mux ! filesink location=output.mp4 

does not work. Could you help me save it as mp4 contener (or avi contener) without transcoding MJPEG video.

+4
source share
2 answers

MJPEG is a codec that, in simple terms, means that there are a number of jpeg images. These jpeg must be stored in the container if you want to view them as a video. MP4 is a common container for storing them.

This way you can output jpegenc output back to mp4mux and save it in a file. Any decent media player should be able to play it.

+1
source

I solved my problem. Here are the lines I was looking for:

Server

 gst-launch filesrc location=thirdmovie640x360.mp4 ! decodebin2 name=dec ! queue ! ffmpegcolorspace ! jpegenc ! queue ! multipartmux ! udpsink host=192.168.0.4 port=5000 

Client

 gst-launch udpsrc port=5000 ! multipartdemux ! image/jpeg, framerate=25/1 ! jpegparse ! jpegdec ! ffmpegcolorspace ! jpegenc ! avimux ! filesink location=output.avi 
+6
source

Source: https://habr.com/ru/post/1437634/


All Articles