How to make GNonLin not to decode videoclip?

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

How to make GNonLin not to decode videoclip?

wl2776
Administrator
I'd like to cut a fragment from a video clip save it to a new file of the same format, and make it as soon as possible.
Another task - cut several pieces of one file and merge them to a file of the same format.
That said, I don't want to recode the file.

I'm studying the GNonLin.
To discover its functionality I've created a pipeline, a gnlcomposition object and two fakesinks and put the latter to the pipeline.
I am planning to replace fakesinks with the muxer and filesink.
I've also set a pad-added handler.

When I run the pipeline, and pad-added handler got called, the pad caps were video/yuv-raw. That is, gnlcomposition has decoded the file.

Is it possible to avoid decoding and pause just at the demuxing and discovering elementary stream formats?
Reply | Threaded
Open this post in threaded view
|

Re: How to make GNonLin not to decode videoclip?

Edward Hervey
On Fri, 2010-08-06 at 06:33 -0700, wl2776 wrote:
>
> Is it possible to avoid decoding and pause just at the demuxing and
> discovering elementary stream formats?

  Set the caps property of the gnlfilesource to the format you want
(ex : video/mpeg,mpegversion=2 for mpeg2 video)

  And if you're just using one gnl(file)source you don't need a
gnlcomposition.

    Edward


------------------------------------------------------------------------------
This SF.net email is sponsored by

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to make GNonLin not to decode videoclip?

wl2776
Administrator
Edward Hervey wrote
  Set the caps property of the gnlfilesource to the format you want
(ex : video/mpeg,mpegversion=2 for mpeg2 video)
Looks like it doesn't work. At least, with gstreamer-sharp.
Here is my code.
If I set caps on gnlfilesources, "pad-added" handler is simply not called.

//"pad-added" signal handler
void comp_PadAdded(object o, PadAddedArgs args)
{
    Trace.WriteLine("pad-added: "+args.Pad.Parent.Name);
}

// another function: 
// It retrieves messages from the bus and processes them by itself.

Gst.Pipeline pipeline = new Pipeline("cut");

Gst.Element comp = Gst.ElementFactory.Make("gnlcomposition","compbin");
pipeline.Add(comp);

comp.PadAdded += new PadAddedHandler(comp_PadAdded);

//FIXME: replace with proper muxer and filesink
Gst.Element asink = Gst.ElementFactory.Make("fakesink", "asink");
Gst.Element vsink = Gst.ElementFactory.Make("fakesink", "vsink");

pipeline.Add(asink);
pipeline.Add(vsink);
            
fragment[] fr = optimize_fragment_list(get_included_fragment_list()); 
Gst.Element[] filesource = new Gst.Element[fr.Length];
ulong begin = 0;
for (int i = 0; i < fr.Length; i++) {
  filesource[i] = Gst.ElementFactory.Make("gnlfilesource","fr"+i.ToString());
  ((Gst.Bin)comp).Add(filesource[i]);
  filesource[i]["location"] = Hyena.SafeUri.FilenameToUri(cur_filename); //I've stolen this from the Banshee :)
  Gst.Caps cps = Gst.Caps.FromString("video/mpeg,mpegversion=2");
  filesource[i]["caps"] = cps;
  filesource[i]["start"] = (UInt64)(begin * (ulong)pos_divisor * Gst.Clock.MSecond);
  filesource[i]["duration"] = (Int64)((ulong)(fr[i].end-fr[i].begin) * (ulong)pos_divisor * Gst.Clock.MSecond);
  filesource[i]["media-start"] = (UInt64)((ulong)fr[i].begin * (ulong)pos_divisor * Gst.Clock.MSecond);
  filesource[i]["media-duration"] = (Int64)((ulong)(fr[i].end - fr[i].begin) * (ulong)pos_divisor * Gst.Clock.MSecond);
  begin += (ulong)(fr[i].end - fr[i].begin);
}

pipeline.SetState(State.Playing);

while(!save.CancellationPending){ //this is intended to run from BackgroundWorker
  Gst.Message msg = pipeline.Bus.Pop(1000);
  bool r=true;
  if(msg!=null)
    r=BusCall(pipeline.Bus, msg);
  if (!r) 
    break;
}
Reply | Threaded
Open this post in threaded view
|

Re: How to make GNonLin not to decode videoclip?

wl2776
Administrator
In reply to this post by Edward Hervey
Edward Hervey wrote
> Is it possible to avoid decoding and pause just at the demuxing and
> discovering elementary stream formats?

  Set the caps property of the gnlfilesource to the format you want
(ex : video/mpeg,mpegversion=2 for mpeg2 video)
Have quickly created a small test program in C - same thing, it doesn't work, "pad-added" signal handler is not called, if I set "caps" property;

#include <stdio.h>
#include <stdlib.h>
#include <gst/gst.h>


static void pad_added (GstPadTemplate * templ, GstPad * newpad, gpointer data)
{
	g_print("pad_added");
	return;
}

gboolean bus_call(GstMessage *msg)
{
	switch(GST_MESSAGE_TYPE(msg)){
		case GST_MESSAGE_EOS:
			GST_INFO("eos");
			return FALSE;
		case GST_MESSAGE_ERROR:{
			GError *err;
			gchar *debug;

			gst_message_parse_error (msg, &err, &debug);

			GST_ERROR ("Error: %s", err->message);

			g_error_free (err);

			if (debug) {
				GST_ERROR ("Debug deails: %s", debug);

				g_free (debug);
			}
		}
			return FALSE;
		default:
			GST_DEBUG("message %s(%d) from %s",GST_MESSAGE_TYPE_NAME(msg),GST_MESSAGE_TYPE(msg),GST_MESSAGE_SRC_NAME(msg));
			return TRUE;
	}
}

