H264 bitstream decoding

Can anyone please help me to figure out how to decode raw h264 bitstream from memory and use it with opencv.

From one of the thread posts I understand that the decoding is supported through gstreamer framework and not through ffmpeg.


Please suggest.

There is a post about camera source + opencv:

You can achieve your usecase by replacing camera source with h264 decoding.

Hi DaneLLL
Thank you for the link. But I could not play the video file with the following piece of code:

cv::VideoCapture cap("filesrc location=/home/ubuntu/test/720p_Ducks_Take_Off.264 ! video/x-raw, width=1280, height=720,format=NV12, framerate=30/1 ! nvvidconv ! video/x-raw,format=I420 ! appsink");

	if (!cap.isOpened())
		std::cout << "Failed to open camera." << std::endl;
		return -1;

	for (;;)
		cv::Mat frame;
		cap >> frame;
		cv::Mat bgr;
		cv::cvtColor(frame, bgr, CV_YUV2BGR_I420);
		cv::imshow("original", bgr);


720p_Ducks_Take_Off.264 is in annex b byte stream format.

Please refer to user guide.