video/mpegts in Win32 - how do i?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

video/mpegts in Win32 - how do i?

Sheshadri Mantha
hello;
i've been playing with Gstreamer in win32 environment for the past
week+.  while i'm able to get the basic tutorial on the oggvorbis audio
working, and able to play videos w/o MPEGTS, i'm unable to play ** ANY
** MPEG video.

here's what I've tried;

   1. embellished the example of oggvorbis to apply/use ffmpeg demuxer,
      ffmpeg video decoder, ffmpeg audio decoder (mp3) and linking to
      directdrawsink and directsoundsink respectively.  The app seems to
      link everything ok, the pads are discovered and link fine - BUT
      there is no video displayed nor audio played.  Since i'm using the
      release win32 builds of gstreamer and plugins, can't step into to
      see whats going on.  (Bit later -- ran it with --gst-debug-level=3
      and discovered that it can't find MPEG-TS demuxer!!!   ALAS!!).
   2. So, then i discovered, gst-launch.  I've tried many variations of
      filesrc location="c:/mydir/my.mpg" ! playbin  and it complains
      that decodebin0 does not have an Mpeg-TS demuxer.
   3. i've tried all combinations of using mpegdemux, mpegparse w/w/o
      queues and to no avail.
   4. checked the documentation (scant) and learned that ffmpeg plugins
      are not advised... so moving to using fluentos but can't find the
      binaries nor know how to build them on Win32.

Some questions:

   1. are there options that i can supply to playbin to get it to play
      an mpeg ts file??  to decodebin ??
   2. does anyone in Win32 have a successful pipeline that uses the base
      plugins and/or good plugins only to play Mpeg2 TS (with mp2 audio)?
   3. if i'm "supposed" to use fluento, how do I build them (tomorrow,
      i'll start slapping the source files into a project and
      workthrough any errors).  if someone has vcprojs please post them
   4. whats the best way to build debug versions of the dlls ?  I've
      tried OABuild and after several days of fighting with patch and
      also with compile and link errors,  simply gave up!  Again, if
      there are vcprojs, please post them or make them avail through cvs.
   5. once i get the basic audio/video player working, i imagine that i
      can get private data - seems to me that it'd be another new pad
      added to the demuxer
   6. i also presume,  that i'd be able to scale the video using the
      videoscale plugin

i'm posting the video.c source herewith for reference.

please review and suggest ways to fix/augment/embellish otherwise make
it work!!

Thank you very much,

kindest regards,
Shesh

        /*
        * OggAudio.c
        * Test program to practice gstreamer
        */

#include <gst/gst.h>
#include <string.h>

static gboolean
bus_call (GstBus *bus, GstMessage *msg, gpointer data)
{
  GMainLoop *loop = (GMainLoop *) data;

  switch (GST_MESSAGE_TYPE (msg)) {
    case GST_MESSAGE_EOS:
      g_print ("End-of-stream\n");
      g_main_loop_quit (loop);
      break;
    case GST_MESSAGE_ERROR: {
      gchar *debug;
      GError *err;

      gst_message_parse_error (msg, &err, &debug);
      g_free (debug);

      g_print ("Error: %s\n", err->message);
      g_error_free (err);

      g_main_loop_quit (loop);
      break;
    }
    default:
      break;
  }

  return TRUE;
}
static void new_pad(GstElement *element, GstPad *pad, gpointer data) {
        GstPad *sinkpad;
        gchar *cstr;
        const gchar* name;
        GstElement *audioq, *videoq;
        GstElement *pipeline = (GstElement*) data;
        GstCaps *caps = gst_pad_get_caps(pad);
        GstStructure *stru = gst_caps_get_structure(caps, 0);
        cstr = gst_caps_to_string(caps);
        name = gst_structure_get_name(stru);
        videoq = gst_bin_get_by_name (GST_BIN (pipeline), "videoq");
        audioq = gst_bin_get_by_name(GST_BIN(pipeline), "audioq");
       
        g_print ("caps are %s\n 0th is:{%s}\nname is:%s", cstr, gst_structure_to_string(stru), name);
        if (strcmp(name, "video/mpeg") == 0)
                sinkpad = gst_element_get_pad(videoq, "sink");
        else if (strcmp(name, "audio/mpeg") == 0)
                sinkpad = gst_element_get_pad(audioq, "sink");

        if (!gst_pad_is_linked(pad)) {
                gchar* srcname = gst_pad_get_name(pad);
                gchar* sinkname = gst_pad_get_name(sinkpad);
                GstPadLinkReturn stat;
               
                g_print("can_link %s to %s returned %s\n", srcname, sinkname, gst_pad_can_link(pad, sinkpad) ? "YES!": "NO!!");
                gst_element_set_state(pipeline, GST_STATE_PAUSED);
                stat = gst_pad_link (pad, sinkpad);
                gst_element_set_state (pipeline, GST_STATE_PLAYING);
                g_print("Link status:%d\tReset to Playing\n", stat);
        }
        gst_caps_unref(caps);
// gst_object_unref (sinkpad);
}

