pylon gstreamer: Could not make x264enc encoder

dcfortin report abuse

Hi All:

I'm not sure if this is the right place but I am having trouble getting my pylon gstreamer working.

When I run it, I get the following error...

pi@raspberrypi:~/Downloads/pylon_gstreamer-0.2-beta/source $ ./pylongstreamer ! queue leaky=1 ! -aoi 640 480 ! -framerate 15 -rescale 320 240 -h264file mymovie.h264 100
Press CTRL+C at any time to quit.
Initializing camera and driver...
Using Camera             : Basler daA2500-14um (22386872)
Camera Area Of Interest  : 640x480
Camera Speed             : 14.9999 fps
Images will be scaled to : 320x240
Creating Pipeline for saving images as h264 video on local host: mymovie.h264...
Could not make omxh264enc encoder. Trying imxvpuenc_h264...
Could not make imxvpuenc_h264 encoder. Trying x264enc...
Could not make x264enc encoder.
An exception occurred in main(): 
Pipeline building failed!

Press Enter to exit.

I am trying to stream video from my Basler Camera to my laptop from a raspberry pi.  Anyhelp would be greatly appreciated as I have been struggling with this issue for a week now.

Thanks,

Dave :)
 

Answers

mattb report abuse

Hi Dave, sure thing I can help! I'm sorry for the lengthy struggle, thats not good :(. I think you may just need to install a missing package...

First I should mention that pylongstreamer doesn't function like gst-launch. It's a standalone program which shows how to build pipelines in c/c++, whereas gst-launch is designed to build pipelines from the shell. So pylongstreamer will ignore the "!" and the "queue leaky=1" arguments. Of course though, you could add the queue element inside the code (see the pipelinehelper class for some examples).

In any case, I see the problem is that no h264 encoder plugin for gstreamer could be found on the RPi (at least not any that I know to look for as you can see from the attempts at using different ones...). This feels a little odd because the RPi should have the omxh264enc encoder and work quite well with it.

Have you tried installing the packages below? (with sudo apt-get update, then sudo apt-get install <package>)

gstreamer1.0
gstreamer1.0-dev
gstreamer1.0-libav
gstreamer1.0-plugins-bad
libgstreamer-plugins-base1.0-dev

PS:
pylongstreamer uses the InstantCameraAppSrc class, which creates a source element for a pipeline from the camera, pylon drivers, and gstreamer's AppSrc api. Usually gstreamer intends for AppSrc to be used only in full programs and not for building a standalone gstreamer 'plugin' like what you would use with gst-launch. This is why it's not possible to do something like gst-launch ! InstantCameraAppSrc ! fakesink. (gst-launch is handy, but is really only intended by the gstreamer team for quick testing of pipelines.)

dcfortin report abuse

Hi Matt:

Thanks for the speedy reply.  Okay, I did as you suggested above and installed all the packages.  I re-ran the code and I still get the same problem.  Should I recompile as well?

This is what I plugged into the command line and the following response...

pi@raspberrypi:~/Downloads/Junk/pylon_gstreamer-0.2-beta/source $ ./pylongstreamer -aoi 640 480 -framerate 15 -h264file mymovie.h264 100
Press CTRL+C at any time to quit.
Initializing camera and driver...
Using Camera             : Basler daA2500-14um (22386872)
Camera Area Of Interest  : 640x480
Camera Speed             : 14.9999 fps
Creating Pipeline for saving images as h264 video on local host: mymovie.h264...
Could not make omxh264enc encoder. Trying imxvpuenc_h264...
Could not make imxvpuenc_h264 encoder. Trying x264enc...
Could not make x264enc encoder.
An exception occurred in main(): 
Pipeline building failed!

Press Enter to exit.
 

Okay, I'm wondering if a small change I made to your code may be causing the problem.  I couldn't get it to compile because it said in CInstantCameraAppSrc.cpp that GSTMemoryFlags was not declared so I commented it out (yeah, I know... but it didn't look like it was being used).  I could try and reproduce the error, if it helps.

line 288 to 297 states..

// create a gst buffer wrapping the image container's buffer
/*
        m_gstBuffer = gst_buffer_new_wrapped_full(
            (GstMemoryFlags*)GST_MEMORY_FLAG_PHYSICALLY_CONTIGUOUS,
            (gpointer)m_Image.GetBuffer(),
            m_Image.GetImageSize(),
            0,
            m_Image.GetImageSize(),
            NULL,
            NULL);

*/

Yeah, probably dumb but I was frustrated :)  I had a hell of a time finding files as the Makefile couldn't find a bunch of stuff.  Sorry, I am a bit new to compiling c++ code.  I have some experience with C++ but probably not enough!

Again, any help would be greatly appreciated.

Dave :)

mattb report abuse

No problem Dave, we've all been there ;-)

Yes I would recompile so that it links with the new libraries. I think what happened was that you had gstreamer 0.1 vs gstreamer 1.0 installed. (0.1 has been around forever, and although 1.0 has been out for a few years, there's still a lot of systems that ship with the old version. At least that's what I've heard).

I think that's also what happened with the memory flag. I wonder if this wasn't introduced until 1.0.

PS: A lot of times I can't even make heads or tails of what's in a makefile. I think to some extent they're a mystery to us all ;)

dcfortin report abuse

Hi Matt:

Thanks, I feel like a dunderhead sometimes.  I actually via trial and error compiled from the command line adding missing directories along the way.

Okay, I updated all the the libraries and started from a fresh copy (ie: no edits by me)

OMG!  The make file ran flawlessly from a clean copy of your code!!!

Sadly, when I ran pylongstreamer, I got this...

pi@raspberrypi:~/Desktop/pylongst/pylon_gstreamer/source $ ./pylongstreamer -aoi 640 480 -framerate 15 -rescale 320 240 -h264file mymovie.h264 100
Press CTRL+C at any time to quit.
Initializing camera and driver...
Using Camera             : Basler daA2500-14um (22386872)
Camera Area Of Interest  : 640x480
Camera Speed             : 14.9999 fps
Images will be scaled to : 320x240
Creating Pipeline for saving images as h264 video on local host: mymovie.h264...

(pylongstreamer:4206): GLib-GObject-WARNING **: g_object_set_valist: object class 'GstBin' has no property named 'num-buffers'
Source will output 100 frames before sending EOS...
Pipeline Made.
Starting Camera image acquistion and Pylon driver Grab Engine...
Starting pipeline...
**
ERROR:gstomxvideoenc.c:1075:gst_omx_video_enc_set_format: code should not be reached
Aborted

Sooo close!...  I tried to see if I was missing anything for GLIB...  arghh! :)  Any suggestions???  ...sorry to keep bugging you but I need this for an experiment.  We are putting a camera in a centrifuge and then sending the data out via wifi.

Dave :)

mattb report abuse

Blech. Bug. This one's on me. I must've forgotten to test the h264file pipeline mode before my last commit.

I just pushed a commit with what I hope is a fix (at least it works ok on my side). Fingers crossed!

https://github.com/MattsProjects/pylon_gstreamer

dcfortin report abuse

Thanks!  I'll check it out over the weekend! 

Cheers and thanks for all the help!!!

Add Answer

Need support?

Just drop us an email to ... Show more