Decode AVPacket

Edward Hervey bilboed at bilboed.com
Thu Dec 31 08:06:40 UTC 2020


Hi,

  Any reason why you don't just use the existing demuxer gstreamer elements ?
This will solve a ton of issues.

  BR,

    Edward

On Wed, 2020-12-30 at 12:17 -0600, fre deric wrote:
> Hi,
> my goal is to demux video in libav and decode it in GStreamer. 
> 
> My approach is to take AVPacket from the video stream in the first thread
> and send it to GStreamer pipeline in the second thread. Important parts of
> code are here:
> 
> -- THREAD 1 --
> // Take data from AVPacket
> img_data = (guchar *)packet.data;
> size = packet.size;
> // Create gst buffer 
> buffer = gst_buffer_new_allocate(NULL, size, NULL);
> gst_buffer_map(buffer, &map, GST_MAP_WRITE);
> memcpy((guchar *)map.data, img_data, gst_buffer_get_size(buffer));
> map.size = size;
> gst_buffer_unmap(buffer, &map);
> // Send the buffer to appsrc element in the gst pipeline.
> gstret = gst_app_src_push_buffer((GstAppSrc *)app_source, buffer);
> 
> -- THREAD 2 --
> // A video cap for appsrc element
> const gchar *video_caps = "video/x-theora, width=1920, height=1080,
> framerate=30/1";
> // pipeline
> string = g_strdup_printf("appsrc name=testsource caps=\"%s\" ! theoradec !
> videoconvert ! autovideosink", video_caps);
> 
> However I got this error:
> "
> ERROR from element theoradec0: Could not decode stream.
> Debugging info: gsttheoradec.c(812): theora_handle_data_packet ():
> /GstPipeline:pipeline0/GstTheoraDec:theoradec0: no header sent yet
> "
> where theoradec0 is name for theoradec element. 
> 
> Why theoradec element is not able to decode the video stream? Does "no
> header sent yet" mean, that I am sending data to the pipeline in wrong
> format? 
> 
> Tested video file:
> container: ogg
> codec: Theora
> dim: 1920x1080
> framerate: 30fps
> 
> 
> I also tested a version, when the AVPacket was decoded to AVFrame by libav
> and then sent to the gstreamer pipeline and it works:
> 
> -- THREAD 1 --
> // Decode.
> avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished, &packet);
> img_data = (guchar *)pFrame->data
> // same way as before.
> 
> -- THREAD 2 --
> const gchar *video_caps = "video/x-raw, format=BGR, width=1920, height=1080,
> framerate=30/1";
> string = g_strdup_printf("appsrc name=testsource caps=\"%s\" ! videoconvert
> ! autovideosink", video_caps);
> 
> Thank you.
> 
> 
> 
> 
> 
> --
> Sent from: http://gstreamer-devel.966125.n4.nabble.com/
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel



More information about the gstreamer-devel mailing list