summaryrefslogtreecommitdiff
path: root/test/dv2mp1.c
blob: ff0dc4956498756efcbe1aea787b679105eb93c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <gst/gst.h>

static gboolean
idle_func (gpointer data) 
{
  gst_bin_iterate (GST_BIN (data));

  return TRUE;
}

int 
main (int argc,char *argv[]) 
{
  GstElement *bin;
  GstElement *src;
  GstElement *dvdec;
  GstElement *cspace;
  GstElement *videoscale;
  GstElement *encoder;
  GstElement *fdsink;

  gint fd_video;

  gst_init (&argc, &argv);

  bin = gst_pipeline_new ("pipeline");

  src = gst_elementfactory_make ("disksrc", "src");
  gtk_object_set (GTK_OBJECT (src), "location", argv[1], "bytesperread", 480, NULL);

  dvdec = gst_elementfactory_make ("dvdec", "decoder");
  cspace = gst_elementfactory_make ("colorspace", "cspace");
  //videoscale = gst_elementfactory_make ("videoscale", "videoscale");
  //gtk_object_set (GTK_OBJECT (videoscale), "width", 352, "height",288, NULL);
  encoder = gst_elementfactory_make ("mpeg2enc", "mpeg2enc");
  fdsink = gst_elementfactory_make ("fdsink", "fdsink");

  fd_video = open (argv[2], O_CREAT|O_RDWR|O_TRUNC);
  gtk_object_set (GTK_OBJECT (fdsink), "fd", fd_video, NULL);

  gst_bin_add (GST_BIN (bin), GST_ELEMENT (src));
  gst_bin_add (GST_BIN (bin), GST_ELEMENT (dvdec));
  gst_bin_add (GST_BIN (bin), GST_ELEMENT (cspace));
  //gst_bin_add (GST_BIN (bin), GST_ELEMENT (videoscale));
  gst_bin_add (GST_BIN (bin), GST_ELEMENT (encoder));
  gst_bin_add (GST_BIN (bin), GST_ELEMENT (fdsink));

  gst_element_connect (src, "src", dvdec, "sink");
  gst_element_connect (cspace, "src", encoder, "sink");
  //gst_element_connect (videoscale, "src", encoder, "sink");
  gst_element_connect (encoder, "src", fdsink, "sink");
  gst_element_connect (dvdec, "video", cspace, "sink");

  gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PLAYING);

  g_idle_add (idle_func, bin);

  gtk_main ();

  exit (0);
}