Gstreamer pipeline through OpenCV for H264 encoded video file

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Gstreamer pipeline through OpenCV for H264 encoded video file

simo-zz
Hi all,

I am working on an IP application working with OpenCV and I need to generate an H264 encoded videos.
OpenCV uses GStramer to for this task, initializing the OpenCV VideoWriter object with a GStramer pipeline. In turns it should passthe frames GStramer which should write the video..

The actual pipeline I am using for this task:

"appsrc ! autovideoconvert ! v4l2video1h264enc extra-controls=\"encode,h264_level=10,h264_profile=4,frame_level_rate_control_enable=1,video_bitrate=2000000\" ! h264parse ! rtph264pay config-interval=1 pt=96 ! filesink location=file.pm4"

But it's neither generating the video. I tried many pipelines without successful results..
What is the correct pipeline I must use ?

Thank you in advance,
Regards,
Simon

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Gstreamer pipeline through OpenCV for H264 encoded video file

Martin Vachovski

One quick thing I can suggest is to try to specify the CAPS before the autovideoconvert element.

Otherwise there might be problems with the negotiation and starting of the pipeline

something like:


appsrc ! video/x-raw,format=YUY2,width=320,height=240,framerate=30/1 !  v4l2video1h264enc  ....


Or whatever format you're getting the videoframes  in from the appsrc, try to specify as many details as possible


Cheers

Martin



From: gstreamer-devel <[hidden email]> on behalf of simo zz <[hidden email]>
Sent: Friday, August 25, 2017 10:58 AM
To: [hidden email]
Subject: Gstreamer pipeline through OpenCV for H264 encoded video file
 
Hi all,

I am working on an IP application working with OpenCV and I need to generate an H264 encoded videos.
OpenCV uses GStramer to for this task, initializing the OpenCV VideoWriter object with a GStramer pipeline. In turns it should passthe frames GStramer which should write the video..

The actual pipeline I am using for this task:

"appsrc ! autovideoconvert ! v4l2video1h264enc extra-controls=\"encode,h264_level=10,h264_profile=4,frame_level_rate_control_enable=1,video_bitrate=2000000\" ! h264parse ! rtph264pay config-interval=1 pt=96 ! filesink location=file.pm4"

But it's neither generating the video. I tried many pipelines without successful results..
What is the correct pipeline I must use ?

Thank you in advance,
Regards,
Simon

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Gstreamer pipeline through OpenCV for H264 encoded video file

Martin Vachovski

Sorry... didn't mean to omit the autovideoconvert...


The pipeline I meant is to be read:


appsrc ! video/x-raw,format=YUY2,width=320,height=240,framerate=30/1 ! autovideoconvert ​!  v4l2video1h264enc  ....


Cheers

Martin



From: gstreamer-devel <[hidden email]> on behalf of Martin Vachovski <[hidden email]>
Sent: Friday, August 25, 2017 11:09 AM
To: [hidden email]; simo zz
Subject: Re: Gstreamer pipeline through OpenCV for H264 encoded video file
 

One quick thing I can suggest is to try to specify the CAPS before the autovideoconvert element.

Otherwise there might be problems with the negotiation and starting of the pipeline

something like:


appsrc ! video/x-raw,format=YUY2,width=320,height=240,framerate=30/1 !   v4l2video1h264enc  ....


Or whatever format you're getting the videoframes  in from the appsrc, try to specify as many details as possible


Cheers

Martin



From: gstreamer-devel <[hidden email]> on behalf of simo zz <[hidden email]>
Sent: Friday, August 25, 2017 10:58 AM
To: [hidden email]
Subject: Gstreamer pipeline through OpenCV for H264 encoded video file
 
Hi all,

I am working on an IP application working with OpenCV and I need to generate an H264 encoded videos.
OpenCV uses GStramer to for this task, initializing the OpenCV VideoWriter object with a GStramer pipeline. In turns it should passthe frames GStramer which should write the video..

The actual pipeline I am using for this task:

"appsrc ! autovideoconvert ! v4l2video1h264enc extra-controls=\"encode,h264_level=10,h264_profile=4,frame_level_rate_control_enable=1,video_bitrate=2000000\" ! h264parse ! rtph264pay config-interval=1 pt=96 ! filesink location=file.pm4"

But it's neither generating the video. I tried many pipelines without successful results..
What is the correct pipeline I must use ?

Thank you in advance,
Regards,
Simon

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Gstreamer pipeline through OpenCV for H264 encoded video file

simo-zz
Hello Martin,

Thank you for your suggestion, however, it still fails, and no error is reported.

Regards,
Simon


El Viernes 25 de agosto de 2017 12:13, Martin Vachovski <[hidden email]> escribió:


Sorry... didn't mean to omit the autovideoconvert...

The pipeline I meant is to be read:

appsrc ! video/x-raw,format=YUY2,width=320,height=240,framerate=30/1 ! autovideoconvert ​!  v4l2video1h264enc  ....

Cheers
Martin


