2002-10-20 17:12:54 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <gst/gst.h>
|
|
|
|
|
|
|
|
/* This example app demonstartes the use of pad query and convert to
|
|
|
|
* get usefull statistics about a plugin. In this case we monitor the
|
|
|
|
* compression status of mpeg audio to ogg vorbis transcoding.
|
|
|
|
*/
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gint
|
|
|
|
main (gint argc, gchar * argv[])
|
2002-10-20 17:12:54 +00:00
|
|
|
{
|
|
|
|
GstElement *pipeline;
|
|
|
|
GError *error = NULL;
|
|
|
|
gchar *description;
|
|
|
|
GstElement *encoder, *decoder;
|
|
|
|
GstPad *dec_sink, *enc_src;
|
|
|
|
|
|
|
|
gst_init (&argc, &argv);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2002-10-20 17:12:54 +00:00
|
|
|
if (argc < 3) {
|
|
|
|
g_print ("usage: %s <inputfile> <outputfile>\n", argv[0]);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
description = g_strdup_printf ("filesrc location=\"%s\" ! mad name=decoder ! "
|
2004-03-14 22:34:33 +00:00
|
|
|
"vorbisenc name=encoder ! filesink location=\"%s\"", argv[1], argv[2]);
|
2002-10-20 17:12:54 +00:00
|
|
|
|
|
|
|
pipeline = GST_ELEMENT (gst_parse_launch (description, &error));
|
|
|
|
if (!pipeline) {
|
|
|
|
if (error)
|
2004-03-14 22:34:33 +00:00
|
|
|
g_print ("ERROR: pipeline could not be constructed: %s\n",
|
2004-03-15 19:32:27 +00:00
|
|
|
error->message);
|
2002-10-20 17:12:54 +00:00
|
|
|
else
|
2004-03-14 22:34:33 +00:00
|
|
|
g_print ("ERROR: pipeline could not be constructed\n");
|
2002-10-20 17:12:54 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
decoder = gst_bin_get_by_name (GST_BIN (pipeline), "decoder");
|
|
|
|
encoder = gst_bin_get_by_name (GST_BIN (pipeline), "encoder");
|
|
|
|
|
|
|
|
dec_sink = gst_element_get_pad (decoder, "sink");
|
|
|
|
enc_src = gst_element_get_pad (encoder, "src");
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2002-10-20 17:12:54 +00:00
|
|
|
if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS) {
|
|
|
|
g_print ("pipeline doesn't want to play\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (gst_bin_iterate (GST_BIN (pipeline))) {
|
|
|
|
gint64 position;
|
|
|
|
gint64 duration;
|
|
|
|
gint64 bitrate_enc, bitrate_dec;
|
|
|
|
GstFormat format;
|
|
|
|
|
|
|
|
format = GST_FORMAT_TIME;
|
|
|
|
/* get the position */
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_pad_query (enc_src, GST_QUERY_POSITION, &format, &position);
|
2002-10-20 17:12:54 +00:00
|
|
|
|
|
|
|
/* get the total duration */
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_pad_query (enc_src, GST_QUERY_TOTAL, &format, &duration);
|
2002-10-20 17:12:54 +00:00
|
|
|
|
|
|
|
format = GST_FORMAT_BYTES;
|
|
|
|
/* see how many bytes are genereated per 8 seconds (== bitrate) */
|
|
|
|
gst_pad_convert (enc_src, GST_FORMAT_TIME, 8 * GST_SECOND,
|
2004-03-15 19:32:27 +00:00
|
|
|
&format, &bitrate_enc);
|
2002-10-20 17:12:54 +00:00
|
|
|
|
|
|
|
gst_pad_convert (dec_sink, GST_FORMAT_TIME, 8 * GST_SECOND,
|
2004-03-15 19:32:27 +00:00
|
|
|
&format, &bitrate_dec);
|
2002-10-20 17:12:54 +00:00
|
|
|
|
|
|
|
g_print ("[%2dm %.2ds] of [%2dm %.2ds], "
|
Fixes: #151879, #151881, #151882, #151883, #151884, #151886, #151887, #152102, #152247.
Original commit message from CVS:
Fixes: #151879, #151881, #151882, #151883, #151884, #151886,
#151887, #152102, #152247.
* examples/indexing/indexmpeg.c: 64-bit warning fixes.
* examples/seeking/cdparanoia.c: same
* examples/seeking/cdplayer.c: same
* examples/seeking/seek.c: same
* examples/seeking/spider_seek.c: same
* examples/seeking/vorbisfile.c: same
* examples/stats/mp2ogg.c: same
* ext/esd/esdsink.c: (gst_esdsink_class_init),
(gst_esdsink_dispose): Dispose of element properly.
* ext/ivorbis/vorbisfile.c: (gst_ivorbisfile_seek): 64-bit warning
fixes.
* ext/nas/nassink.c: (gst_nassink_class_init),
(gst_nassink_dispose): Dispose of element correctly.
* gst/wavenc/gstwavenc.c: (gst_wavenc_chain): Fix leak.
* sys/ximage/ximagesink.c: (gst_ximagesink_check_xshm_calls),
(gst_ximagesink_ximage_new), (gst_ximagesink_ximage_destroy):
Fix 64-bit warning.
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_check_xshm_calls),
(gst_xvimagesink_xvimage_new), (gst_xvimagesink_xvimage_destroy):
Fix 64-bit warning.
2004-09-12 22:57:26 +00:00
|
|
|
"src avg bitrate: %" G_GINT64_FORMAT ", dest avg birate: %"
|
|
|
|
G_GINT64_FORMAT ", ratio [%02.2f] \r",
|
2004-03-15 19:32:27 +00:00
|
|
|
(gint) (position / (GST_SECOND * 60)),
|
|
|
|
(gint) (position / (GST_SECOND)) % 60,
|
|
|
|
(gint) (duration / (GST_SECOND * 60)),
|
Fixes: #151879, #151881, #151882, #151883, #151884, #151886, #151887, #152102, #152247.
Original commit message from CVS:
Fixes: #151879, #151881, #151882, #151883, #151884, #151886,
#151887, #152102, #152247.
* examples/indexing/indexmpeg.c: 64-bit warning fixes.
* examples/seeking/cdparanoia.c: same
* examples/seeking/cdplayer.c: same
* examples/seeking/seek.c: same
* examples/seeking/spider_seek.c: same
* examples/seeking/vorbisfile.c: same
* examples/stats/mp2ogg.c: same
* ext/esd/esdsink.c: (gst_esdsink_class_init),
(gst_esdsink_dispose): Dispose of element properly.
* ext/ivorbis/vorbisfile.c: (gst_ivorbisfile_seek): 64-bit warning
fixes.
* ext/nas/nassink.c: (gst_nassink_class_init),
(gst_nassink_dispose): Dispose of element correctly.
* gst/wavenc/gstwavenc.c: (gst_wavenc_chain): Fix leak.
* sys/ximage/ximagesink.c: (gst_ximagesink_check_xshm_calls),
(gst_ximagesink_ximage_new), (gst_ximagesink_ximage_destroy):
Fix 64-bit warning.
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_check_xshm_calls),
(gst_xvimagesink_xvimage_new), (gst_xvimagesink_xvimage_destroy):
Fix 64-bit warning.
2004-09-12 22:57:26 +00:00
|
|
|
(gint) (duration / (GST_SECOND)) % 60, bitrate_dec, bitrate_enc,
|
|
|
|
(gfloat) bitrate_dec / bitrate_enc);
|
2002-10-20 17:12:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_print ("\n");
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2002-10-20 17:12:54 +00:00
|
|
|
return 0;
|
|
|
|
}
|