libvlc_video_take_snapshot

This forum is about all development around libVLC.
ivanisimus
Blank Cone
Blank Cone
Posts: 10
Joined: 30 Apr 2013 11:22

libvlc_video_take_snapshot

Postby ivanisimus » 24 Jun 2013 11:49

please help with libvlc_video_take_snapshot
here is my code

Code: Select all

bool TVLCManager::SnapShot(String fn) { if (mp) { return libvlc_video_take_snapshot(mp,0,AnsiString(fn).c_str(),0,0)==0; } return false; }
i call this from main thread

when i call this, my program hangs (snapshot created, but movie stops, and main window does not answer the messages)
Please, any help!

Dll File Version Information :

Version language : Английский (США)
CompanyName : VideoLAN
ProductName : VLC media player
ProductVersion : 2,0,6,0
FileVersion : 2.0.6
FileDescription : VLC media player 2.0.6

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: libvlc_video_take_snapshot

Postby Jean-Baptiste Kempf » 24 Jun 2013 17:12

Don't run it on the main thread.
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.

ivanisimus
Blank Cone
Blank Cone
Posts: 10
Joined: 30 Apr 2013 11:22

Re: libvlc_video_take_snapshot

Postby ivanisimus » 24 Jun 2013 17:24

what should i do? do i need to create new thread every time for create snapshot? thanks for answers

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

Re: libvlc_video_take_snapshot

Postby Rémi Denis-Courmont » 24 Jun 2013 18:11

A number of libvlc functions may block the message queue while waiting for something to happen inside LibVLC. You cannot rely on the message pump to run meanwhile.

How you fix that, is really a matter of your software design.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

AlexJung
New Cone
New Cone
Posts: 2
Joined: 10 Nov 2016 10:46

Re: libvlc_video_take_snapshot

Postby AlexJung » 10 Nov 2016 11:11

Hi, I have a problem in capturing screen.

current libvlc_video_take_snapshot source code in git is below:
libvlc_video_take_snapshot(...){
assert( psz_filepath );

vout_thread_t *p_vout = GetVout (p_mi, num);
if (p_vout == NULL)
return -1;

/* FIXME: This is not atomic. All parameters should be passed at once
* (obviously _not_ with var_*()). Also, the libvlc object should not be
* used for the callbacks: that breaks badly if there are concurrent
* media players in the instance. */
var_Create( p_vout, "snapshot-width", VLC_VAR_INTEGER );
var_SetInteger( p_vout, "snapshot-width", i_width);
var_Create( p_vout, "snapshot-height", VLC_VAR_INTEGER );
var_SetInteger( p_vout, "snapshot-height", i_height );
var_Create( p_vout, "snapshot-path", VLC_VAR_STRING );
var_SetString( p_vout, "snapshot-path", psz_filepath );
var_Create( p_vout, "snapshot-format", VLC_VAR_STRING );
var_SetString( p_vout, "snapshot-format", "png" );
var_TriggerCallback( p_vout, "video-snapshot" );
vlc_object_release( p_vout );
return 0;
}

I call this funtcion and return 0 successfully.
but there was no capture file that I expected place.
I develop in Android OS and code is below;

- in Android test java file
new Thread(new Runnable() {
public void run() {
boolean result = mLibVLC.takeSnapshot(0, "/sdcard/Android/data/com.ebs.android/capture.png", 640, 480);
if(result)
Log.d("EBSSAMPLE", "snapshot success");
}
}).start();


- in Jni function

jboolean Java_org_videolan_libvlc_LibVLC_takeSnapshot(JNIEnv *env, jobject thiz, jint number, jstring jpath, jint width,jint height) {
vlcjni_object *p_obj = VLCJniObject_getInstance(env, thiz);
const char* psz_path;

if (!p_obj)
return;

libvlc_media_player_t *mp = (libvlc_media_player_t *)(p_obj->u.p_mp);

psz_path = jpath ? (*env)->GetStringUTFChars(env, jpath, 0) : NULL;

if(mp && psz_path){
if(libvlc_video_take_snapshot(mp, (int)number, psz_path, (int)width, (int)height) == 0) {
(*env)->ReleaseStringUTFChars(env, jpath, psz_path);
return JNI_TRUE;
}else{
(*env)->ReleaseStringUTFChars(env, jpath, psz_path);
}
}

return JNI_FALSE;
}

Anyone's helps or advices are appreciate that I must check to solve this problem.


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 14 guests