Question

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.

Was it helpful?

Solution

MJPEG is a codec which in simple terms means that there are is a series of jpeg images. These jpegs have to be stored in a container if you want to view them as a video. MP4 is a common container to store them in.

So you can mux the jpegenc output back to a mp4mux and store it in a file. Any decent media player should be able to play it back.

OTHER TIPS

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top