LibVLC with Hardware Acceleration (???)

*nix specific usage questions
mrblue1234
Blank Cone
Blank Cone
Posts: 21
Joined: 12 May 2017 19:53

LibVLC with Hardware Acceleration (???)

Postby mrblue1234 » 14 Jul 2017 00:27

All,

I hope you are having a great day.

1.) I have compiled VLC (2.2.5.1) to use hardware acceleration and I can play back 1080p videos smoothly without any choppiness of the video or audio.

2.) But when I use LibVLC to play the same video the video is choppy and the CPU usage jumps to 100%. The audio continues to play smoothly. How can I get the LibVLC version that I am using to use the hardware acceleration? I am compiling my LibVLC program like this:

cc vlc_player.c -lvlc -o vlc_player

3.) Is there another flag to add when compiling?

Thank you.

-Mike

Rémi Denis-Courmont
Developer
Developer
Posts: 15265
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: LibVLC with Hardware Acceleration (???)

Postby Rémi Denis-Courmont » 16 Jul 2017 14:07

No. Usually, this breaks either because you have added bad parameters in the libvlc_new() call, or because you use custom callbacks for video rendering.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

mrblue1234
Blank Cone
Blank Cone
Posts: 21
Joined: 12 May 2017 19:53

Re: LibVLC with Hardware Acceleration (???)

Postby mrblue1234 » 17 Jul 2017 18:08

Thanks for the post Remi.

1.) My call to libvlc_new() is like this:

/* Load the VLC engine */
inst = libvlc_new (0, NULL);

Does this look correct?

2.) I don't believe I am using an custom callbacks.

3.) Here is my code below toggling between audio output devices.

Code: Select all

#include <stdio.h> #include <stdlib.h> #include <vlc/vlc.h> // old #include <vlc/libvlc_media_player.h> int main(int argc, char* argv[]) { libvlc_instance_t * inst; libvlc_media_player_t *mp; libvlc_media_t *m; libvlc_audio_output_t *audio_list; int var_test = 0; libvlc_audio_output_device_t *audio_output_list; int i = 0; char debug_string[500]; int64_t delayplayer = 100; printf("This is going somewhere.....\n\n\n"); /* Load the VLC engine */ inst = libvlc_new (0, NULL); ///////////////////////////////////////////////////////////////////////////////// // The list here will give me the list of available output modules. // we wnat to be using the alsa module. ///////////////////////////////////////////////////////////////////////////////// audio_list = libvlc_audio_output_list_get(inst); printf("Print out all the audio modules here......\n\n"); for ( var_test =0; var_test < 6; var_test++) { printf("The address of the pointer here %X \n", audio_list); printf("The psz_name field is %s \n", audio_list->psz_name); printf("The psz_descriptoin is %s \n", audio_list->psz_description); printf("The psz_descriptoin field is %X \n\n\n", audio_list->p_next); audio_list = audio_list->p_next; } // Free's the list of available audio output modules libvlc_audio_output_list_release(audio_list); ///////////////////////////////////////////////////////////////////////////////// // Here I am getting a list of audio output devices for a given audio output /////////////////////////////////////////////////////////////////////////////// audio_output_list = libvlc_audio_output_device_list_get(inst,"alsa"); printf("Printing out all the audio outputs here......\n\n"); for ( var_test =0; var_test < 18; var_test++) { printf("The address of the pointer here %X \n", audio_output_list); printf("The psz_name (device ID) field is %s \n", audio_output_list->psz_device); printf("The psz_descriptoin is %s \n", audio_output_list->psz_description); printf("Next entry in list: %X \n\n\n", audio_output_list->p_next); audio_output_list = audio_output_list->p_next; } libvlc_audio_output_device_list_release(audio_output_list); ////////////////////////////////////////////////////////////////////// /* Create a new item */ m = libvlc_media_new_path (inst, "/home/pi/libvlc/h.mp4"); /* Create a media player playing environement */ mp = libvlc_media_player_new_from_media (m); /* No need to keep the media now */ libvlc_media_release (m); ///////////////////////////////////////////////// libvlc_audio_output_set(mp,"alsa"); // This has to be here or audio wil not play ///////////////////////////////////////////////////////////// // This will play to the external speakers and sound bar libvlc_audio_output_device_set(mp,"alsa","hw:CARD=sndrpihifiberry,DEV=0"); // Audio 1 // libvlc_audio_output_device_set(mp,"alsa","hw:CARD=ALSA,DEV=1"); // Audio 2 TV libvlc_audio_output_set(mp,"alsa"); // This has to be here or audio wil not play printf("\n\nStarting the player.....\n\n\n"); libvlc_media_player_play (mp); sleep (10); printf("Doing the switch....\n"); libvlc_audio_output_device_set(mp,NULL,"hw:CARD=ALSA,DEV=1"); sleep (10); libvlc_audio_output_device_set(mp,NULL,"hw:CARD=sndrpihifiberry,DEV=0"); // Audio 1 sleep (10); libvlc_audio_output_device_set(mp,NULL,"hw:CARD=ALSA,DEV=1"); sleep (10); printf("\n\nStopping the player \n\n\n"); /* Stop playing */ libvlc_media_player_stop (mp); /* Free the media_player */ libvlc_media_player_release (mp); libvlc_release (inst); return 0; }
Any ideas?

Thanks.

-Mike

Rémi Denis-Courmont
Developer
Developer
Posts: 15265
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: LibVLC with Hardware Acceleration (???)

Postby Rémi Denis-Courmont » 18 Jul 2017 14:07

That should work just fine. Are you using default VLC settings??
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

mrblue1234
Blank Cone
Blank Cone
Posts: 21
Joined: 12 May 2017 19:53

Re: LibVLC with Hardware Acceleration (???)

Postby mrblue1234 » 18 Jul 2017 18:31

I am compiling and running the above LibVLC program as shown below:

$ cc vlc_demo.c -lvlc -o vlc_demo

$ ./vlc_demo

(the result is choppy video but the audio is fine).

If I just run vlc directly this runs perfectly (smooth video and audio)

$ vlc video.mp4

Other ideas?

Thanks.

-Mike

Rémi Denis-Courmont
Developer
Developer
Posts: 15265
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: LibVLC with Hardware Acceleration (???)

Postby Rémi Denis-Courmont » 23 Jul 2017 20:23

Does it work with the DEFAULT VLC settings?
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded


Return to “VLC media player for Linux and friends Troubleshooting”

Who is online

Users browsing this forum: No registered users and 4 guests