How to take screenshots from a stream without displaying the GUI?

This forum is about all development around libVLC.
SunliMin
New Cone
New Cone
Posts: 1
Joined: 11 May 2016 21:29

How to take screenshots from a stream without displaying the GUI?

Postby SunliMin » 11 May 2016 21:41

I am writing a program for the Raspberry Pi which utilizes libVLC to read rawvideo data from standard input and periodically (roughly twice a second) takes a screenshot from the rawvideo data and saves the image to a particular location.

The program words perfectly on Ubuntu, but when I move it over to the Raspberry Pi it is insanely sluggish and throws errors everywhere. After researching these error messages, it appears to be an issue with VLC being too heavy weight of a program for the Raspberry Pi. The issue though is in the rendering of the image in the VLC display.

The simplest solution I can think of is seeing if libVLC can let you take screenshots of the stream WITHOUT needing to render it in the UI? Is there a way to just have it running in the background/terminal and just take screenshots from behind the scenes?

Thank you for your time, my program is listed below. The line that causes all the rendering has the comment on it.

-----

Code: Select all

#include <stdio.h> #include <stdlib.h> #include <signal.h> #include <unistd.h> #include <vlc/vlc.h> #define SCREENSHOTRATE 2 void handleTerminate(int code); libvlc_instance_t *inst; libvlc_media_player_t *mp; libvlc_media_t *m; int terminate; int main(int argc, char **argv) { const char * const vlc_argv[] = { "--demux", "rawvideo", "--rawvid-height=480", "--rawvid-width=720", "--rawvid-chroma=UYVY", "--rawvid-aspect-ratio=3:2", "--rawvid-fps=29.97", "--clock-jitter=0", "-Incurse" }; int vlc_argc = sizeof(vlc_argv) / sizeof(vlc_argv[0]); signal(SIGINT, handleTerminate); terminate = 0; int screenshotResult = 0; inst = libvlc_new(vlc_argc, vlc_argv); mp = libvlc_media_player_new(inst); m = libvlc_media_new_fd(inst, 0); libvlc_media_player_set_media(mp, m); libvlc_media_player_play(mp); //This line pops up GUI. Can we remove it and still take screenshots somehow? //Sleep 2 seconds to let VLC open usleep(2000000); while(!terminate) { usleep(1000000 / SCREENSHOTRATE); screenshotResult = libvlc_video_take_snapshot(mp, 0, "pic.png", 0, 0); if (screenshotResult == -1) { printf("[ERROR] Screenshot failed. Exiting program.\n"); terminate = 1; } } libvlc_media_release(m); libvlc_media_player_stop(mp); libvlc_media_player_release(mp); libvlc_release(inst); printf("\nResources released successfully\n"); return 0; } void handleTerminate(int code) { terminate = 1; }

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: How to take screenshots from a stream without displaying the GUI?

Postby Jean-Baptiste Kempf » 28 Jun 2016 10:10

Look at the Android thumbnailer.
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 25 guests