From: gstreamer-devel <[hidden email]> on behalf of Martin Vachovski <[hidden email]>
Sent: Friday, August 25, 2017 11:09 AM
To: [hidden email]; simo zz
Subject: Re: Gstreamer pipeline through OpenCV for H264 encoded video file
 
One quick thing I can suggest is to try to specify the CAPS before the autovideoconvert element.
Otherwise there might be problems with the negotiation and starting of the pipeline
something like:

appsrc ! video/x-raw,format=YUY2,width=320,height=240,framerate=30/1 !   v4l2video1h264enc  ....

Or whatever format you're getting the videoframes  in from the appsrc, try to specify as many details as possible

Cheers
Martin


From: gstreamer-devel <[hidden email]> on behalf of simo zz <[hidden email]>
Sent: Friday, August 25, 2017 10:58 AM
To: [hidden email]
Subject: Gstreamer pipeline through OpenCV for H264 encoded video file
 
Hi all,

I am working on an IP application working with OpenCV and I need to generate an H264 encoded videos.
OpenCV uses GStramer to for this task, initializing the OpenCV VideoWriter object with a GStramer pipeline. In turns it should passthe frames GStramer which should write the video..

The actual pipeline I am using for this task:

"appsrc ! autovideoconvert ! v4l2video1h264enc extra-controls=\"encode,h264_level=10,h264_profile=4,frame_level_rate_control_enable=1,video_bitrate=2000000\" ! h264parse ! rtph264pay config-interval=1 pt=96 ! filesink location=file.pm4"

But it's neither generating the video. I tried many pipelines without successful results..
What is the correct pipeline I must use ?

Thank you in advance,
Regards,
Simon
_______________________________________________
gstreamer-devel mailing list
gstreamer-devel@...
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel



_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Gstreamer pipeline through OpenCV for H264 encoded video file

Martin Vachovski

Hi Simon,


>>> Thank you for your suggestion, however, it still fails, and no error is reported.

If you're running the pipeline from a C/C++ program, you can pass the --gst-debug-level option to the

gst_init()

function


int argc = 3;
char **argv = new char*[argc];
argv[0] = "appname";
argv[1] = "--gst-debug-level=X";
argv[2] = "--gst-debug-no-color";

gst_init(&argc, &argv);

where X is a number from 0 to 9, 9 being the highest level- then you'll see a lot of errors on stderr (even overwhelming)

Anyway, recently I managed to make the following pipeline work:

"appsrc name=appsrc_element block=true format=3 ! video/x-raw,format=YUY2,width=320,height=240,framerate=30/1 ! "
"videoconvert ! x264enc tune=zerolatency bitrate=4096 ! video/x-h264,profile=\"high-4:4:4\" ! rtph264pay ! udpsink host=192.168.168.98 port=10000"

It does something similar to what you're trying to achieve- only transmits over the network instead of saving to a file.
As an advice try first replacing the whole H264 encoding part with a autovideosink- that way you'll
make sure that the video you import from the appsrc is working, something like:

"appsrc name=appsrc_element block=true format=3 ! video/x-raw,format=YUY2,width=320,height=240,framerate=30/1 ! "
"videoconvert ! autovideosink"

When this pipeline works, proceed with adding more elements

Hope that helps
Martin





From: gstreamer-devel <[hidden email]> on behalf of simo zz <[hidden email]>
Sent: Friday, August 25, 2017 12:10 PM
To: Discussion of the development of and with GStreamer
Subject: Re: Gstreamer pipeline through OpenCV for H264 encoded video file
 
Hello Martin,

Thank you for your suggestion, however, it still fails, and no error is reported.

Regards,
Simon


El Viernes 25 de agosto de 2017 12:13, Martin Vachovski <[hidden email]> escribió:


Sorry... didn't mean to omit the autovideoconvert...

The pipeline I meant is to be read:

appsrc ! video/x-raw,format=YUY2,width=320,height=240,framerate=30/1 ! autovideoconvert ​!  v4l2video1h264enc  ....

Cheers
Martin


From: gstreamer-devel <[hidden email]> on behalf of Martin Vachovski <[hidden email]>
Sent: Friday, August 25, 2017 11:09 AM
To: [hidden email]; simo zz
Subject: Re: Gstreamer pipeline through OpenCV for H264 encoded video file
 
One quick thing I can suggest is to try to specify the CAPS before the autovideoconvert element.
Otherwise there might be problems with the negotiation and starting of the pipeline
something like:

appsrc ! video/x-raw,format=YUY2,width=320,height=240,framerate=30/1 !   v4l2video1h264enc  ....

Or whatever format you're getting the videoframes  in from the appsrc, try to specify as many details as possible

Cheers
Martin


From: gstreamer-devel <[hidden email]> on behalf of simo zz <[hidden email]>
Sent: Friday, August 25, 2017 10:58 AM
To: [hidden email]
Subject: Gstreamer pipeline through OpenCV for H264 encoded video file
 
Hi all,

I am working on an IP application working with OpenCV and I need to generate an H264 encoded videos.
OpenCV uses GStramer to for this task, initializing the OpenCV VideoWriter object with a GStramer pipeline. In turns it should passthe frames GStramer which should write the video..

