Hi,
I am working on encoding a raw file image to jpeg image in C
Below is working structure in comand line to encode image :
gst-launch filesrc location=/home/root/one.raw blocksize=608256 ! \
'video/x-raw-yuv, format=(fourcc)I420,width=(int)704,height=(int)576,framerate=(fraction)0/1'
! ffmpegcolorspace ! 'video/x-raw-yuv,format=(fourcc)I420,width=(int)704,height=(int)576,,framerate=(fraction)0/1' ! vpuenc codec = 12 ! \
filesink location=/home/root/image.jpg
Below are pipeline structure :
app->src = gst_element_factory_make("filesrc", "mysrc");
app->encoder = gst_element_factory_make("vpuenc", "enc");
app->video_convert = gst_element_factory_make ("ffmpegcolorspace", "converter");
app->imagesink = gst_element_factory_make("filesink", "myvsink");
have created all elements, objects.
g_object_set (app->src, "blocksize", BUFF_SIZE, NULL);
where BUFF_SIZE is 608256
g_object_set (app->encoder, "codec", 12, NULL);
gst_bin_add_many(GST_BIN(app->pipeline), (GstElement*)app->src,app->video_convert,app->encoder,
app->imagesink, NULL);
filesrc location using : g_object_set(G_OBJECT(app->src),
"location", "/home/root/one.raw",NULL);
and,
filesink location using : g_object_set(G_OBJECT(app->imagesink),
"location", "/home/root/tr2.jpg",NULL);
I am getting link failed when I try to link app->src and app->video_convert, and
app->video_convert and app->encoder
Below is C code for linking :
link_ok = gst_element_link_filtered (app->src, app->video_convert,
gst_caps_new_simple ("video/x-raw-yuv",
"format", G_TYPE_STRING, "I420",
"width",G_TYPE_INT, 704,
"height",G_TYPE_INT, 576,
//"framerate",GST_TYPE_FRACTION, 0,1,
NULL));
and
link_ok = gst_element_link_filtered (app->video_convert, app->encoder,
gst_caps_new_simple ("video/x-raw-yuv",
"format", G_TYPE_STRING, "I420",
"width",G_TYPE_INT, 704,
"height",G_TYPE_INT, 576,
"framerate",GST_TYPE_FRACTION, 1,1,
// "pixel-aspect-ratio",GST_TYPE_FRACTION,1,1,
NULL));
Surprisingly the same caps works in command line but if I link through C its giving error.
What am I doing wrong?
Please do help.
What is the error's log? vpuenc is not able to do JPEG encoding, so try the ffmpeg one. Freescale has a color-space converter, called mfw_ipucsc, try it. It would be nice if you post the whole code (perhaps attached).
Leo
This is wrong
gst_bin_add_many(GST_BIN(app->pipeline), (GstElement*)app->src,app->video_convert,app->encoder,
app->imagesink, NULL);
You should build something like this
filesrc ! mfw_ipu_csc ! capsfilter ! jpegenc ! filesink
Leo
As you said I used mfw_ipu_csc and capfilter. Below is working structure in command line using gst-launch
gst-launch filesrc location=/home/root/one.raw blocksize=608256 ! \
capsfilter caps="video/x-raw-yuv,format=(fourcc)I420,width=704,height=576,framerate=(fraction)0/1" ! \
mfw_ipucsc ! capsfilter caps="video/x-raw-yuv,format=(fourcc)I420,width=704,height=576,framerate=(fraction)0/1" ! \
vpuenc codec=12 ! filesink location=/home/root/j1.jpg
Attached is my c code file which I created same like what I did in gst-launch command above. !
I get link failed at app->postcapsfilter, app->video_convert.
If I check error message I am getting Segmentation Fault.
What am I missing or is it correct way of linking? !
Is setting of capsfilter correct in code?
Gst-launch command works perfectly but if I convert same thing in C code I am getting error
The first capsfilter element is redundant, so remove it. Enable debug log on you C code and share log; you need to figure out which element is the offending one.