python-vlc icon indicating copy to clipboard operation
python-vlc copied to clipboard

SET Audio Track

Open fredycoding opened this issue 4 years ago • 6 comments

Hi. I have a video with two audio tracks, but with SET detects one, and with GET detects 3 audio_set_track(2) not working image

fredycoding avatar Apr 24 '21 16:04 fredycoding

Try calling media_player.audio_set_track(2) after the call to media_player.play().

mrJean1 avatar Apr 24 '21 16:04 mrJean1

Hi mrJean1, thanks for your answer, Your answer served me but I have to double play and double sleep to make it work. In the player only works that way for me and I can listen to the second track of the video. image

fredycoding avatar Apr 24 '21 21:04 fredycoding

Here the code

import vlc, time
media_player = vlc.MediaPlayer()

mrl = "video.mp4"

media_player.set_mrl(mrl) media_player.audio_set_volume (100) media_player.set_role(1) media_player.audio_set_mute(False)

media_player.play() time.sleep(0.1) media_player.audio_set_track(2) media_player.play() time.sleep(5)

value = media_player.audio_get_track_count() print(f"Audio get track count: {value}")

value = media_player.audio_get_track() print(f"Audio get track: {value}")

value = media_player.audio_get_mute() print(f"Audio Get mute: {value}")

value = media_player.audio_get_channel() print(f"Audio Get channel: {value}")

value = media_player.audio_get_volume() print(f"Audio Get Volume: {value}")

value = media_player.audio_output_device_enum() print(f"Audio output device enum: {value}")

value = media_player.audio_output_device_get() print(f"Audio output device: {value}")

value = media_player.get_full_title_descriptions() print(f"Get full title descriptions: {value}")

value = media_player.get_role() print(f"Get Role: {value}")

fredycoding avatar Apr 24 '21 22:04 fredycoding

Does the problem occur when you play that video in the VLC app on the same computer?

mrJean1 avatar Apr 24 '21 22:04 mrJean1

No that doesn't happen, when I play the video in VLC I choose track 2 and it works fine. I have tried with mkv and mp4 and I have converted various types of video and the same thing happens image

fredycoding avatar Apr 24 '21 23:04 fredycoding

I also have this problem, even I have run parse() and got 4 tracks info before media_player.play():

import vlc mrl = "D:\test.mkv" m = vlc.Media(mrl) m.parse() tracks = list(m.tracks_get()) print(len(tracks)) # this got 4 tracks

p= vlc.MediaPlayer() p.set_media(m) print(p.audio_get_track_description()) # this got [ ] print(p.audio_get_track_count()) # this got -1 p.audio_set_track(2) # I set track 2 to play, but have no result p.play() # still played track 1

my win10 64bit vlc player version is up to day.

import vlc vlc.libvlc_get_version() b'3.0.12 Vetinari'

any recomendation on this is appreciative. @oaubert @mrJean1 @xbox360colombia

huangxin168 avatar May 03 '21 07:05 huangxin168