Getting Audio from a Movie

I am having difficulty getting the audio from a movie file, I’ve tried a few different ways but haven’t been able to get it to work properly. I can get the video to work, but the audio won’t work. Anyone know the proper way of doing this?

I’ve tried AudioSound and it won’t open a movie file. So I tried using MovieSound but I can’t sync that to the video… so I converted that to an AudioSound and it doesn’t play anything. The examples all show using loader, which doesn’t seem to have loadSfx in C++… I must be missing something…

What audio codec does your video have? Have you tested video with other codecs?

I used the video that was supplied with the Python example of the code… not sure the codecs it is using but I did try 2 other videos with the same soundless results.

Can you post your code?

alright, here is my code… pretty messy but ive been trying to mash together the different documentation on it. If I do not sync the audio with the video then the video plays fine… and the AudioSound itself will not play. So it seems it’s not reading the audio from the movie file properly…

and just to re-iterate, I created the MovieAudio because the AudioSound wouldn’t read directly from the file, and then I converted it to AudioSound because I couldn’t sync the MovieTexture to MovieAudio… is there a function that would do that, or another method to convert?

	PT(TextureStage) TStage = new TextureStage("TStage");
	PT(MovieTexture) TMovie = new MovieTexture("TMovie");
	PT(MovieAudio) MAudio = new MovieAudio("MAudio");
	TMovie->read(MEDIAFILE);
    CardMaker cm("FSCard");
	cm.set_frame_fullscreen_quad();
    cm.set_uv_range(TMovie);
    NodePath card(cm.generate());
	card.reparent_to(window->get_render_2d());
	card.set_texture(TMovie);
	card.set_tex_scale(TStage->get_default(), TMovie->get_tex_scale());
	MAudio->get(MEDIAFILE);
	PT(AudioManager) AM = AudioManager::create_AudioManager();
	PT(AudioSound) ASound = AM->get_sound(MAudio);
	TMovie->synchronize_to(ASound);

Ah, you haven’t set the AudioManager to active,say like this

AM->set_active(true); 

And also you need to play the sound like this

 ASound->play();

And you need to have a task or thread to say

 AM->update(); 

That should let your stuff work.