int main(int argc,char *argv[])
{
	GstElement *pipeline;
	GstBus *bus;
	GstElement *comp;
	GstElement *filesource1;
	GstElement *filesource2;
	GstElement *asink;
	GstElement *vsink;

	gst_init(&argc,&argv);

	pipeline = gst_pipeline_new("pipeline");
	bus = gst_pipeline_get_bus(pipeline);

	comp = gst_element_factory_make("gnlcomposition","compbin");
	g_signal_connect(G_OBJECT(comp),"pad-added",pad_added,NULL);

	asink = gst_element_factory_make("fakesink","asink");
	vsink = gst_element_factory_make("fakesink","vsink");

	gst_bin_add(GST_BIN(pipeline),comp);
	gst_bin_add(GST_BIN(pipeline),asink);
	gst_bin_add(GST_BIN(pipeline),vsink);

	filesource1=gst_element_factory_make("gnlfilesource","fr1");

	g_object_set(G_OBJECT(filesource1),"location","file:///home/wl/AVIK/video/10.mpg",
									   //"caps",gst_caps_from_string("video/mpeg,mpegversion=2"),
									   "start",5*GST_MSECOND,
									   "duration",5*GST_MSECOND,
									   "media-start",0,
									   "media-duration",5*GST_MSECOND,
									   NULL);
	gst_bin_add(GST_BIN(comp),filesource1);

	filesource2=gst_element_factory_make("gnlfilesource","fr2");
	g_object_set(G_OBJECT(filesource1),"location","file:///home/wl/AVIK/video/10.mpg",
									   //"caps",gst_caps_from_string("video/mpeg,mpegversion=2"),
									   "start",125*GST_MSECOND,
									   "duration",5*GST_MSECOND,
									   "media-start",5,
									   "media-duration",5*GST_MSECOND,
									   NULL);
	gst_bin_add(GST_BIN(comp),filesource2);

	gst_element_set_state(pipeline,GST_STATE_PLAYING);

	while(1){
		GstMessage *msg=gst_bus_pop(bus);
		gboolean r;

		if(msg!=NULL)
			r=bus_call(msg);

		gst_message_unref(msg);

		if(!r)
			break;

	}

	return EXIT_SUCCESS;
}
Reply | Threaded
Open this post in threaded view
|

Re: How to make GNonLin not to decode videoclip?

wl2776
Administrator
In reply to this post by Edward Hervey
Edward Hervey wrote
  Set the caps property of the gnlfilesource to the format you want
(ex : video/mpeg,mpegversion=2 for mpeg2 video)
After looking at the gnonlin sources, I have an impression, that this will not work any way.
Because gnlurisource and gnlfilesource use uridecodebin, and there is no code in the whole gnonlin, setting caps on that bin.

Will be happy if I am wrong.
Reply | Threaded
Open this post in threaded view
|

Re: How to make GNonLin not to decode videoclip?

Sandeep Prakash
Hi All,

I have tried setting the caps for gnlfilesource for an mpeg4 video and its not working.
caps="video/mpeg, mpegversion=(int)4"
or
caps="video/mpeg, mpegversion=(int)4, systemstream=(boolean)false"

Could anyone confirm on this?

Thanks
Sandeep Prakash
http://sandeepprakash.homeip.net
Reply | Threaded
Open this post in threaded view
|

Re: How to make GNonLin not to decode videoclip?

Edward Hervey
In reply to this post by wl2776
On Mon, 2010-08-09 at 07:08 -0700, wl2776 wrote:

>
> Edward Hervey wrote:
> >
> >   Set the caps property of the gnlfilesource to the format you want
> > (ex : video/mpeg,mpegversion=2 for mpeg2 video)
> >
> After looking at the gnonlin sources, I have an impression, that this will
> not work any way.
> Because gnlurisource and gnlfilesource use uridecodebin, and there is no
> code in the whole gnonlin, setting caps on that bin.
>
> Will be happy if I am wrong.

  Works in latest gnonlin release


http://cgit.freedesktop.org/gstreamer/gnonlin/tree/gnl/gnlurisource.c#n166




------------------------------------------------------------------------------
This SF.net email is sponsored by

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to make GNonLin not to decode videoclip?

Edward Hervey
On Tue, 2010-08-10 at 09:35 +0200, Edward Hervey wrote:

> On Mon, 2010-08-09 at 07:08 -0700, wl2776 wrote:
> >
> > Edward Hervey wrote:
> > >
> > >   Set the caps property of the gnlfilesource to the format you want
> > > (ex : video/mpeg,mpegversion=2 for mpeg2 video)
> > >
> > After looking at the gnonlin sources, I have an impression, that this will
> > not work any way.
> > Because gnlurisource and gnlfilesource use uridecodebin, and there is no
> > code in the whole gnonlin, setting caps on that bin.
> >
> > Will be happy if I am wrong.
>
>   Works in latest gnonlin release

  My bad, I thought I had done a release since. It's fixed in git of
gnonlin. I'll try to do a release within the next two weeks.

>
>
> http://cgit.freedesktop.org/gstreamer/gnonlin/tree/gnl/gnlurisource.c#n166
>
>
>



------------------------------------------------------------------------------
This SF.net email is sponsored by

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to make GNonLin not to decode videoclip?

wl2776
Administrator
Thanks, it works well now.

Please, pay some attention to my another question.