The actual pipeline I am using for this task:

"appsrc ! autovideoconvert ! v4l2video1h264enc extra-controls=\"encode,h264_level=10,h264_profile=4,frame_level_rate_control_enable=1,video_bitrate=2000000\" ! h264parse ! rtph264pay config-interval=1 pt=96 ! filesink location=file.pm4"

But it's neither generating the video. I tried many pipelines without successful results..
What is the correct pipeline I must use ?

Thank you in advance,
Regards,
Simon
_______________________________________________
gstreamer-devel mailing list
gstreamer-devel@...
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel



_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Gstreamer pipeline through OpenCV for H264 encoded video file

simo-zz
Hello Martin,

After struggling a while, I finally decide to use a different approach, which is using a gstreamer pipeline to record a video from the USB camera data, using a hardware encoder.
I think it will be the best and simple approach.

Thank you for your help.
Regards,
Simon



El Viernes 25 de agosto de 2017 13:34, Martin Vachovski <[hidden email]> escribió:


Hi Simon,

>>> Thank you for your suggestion, however, it still fails, and no error is reported.
If you're running the pipeline from a C/C++ program, you can pass the --gst-debug-level option to the
gst_init()
function

int argc = 3;
char **argv = new char*[argc];
argv[0] = "appname";
argv[1] = "--gst-debug-level=X";
argv[2] = "--gst-debug-no-color";

gst_init(&argc, &argv);

where X is a number from 0 to 9, 9 being the highest level- then you'll see a lot of errors on stderr (even overwhelming)

Anyway, recently I managed to make the following pipeline work:

"appsrc name=appsrc_element block=true format=3 ! video/x-raw,format=YUY2,width=320,height=240,framerate=30/1 ! "
"videoconvert ! x264enc tune=zerolatency bitrate=4096 ! video/x-h264,profile=\"high-4:4:4\" ! rtph264pay ! udpsink host=192.168.168.98 port=10000"

It does something similar to what you're trying to achieve- only transmits over the network instead of saving to a file.
As an advice try first replacing the whole H264 encoding part with a autovideosink- that way you'll
make sure that the video you import from the appsrc is working, something like:

"appsrc name=appsrc_element block=true format=3 ! video/x-raw,format=YUY2,width=320,height=240,framerate=30/1 ! "
"videoconvert ! autovideosink"

When this pipeline works, proceed with adding more elements

Hope that helps
Martin




From: gstreamer-devel <[hidden email]> on behalf of simo zz <[hidden email]>
Sent: Friday, August 25, 2017 12:10 PM
To: Discussion of the development of and with GStreamer
Subject: Re: Gstreamer pipeline through OpenCV for H264 encoded video file
 
Hello Martin,

Thank you for your suggestion, however, it still fails, and no error is reported.

Regards,
Simon


El Viernes 25 de agosto de 2017 12:13, Martin Vachovski <[hidden email]> escribió:


Sorry... didn't mean to omit the autovideoconvert...

The pipeline I meant is to be read:

appsrc ! video/x-raw,format=YUY2,width=320,height=240,framerate=30/1 ! autovideoconvert ​!  v4l2video1h264enc  ....

Cheers
Martin


From: gstreamer-devel <[hidden email]> on behalf of Martin Vachovski <[hidden email]>
Sent: Friday, August 25, 2017 11:09 AM
To: [hidden email]; simo zz
Subject: Re: Gstreamer pipeline through OpenCV for H264 encoded video file
 
One quick thing I can suggest is to try to specify the CAPS before the autovideoconvert element.
Otherwise there might be problems with the negotiation and starting of the pipeline
something like:

appsrc ! video/x-raw,format=YUY2,width=320,height=240,framerate=30/1 !   v4l2video1h264enc  ....

Or whatever format you're getting the videoframes  in from the appsrc, try to specify as many details as possible

Cheers
Martin


From: gstreamer-devel <[hidden email]> on behalf of simo zz <[hidden email]>
Sent: Friday, August 25, 2017 10:58 AM
To: [hidden email]
Subject: Gstreamer pipeline through OpenCV for H264 encoded video file
 
Hi all,

I am working on an IP application working with OpenCV and I need to generate an H264 encoded videos.
OpenCV uses GStramer to for this task, initializing the OpenCV VideoWriter object with a GStramer pipeline. In turns it should passthe frames GStramer which should write the video..

The actual pipeline I am using for this task:

"appsrc ! autovideoconvert ! v4l2video1h264enc extra-controls=\"encode,h264_level=10,h264_profile=4,frame_level_rate_control_enable=1,video_bitrate=2000000\" ! h264parse ! rtph264pay config-interval=1 pt=96 ! filesink location=file.pm4"

But it's neither generating the video. I tried many pipelines without successful results..
What is the correct pipeline I must use ?

Thank you in advance,
Regards,
Simon
_______________________________________________
gstreamer-devel mailing list
gstreamer-devel@...
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel



_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel