code for converting raw image to jpeg image

Thomas DEBESSE thomas.debesse at rcf.fr
Wed Aug 21 03:40:46 PDT 2013


If your first pipeline works (not tested it) you can use
gst_parse_launch() with your pipeline-as-a-string (it's the easiest
way but the less convenient for advanced operations).

As shown in the "Hello World" of the C tutorial :
http://docs.gstreamer.com/pages/viewpage.action?pageId=327735

Something like that could work :

#include <gst/gst.h>

int main(int argc, char *argv[]) {
  GstElement *pipeline;
  GstBus *bus;
  GstMessage *msg;

  /* Initialize GStreamer */
  gst_init (&argc, &argv);

  /* Build the pipeline */
  pipeline = gst_parse_launch ("filesrc location=one.raw  blocksize=
608256 ! 'video/x-raw-yuv, format=(fourcc)I420, width=(int)704,
height=(int)576, framerate=(fraction)0/1' ! jpegenc ! filesink
location=image1.jpg", NULL);

  /* Start playing */
  gst_element_set_state (pipeline, GST_STATE_PLAYING);

  /* Wait until error or EOS */
  bus = gst_element_get_bus (pipeline);
  msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE,
GST_MESSAGE_ERROR | GST_MESSAGE_EOS);

  /* Free resources */
  if (msg != NULL)
    gst_message_unref (msg);
  gst_object_unref (bus);
  gst_element_set_state (pipeline, GST_STATE_NULL);
  gst_object_unref (pipeline);
  return 0;
}

(I have not tested it)

This tutorial is so good:
http://docs.gstreamer.com/display/GstSDK/Basic+tutorials

NB: GStreamer can probably do that, but it may not be the best tool to
do it, as others said.

-- 
Thomas DEBESSE
RCF Méditerrannée


More information about the gstreamer-devel mailing list