libvlc_video_take_snapshot
Posted: 24 Jun 2013 11:49
by ivanisimus
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
Re: libvlc_video_take_snapshot
Posted: 24 Jun 2013 17:12
by Jean-Baptiste Kempf
Don't run it on the main thread.
Re: libvlc_video_take_snapshot
Posted: 24 Jun 2013 17:24
by ivanisimus
what should i do? do i need to create new thread every time for create snapshot? thanks for answers
Re: libvlc_video_take_snapshot
Posted: 24 Jun 2013 18:11
by Rémi Denis-Courmont
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.
Re: libvlc_video_take_snapshot
Posted: 10 Nov 2016 11:11
by AlexJung
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.