Lossless compressed JPEG gstreamer element?

Go To StackoverFlow.com

0

The pipeline below works fine for saving compressed JPEG images but is there a way to save lossless compressed JPEG images using gstreamer?

gst-launch v4l2src always-copy=false num-buffers=1 chain-ipipe=true ! 'video/x-raw-yuv,format=(fourcc)NV12, width=2176, height=1944' ! dmaiaccel ! dm365facedetect draw-square=true ! dmaienc_jpeg ! filesink location=$FILE_NAME

2012-04-05 17:19
by jacknad
JPG is by definition a lossy format. it is impossible to NOT lose data when saving as JPG. if you need lossless, then go with PN - Marc B 2012-04-05 17:20
though, http://en.wikipedia.org/wiki/Lossless_JPE - ShinTakezou 2012-04-05 17:20
@MarcB: is there a lossless compressed PNG gstreamer element - jacknad 2012-04-05 17:32


3

Assuming you have all the GStreamer plugins installed (good, bad, and ugly), you have an impressive number of lossless video compressors at your disposal via the FFmpeg GStreamer element. These include ffenc_png (for PNG encoding), ffenc_jpegls (lossless JPEG algorithm), and many less common ones.

However, if I'm reading your GStreamer command line correctly, you seem to be calling a series of custom components that are tied to a particular type of hardware (I have been Googling but I haven't quite nailed down what it is). The JPEG encoder component is 'dmaienc_jpeg'. It's possible that the element preceding it in the chain (dm365facedetect) only outputs data that dmaienc_jpeg can interpret. However, if it's a general colorspace, then you can send it through an FFmpeg lossless encoder, possibly with a colorspace conversion in between. The answer can be ascertained by invoking 'gst-inspect' on the elements and studying the output (the src and sink data types).

Update, pursuant to new data: Good news: that dm365facedetect element outputs raw YUV in an NV12 format. Very flexible, and you have a lot of options.

What platform are you on? If you are using Ubuntu Linux, install a bunch of GStreamer plugins using:

apt-get install gstreamer0.10-plugins-good \
  gstreamer0.10-plugins-bad gstreamer0.10-plugins-ugly gstreamer0.10-ffmpeg

Some lossless codec options: PNG, via either 'pngenc' or 'ffenc_png' (although this may technically incur a tiny bit of loss due to YUV -> RGB colorspace conversion), 'ffenc_huffyuv', 'ffenc_jpegls', or 'ffenc_ljpeg'. When you encode these, send them through the avimux component. So, an example amendment to the end of your command line:

... ! dm365facedetect draw-square=true ! ffenc_ljpeg ! \
  avimux ! filesink location=$FILE_NAME

Expect the lossless codec data to be somewhat larger than the JPEG data you were getting before. Experiment with different codecs to see what you like, and make sure you can decode the data on the other side using your preferred toolchain (FFmpeg and VLC should always be able to handle it).

2012-04-06 01:29
by Multimedia Mike
Yes. There are some custom components. dm365facedetect uses the RidgeRun SDK with a TI DaVinci TMS320DM368 HW Face Detect Engine to draw a rectangle around a face. And yes. gst-inspect returns a boatload of plugins (145) and features (520) but I don't see ffencpng or ffencjpegls. How are GStreamer plugins typically installed? Is ffencjpegls or ffencpng able to save lossless JPEG files? Also. I don't need color. Gray-scale is fine - jacknad 2012-04-10 19:28
gst-inspect output is herejacknad 2012-04-10 19:47
Thanks for posting the output of gst-inspect. I need a little more information in order to answer your question: Please post the output of 'gst-inspect dm365facedetect' and 'gst-inspect dmaienc_jpeg'. Also, I would like to see 'gst-inspect TIDmaiVideoSink' - Multimedia Mike 2012-04-10 22:31
This GStreamer library is amazing. Here are the files you asked about. gst-inspect-dm365facedetect.txt. gst-inspect-dmaienc_jpeg.txt. gst-inspect-TIDmaiVideoSink.txt. Thank you very very much. Jac - jacknad 2012-04-11 12:34
I updated my original answer pursuant to your new data - Multimedia Mike 2012-04-11 16:52
+100: great answer. Thanks a million - jacknad 2012-04-12 10:40
I gather that the solution worked out for you. Glad to know - Multimedia Mike 2012-04-12 16:09
Ads