int mpegVideo(int argc, char* argv[]) {
        GMainLoop *loop;
        GstBus *bus;
        GstElement *pipeline, *source, *demux, *vdecoder, *vsink, *vconv;
        GstElement *adecoder, *aconv, *asink;
        GstElement *audioq, *videoq;

        loop = g_main_loop_new(NULL, FALSE);

        /* create the elements */
        pipeline = gst_pipeline_new ("mpeg-player");
        source = gst_element_factory_make ("filesrc", "file-source");
        demux = gst_element_factory_make ("mpegdemux", "ffdemux-mpegts");
        audioq = gst_element_factory_make("queue", "audioq");
        videoq = gst_element_factory_make("queue", "videoq");
        vdecoder = gst_element_factory_make ("ffdec_mpegvideo", "mpeg2-vdecoder");
        vconv = gst_element_factory_make("ffmpegcolorspace", "colorconv");
        adecoder = gst_element_factory_make("ffdec_mp3", "mpeg2-adecoder");
        aconv = gst_element_factory_make ("audioconvert", "converter");
        asink = gst_element_factory_make ("directsoundsink", "audio-output");
        vsink = gst_element_factory_make("directdrawsink", "video-output");
        if (!pipeline || !source || !demux || !audioq || !videoq ||
                        !vdecoder || !vconv || !adecoder || !aconv || !asink || !vsink) {
                g_print ("One element could not be created\n");
                return -1;
        }

        /* set filename property on the file source. Also add a message
        * handler. */
        g_object_set (G_OBJECT (source), "location", argv[1], NULL);

        bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
        gst_bus_add_watch (bus, bus_call, loop);
        gst_object_unref (bus);

        /* put all elements in a bin */
        gst_bin_add_many (GST_BIN (pipeline),
                        source, demux, vdecoder, audioq, videoq, adecoder, aconv, asink, vsink, NULL);

        /* link together - note that we cannot link the demux and
        * decoder yet, becuse the demux uses dynamic pads. For that,
        * we set a pad-added signal handler. */
        gst_element_link (source, demux);
        gst_element_link_many (audioq, adecoder, aconv, asink, NULL);
        gst_element_link_many (videoq, vdecoder, vconv, vsink, NULL);
        g_signal_connect (demux, "pad-added", G_CALLBACK (new_pad), pipeline);

        /* Now set to playing and iterate. */
        g_print ("Setting to PLAYING\n");
        gst_element_set_state (pipeline, GST_STATE_PLAYING);
        g_print ("Running\n");
        g_main_loop_run (loop);

        /* clean up nicely */
        g_print ("Returned, stopping playback\n");
        gst_element_set_state (pipeline, GST_STATE_NULL);
        g_print ("Deleting pipeline\n");
        gst_object_unref (GST_OBJECT (pipeline));

        return 0;
}

int main(int argc, char* argv[]) {
        if (argc != 2) {
                g_print("Usage: %s <Ogg/Vorbis filename>\n", argv[0]);
                return -1;
        }
        /* Initialize the gstreamer */
        gst_init(&argc, &argv);
        mpegVideo(argc, argv);
}
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel

sheshadri_mantha.vcf (392 bytes) Download Attachment