From: Noam H. <noa...@gm...> - 2005-09-26 13:07:29
|
I am trying to use xinelib for decoding files and reencoding them. while xine_get_next_video_frame works ok, I can't get xine_get_next_audio_frame to work. the frame.data point is either 0 or invalid. also (audio_buffer_t*)frame.xine_frame contains strange data. I am using xine 1.0.2 on redhat enterprise linux 3, 2.4.21-17.ELsmp #1 SMP, gcc 3.2.3 Thanks, noam This is the test application: #include <stdio.h> #include <string.h> #include <math.h> #include <sys/time.h> #define XINE_ENABLE_EXPERIMENTAL_FEATURES #include <xine.h> #include <xine/xineutils.h> #include <xine/audio_out.h> static xine_t *xine; static xine_stream_t *stream; static xine_video_port_t *vo_port; static xine_audio_port_t *ao_port; static xine_video_frame_t video_frame; static xine_audio_frame_t audio_frame; int main(int argc, char **argv) { =09char configfile[2048]; =09double res_h, res_v; =09char *mrl =3D NULL; =09int i; =09 =09if(argc <=3D 1) { =09=09printf("specify one mrl\n"); =09=09return 0; =09} =09 =09mrl =3D argv[1]; =09 =09xine =3D xine_new(); =09sprintf(configfile, "%s%s", xine_get_homedir(), "/.xine/config"); =09printf ("configfile=3D%s\n", configfile); =09xine_config_load(xine, configfile); =09xine_init(xine); =09 =09xine_engine_set_param(xine, XINE_ENGINE_PARAM_VERBOSITY, XINE_VERBOSITY_= DEBUG); =09vo_port =3D xine_new_framegrab_video_port(xine); =09if( vo_port=3D=3D NULL) { =09=09printf("I'm unable to initialize video driver. Giving up.\n"); =09=09return 0; =09} =09 =09ao_port =3D xine_new_framegrab_audio_port(xine); =09if( ao_port=3D=3D NULL) { =09=09printf("I'm unable to initialize audio driver. Giving up.\n"); =09=09return 0; =09} =09stream =3D xine_stream_new(xine, ao_port, vo_port); =09 =09if(!xine_open(stream, mrl)) { =09=09printf("Unable to open mrl '%s'\n", mrl); =09=09return 0; =09} =09xine_play(stream, 0, 0); =09 =09// dump video =09int res =3D 1; #if 0 =09printf("video:\n"); =09while (res) =09{ =09=09res =3D xine_get_next_video_frame (vo_port,&video_frame); =09=09printf("res =3D %d, w =3D %d, h =3D %d, data =3D %x, pos_s =3D %d, po= s_t =3D %d\n", =09=09=09res, =09=09=09video_frame.width, =09=09=09video_frame.height, =09=09=09video_frame.data, =09=09=09video_frame.pos_stream, =09=09=09video_frame.pos_time); =09=09xine_free_video_frame(vo_port, &video_frame); =09} #endif =09 =09// dump audio =09printf("audio:\n"); =09res =3D 1; =09while (res) =09{ =09=09res =3D xine_get_next_audio_frame(ao_port, &audio_frame); =09=09printf("samples =3D %d, channels =3D %d, bps =3D %d, data =3D %x, pos= _s =3D %d, pos_t =3D %d, xineframe =3D %x\n", =09=09=09audio_frame.num_samples, =09=09=09audio_frame.num_channels, =09=09=09audio_frame.bits_per_sample, =09=09=09audio_frame.data, =09=09=09audio_frame.pos_stream, =09=09=09audio_frame.pos_time, =09=09=09audio_frame.xine_frame); =09=09audio_buffer_t* aubuf =3D (audio_buffer_t*)audio_frame.xine_frame; =09=09printf ("next =3D %x, mem =3D %x, mem_size =3D %d, num =3D %d\n", aubuf->next, aubuf->mem, aubuf->mem_size, aubuf->num_frames); =09=09if (res) =09=09{ =09=09=09xine_free_audio_frame(ao_port, &audio_frame); =09=09} =09} =09xine_close(stream); =09xine_dispose(stream); =09if(ao_port) =09=09xine_close_audio_driver(xine, ao_port); =09if(vo_port) =09=09xine_close_video_driver(xine, vo_port); =09xine_exit(xine); =09 =09return 1; } |