Encoding from raw to h264

This operation was only made on tegra-ubuntu3.

sudo apt-get install gstreamer1.0-plugins-bad

Produces.

The following extra packages will be installed: gstreamer1.0-plugins-bad-faad gstreamer1.0-plugins-bad-videoparsers libchromaprint0 libfluidsynth1 libgstreamer-plugins-bad1.0-0 libilmbase6 libmpg123-0 libopencv-calib3d2.4 libopencv-contrib2.4 libopencv-core2.4 libopencv-features2d2.4 libopencv-flann2.4 libopencv-highgui2.4 libopencv-imgproc2.4 libopencv-legacy2.4 libopencv-ml2.4 libopencv-objdetect2.4 libopencv-video2.4 libopenexr6 libsrtp0 Suggested packages: frei0r-plugins libchromaprint-tools python-acoustid srtp-utils The following packages will be REMOVED: libopencv4tegra libopencv4tegra-dev The following NEW packages will be installed: gstreamer1.0-plugins-bad gstreamer1.0-plugins-bad-faad gstreamer1.0-plugins-bad-videoparsers libchromaprint0 libfluidsynth1 libgstreamer-plugins-bad1.0-0 libilmbase6 libmpg123-0 libopencv-calib3d2.4 libopencv-contrib2.4 libopencv-core2.4 libopencv-features2d2.4 libopencv-flann2.4 libopencv-highgui2.4 libopencv-imgproc2.4 libopencv-legacy2.4 libopencv-ml2.4 libopencv-objdetect2.4 libopencv-video2.4 libopenexr6 libsrtp0

The command line

gst-launch-1.0 filesrc location=ContinuousGrab ! ! 'video/x-raw, format=(string)UYVY, width=(int)1600, height=(int)1200' ! nvvidconv ! 'video/x-raw(memory:NVMM)' ! omxh264enc ! 'video/x-h264, stream-format=(string)byte-stream' ! h264parse ! qtmux ! filesink location=video.mp4 -e

Produces

(gst-plugin-scanner:24425): GStreamer-WARNING **: Failed to load plugin '/usr/lib/arm-linux-gnueabihf/gstreamer-1.0/libgsteglglessink.so': /usr/lib/arm-linux-gnueabihf/libgstegl-1.0.so.0: undefined symbol: eglDestroyImageKHR WARNING: erroneous pipeline: link without source element


YCbCr filetype documentations: https://www.loc.gov/preservation/digital/formats/fdd/fdd000352.shtml https://www.ptgrey.com/Content/Images/Uploaded/Downloads/TRM/2016/BFS-U3-51S5/HTML/Model/public/ImageFormatControl.html

YCbCr422_8 == YUYV format aka YUY2 (!!)

Solutions:

Update

This works, when saving raw Basler data (see ContinuousGrab, just basler's produced image buffer without any converter), on jetson: gst-launch-1.0 filesrc location=ContinuousGrab ! videoparse width=1600 height=1200 framerate=24/1 format=4 ! videoconvert ! omxh264enc ! 'video/x-h264, stream-format=(string)byte-stream' ! h264parse ! qtmux ! filesink location=test.mp4 -e

(videoparse format 4 = YUY2, 15 = RGB, 25=gray8, ).

Example with encoder parameters (could we make these parametrized, for tweakability, if this is set in the function?):

^ Let's use this, seems to work most reliably. Can tweak low-latency=true/false. True seems to be higher compressed sizes and slightly longer compression time (i.e. low latency forces a bit weaker compression approach).

Example using gst video caps instead of videoparse element (Smth not right, result does not seem to consistently work and is missing data - perhaps with live appsrc these could/should work...): gst-launch-1.0 filesrc location=ContinuousGrab blocksize=3840000 ! 'video/x-raw,format=YUY2,width=1600,height=1200,framerate=24/1' ! videoconvert ! omxh264enc bitrate=20000000 profile=high quality-level=2 control-rate=2 ! 'video/x-h264, stream-format=(string)byte-stream' ! h264parse ! qtmux ! filesink location=testWithSmallerBlocksize.mp4 -e

Launch sequency using lbstreamermm wrapper and control app: Glib::ustring launch_command = "appsrc name=camerasource ! video/x-raw,width=1600,height=1200,format=YUY2,framerate=24/1 ! videoconvert ! omxh264enc bitrate=20000000 profile=8 quality-level=2 control-rate=2 temporal-tradeoff=0 no-B-Frames=false insert-sps-pps=false low-latency=true ! video/x-h264,stream-format=(string)byte-stream ! h264parse ! qtmux ! filesink location=smurf.mp4"; //"rtph264pay ! udpsink host=127.0.0.1 port=1234";