using smem - parameters

This forum is about all development around libVLC.
laszloj
New Cone
New Cone
Posts: 9
Joined: 28 Jun 2010 10:04

using smem - parameters

Postby laszloj » 28 Jun 2010 11:09

Hi,

Could someone please provide the right parameters for using smem module in order to render video and audio
into preallocated buffers? The code I am using now to render video with vmem is below. Can anyone provide the right parameters for the smem module? (FYI I use libvlc.dll, that's why I prefer initalizing by the provided arglist.) I searched for many pages and topics here as well, but there is no working example for this. I want to provide the lock/unlock functions for vlc for both video and audio so I can get the rendered data in my buffers. This works with vmem, but need the audio data, too.

thanks for helping

jozsef

Code: Select all

sprintf(clock, "%lld", (long long int)(intptr_t)mylock); sprintf(cunlock, "%lld", (long long int)(intptr_t)myunlock); sprintf(cdata, "%lld", (long long int)(intptr_t)&ctx); sprintf(width, "%i", VIDEOW); sprintf(height, "%i", VIDEOH); sprintf(pitch, "%i", VIDEOW * 4); array<String^>^ args = gcnew array<String^>{ "-I", "dummy", "--ignore-config", "--plugin-path="+pluginpath, "--quiet", "--vout", "vmem", "--vmem-width", gcnew String(width), "--vmem-height", gcnew String(height), "--vmem-pitch", gcnew String(pitch), "--vmem-chroma", "RV32", "--vmem-lock", gcnew String(clock), "--vmem-unlock", gcnew String(cunlock), "--vmem-data", gcnew String(cdata) }; instance = libvlc_new(args->Length, args, p);

laszloj
New Cone
New Cone
Posts: 9
Joined: 28 Jun 2010 10:04

Re: using smem - parameters

Postby laszloj » 29 Jun 2010 16:58

Hi all,

Seems no one answers, so I answer myself. Using smem to output into memory buffers needs the following stuff:

1. Callback functions:

Buffers and variables:

bool vData; // can be used for single state signals
bool aData;
uint8_t* videoBuffer; // have to be allocated before use !!
uint8_t* audioBuffer;

Code: Select all

void vPreCallback( void* p_video_data, uint8_t** pp_pixel_buffer , int size ) { // called before video rendered } void vPostCallback( void* p_video_data, uint8_t* p_pixel_buffer, int width, int height, int pixel_pitch, int size, mtime_t pts ) { // called after video rendered } void aPreCallback( void* p_audio_data, uint8_t** pp_pcm_buffer , unsigned int size ) { // called before audio rendered } void aPostCallback( void* p_audio_data, uint8_t* p_pcm_buffer, unsigned int channels, unsigned int rate, unsigned int nb_samples, unsigned int bits_per_sample, unsigned int size, mtime_t pts ) { // called after audio rendered }
2. Initializing parameters (using vlc 1.1.0)

Code: Select all

const char * const vlc_args[] = { "--plugin-path=c:\\program files\\videolan\\vlc\\plugins", "-I", "dummy", /* Don't use any interface */ "--ignore-config", /* Don't use VLC's config */ "--quiet", "--sout=#transcode{vcodec=RV24,acodec=s16l}:smem", }; /* init vlc modules, should be done only once */ inst = libvlc_new (sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args); /* Create a new item */ m = libvlc_media_new_path (inst, "path_to_movie_file"); libvlc_media_add_option(m,":noaudio"); libvlc_media_add_option(m,":no-video-title-show"); char s[512]; sprintf(s,":sout-smem-video-prerender-callback=%lld",(long long int)(intptr_t)vPreCallback); libvlc_media_add_option(m,s); sprintf(s,":sout-smem-video-postrender-callback=%lld",(long long int)(intptr_t)vPostCallback); libvlc_media_add_option(m,s); sprintf(s,":sout-smem-video-data=%lld",(long long int)(intptr_t)&vData ); libvlc_media_add_option(m,s); sprintf(s,":sout-smem-audio-prerender-callback=%lld",(long long int)(intptr_t)aPreCallback); libvlc_media_add_option(m,s); sprintf(s,":sout-smem-audio-postrender-callback=%lld",(long long int)(intptr_t)aPostCallback); libvlc_media_add_option(m,s); sprintf(s,":sout-smem-audio-data=%lld",(long long int)(intptr_t)&aData ); libvlc_media_add_option(m,s); sprintf(s,":sout-smem-time-sync=1"); libvlc_media_add_option(m,s); /* 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); /* play the media_player */ libvlc_media_player_play (mp);
The code above works fine. There is only one issue with it: if I change vcodec parameter from RV24 to RV32, video callbacks are not called for some reason. Can anyone tell, why? RV16 and RV24 works well.

jozsef

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

Re: using smem - parameters

Postby Rémi Denis-Courmont » 30 Jun 2010 12:47

Check the LibVLC logs.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

laszloj
New Cone
New Cone
Posts: 9
Joined: 28 Jun 2010 10:04

Re: using smem - parameters

Postby laszloj » 30 Jun 2010 13:11

Hi,

Checked, but did not find any bug. It says it will use direct rendering, I do not know what that means exactly. Nevertheless, audio callbacks are called, but video ones are not when using RV32. See below. Any idea?

jozsef

[0bd3bca4] main input debug: Stream buffering done (325 ms in 11 ms)
[0bd40c4c] main generic debug: using decoder module "mpeg_audio"
[0bd40c4c] main generic debug: TIMER module_need() : 20.000 ms - Total 20.000 ms
/ 1 intvls (Avg 20.000 ms)
[0bd38814] main encoder debug: looking for encoder module: 12 candidates
[0bd38814] araw encoder debug: samplerate:48000Hz channels:2 bits/sample:16
[0bd38814] main encoder debug: using encoder module "araw"
[0bd38814] main encoder debug: TIMER module_need() : 7.000 ms - Total 7.000 ms /
1 intvls (Avg 7.000 ms)
[0bd2bfdc] stream_out_transcode stream out debug: Looking for filter (mpga->s16l
, channels 2->2, rate 48000->48000)
[0bd495bc] main filter debug: looking for audio filter module: 14 candidates
[0bd495bc] mpgatofixed32 filter debug: mpga->f32l, bits per sample: 0
[0bd495bc] main filter debug: using audio filter module "mpgatofixed32"
[0bd495bc] main filter debug: TIMER module_need() : 4.000 ms - Total 4.000 ms /
1 intvls (Avg 4.000 ms)
[0bd2bfdc] main stream out debug: Filter 'mpgatofixed32' (0bd495bc) appended to
chain
[0bd49994] main filter debug: looking for audio filter module: 14 candidates
[0bd49994] audio_format filter debug: f32l->s16l, bits per sample: 32->16
[0bd49994] main filter debug: using audio filter module "audio_format"
[0bd49994] main filter debug: TIMER module_need() : 23.000 ms - Total 23.000 ms
/ 1 intvls (Avg 23.000 ms)
[0bd2bfdc] main stream out debug: Filter 'audio_format' (0bd49994) appended to c
hain
[0bd2bfdc] stream_out_transcode stream out debug: Got complete audio filter chai
n
[0bd2bfdc] stream_out_transcode stream out debug: creating video transcoding fro
m fcc=`mp4v' to fcc=`RV32'
[0bd53ab4] main generic debug: looking for decoder module: 34 candidates
[0bd53ab4] avcodec generic debug: libavcodec initialized (interface 0x344d00)
[0bd53ab4] avcodec generic debug: trying to use direct rendering
[0bd53ab4] avcodec generic debug: ffmpeg codec (MPEG-4 Video) started
[0bd53ab4] main generic debug: using decoder module "avcodec"
[0bd53ab4] main generic debug: TIMER module_need() : 25.000 ms - Total 25.000 ms
/ 1 intvls (Avg 25.000 ms)
[0bd529bc] main encoder debug: looking for encoder module: 12 candidates
[0bd529bc] avcodec encoder debug: libavcodec already initialized
[0bd529bc] avcodec encoder debug: found encoder Raw video
[0bd529bc] main encoder debug: using encoder module "avcodec"
[0bd529bc] main encoder debug: TIMER module_need() : 5.000 ms - Total 5.000 ms /
1 intvls (Avg 5.000 ms)
[0bd529bc] main encoder debug: removing module "avcodec"
[0bd3bca4] main input debug: Decoder buffering done in 84 ms
[0bd53ab4] avcodec generic debug: using direct rendering
[0bd2bfdc] stream_out_transcode stream out debug: late picture skipped (43000)
[0bd40c4c] mpeg_audio generic debug: MPGA channels:2 samplerate:48000 bitrate:12
8
[0bd2bfdc] stream_out_transcode stream out debug: decoder aspect is 1.333333:1
[0bd2bfdc] stream_out_transcode stream out debug: source pixel aspect is 1.00000
0:1
[0bd2bfdc] stream_out_transcode stream out debug: scaled pixel aspect is 1.00000
0:1
[0bd2bfdc] stream_out_transcode stream out debug: source 640x480, destination 64
0x480
[0bd2bfdc] stream_out_transcode stream out debug: encoder aspect is 640:480
[0dc0b80c] main filter debug: looking for video filter2 module: 18 candidates
[0dc0b80c] swscale filter debug: 640x480 chroma: I420 -> 640x480 chroma: RV32 wi
th scaling using Bicubic (good quality)
[0dc0b80c] main filter debug: using video filter2 module "swscale"
[0dc0b80c] main filter debug: TIMER module_need() : 8.000 ms - Total 8.000 ms /
1 intvls (Avg 8.000 ms)
[0bd2bfdc] main stream out debug: Filter 'Swscale' (0dc0b80c) appended to chain
[0bd2bfdc] stream_out_transcode stream out debug: destination (after video filte
rs) 640x480
[0bd529bc] main encoder debug: looking for encoder module: 12 candidates
[0bd529bc] avcodec encoder debug: libavcodec already initialized
[0bd529bc] avcodec encoder debug: found encoder Raw video
[0bd529bc] main encoder debug: using encoder module "avcodec"
[0bd529bc] main encoder debug: TIMER module_need() : 2.000 ms - Total 2.000 ms /
1 intvls (Avg 2.000 ms)

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

Re: using smem - parameters

Postby Rémi Denis-Courmont » 30 Jun 2010 14:55

Then I don't know.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

ian168
New Cone
New Cone
Posts: 6
Joined: 12 Nov 2010 13:02

Re: using smem - parameters

Postby ian168 » 12 Nov 2010 14:23

i used vlc library to build a project by MFC that can play rtsp stream and open a file,
but my purpose is how to get the video raw data(every frame).
i implemented the method you told,so i had some questions as below:
1.how can i know the callback function working?i put the breakpoint on callback function but it's not work.
2.how to get the log message?
3.could you provide your source code in detail???

thanks a lot!!!


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 11 guests