Search code examples
cgstreamergstreamer-1.0

what should I set appsrc caps to fix "internal data stream error"?


I'm trying to open an mp4 video decode it and send it to appsink. then recieve it from appsrc and save it on an mp4 file.

I'm sure I've set the caps wrong.

const gchar *video_caps =
"video/x-raw,width=1280,height=720,framerate=25/1";

first half of the pipeline:

  string = g_strdup_printf ("filesrc location=\"%s\" ! decodebin name=dec ! queue ! videoconvert ! appsink caps=\"%s\" name=testsink",
  in_filename, video_caps);

second half:

string = g_strdup_printf ("appsrc name=testsource caps=\"%s\" !x264enc ! mp4mux! filesink location=\"%s\"",
       video_caps,out_filename);

what should I set my caps to make it work?

error I got:Received error in sink(appsrc module) Error: Internal data stream error.


Solution

  • in order to make correct caps negotiation, you have to specifically mention data types in caps for both appsink and appsrc.caps must be set based on previous elements outputs. in the question, decodebin output data is in YUV I420 format.

    if the data gets modulated or changed before reaching appsrc you have to set correct caps for appsrc.

    const gchar * appsink_video_caps = "video/x-raw,format=I420,width=1280,height=720,framerate=25/1";
    
    const gchar * appsrc_video_caps = "video/x-raw,format=I420,width=1280,height=720,framerate=25/1";