GStreamer - MJPEG stream to file

XMementoIT picture XMementoIT · Oct 3, 2012 · Viewed 17.7k times · Source

I have problem with saving MJPEG stream to file. When I stream MJPEG using such 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 am able to play this stream on my second machine using such pipeline:

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

However, how can I save such MJPEG stream to file (without transcoding!) which will be able to be played in some media player? Could you recommend some pipeline?


I found such pipeline to save output stream as 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 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.

Answer

XMementoIT picture XMementoIT · Oct 4, 2012

I solved my problem. Here are piplines which 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