Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdint.h>
- #include <vlc/vlc.h>
- #include <pthread.h>
- FILE * myfile;
- pthread_mutex_t count_mutex;
- void prepareRender (void* p_video_data, uint8_t** pp_pcm_buffer , size_t size)
- {
- printf("\ngot the pre call\n ");
- pthread_mutex_lock(&count_mutex);
- *pp_pcm_buffer = (uint8_t *) malloc(size);
- }
- void handleStream( void* p_video_data, uint8_t* p_pixel_buffer, int width, int height, int pixel_pitch, int size, int64_t pts ){
- printf("\ngot the post call \n");
- int i_line, i_line_size, i_size ;
- if( pixel_pitch > 0 )
- {
- i_line = height;
- i_line_size = width;
- i_size = i_line * i_line_size;
- uint8_t *p_in = p_pixel_buffer;
- uint8_t *p_out;
- int line =0;
- while(line < i_line)
- {
- fwrite (p_in, sizeof(char), i_line_size, myfile);
- p_out += i_line_size;
- p_in += i_line_size;
- line++;
- }
- }
- else
- {
- i_size = size;
- fwrite (p_pixel_buffer, sizeof(char), i_size, myfile);
- }
- free(p_pixel_buffer);
- pthread_mutex_unlock(&count_mutex);
- }
- int main(int argc, char **argv) {
- myfile = fopen ("vlc_ouput.ogg", "w");
- printf("\nhere 0");
- libvlc_instance_t *vlcInstance;
- libvlc_media_player_t *mp;
- libvlc_media_t *media;
- char smem_options[256];
- //sprintf(smem_options, "#transcode{vcodec=theo,vb=800,acodec=vorb,ab=128,channels=2,samplerate=44100}:file{dst=stream-output.ogg}");
- sprintf(smem_options, "#transcode{vcodec=RV32}:smem{video-postrender-callback=%lld,video-prerender-callback=%lld}",
- // We are using transcode because smem only support raw audio and video formats
- (long long int)(intptr_t)(void*)&handleStream, (long long int)(intptr_t)(void*)&prepareRender);
- const char * const vlc_args[] = {
- "-I", "dummy", // Don't use any interface
- "--ignore-config", // Don't use VLC's config
- "--extraintf=logger", // Log anything
- "--verbose=3", // Be much more verbose then normal for debugging purpose
- "--sout", smem_options // Stream to memory
- };
- printf("\nhere 1");
- // We launch VLC
- vlcInstance = libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args);
- printf("\nhere 2");
- media = libvlc_media_new_path(vlcInstance,"sample.mkv");
- if(!media){
- printf("\n no media");
- }else{
- printf("\n yes media");
- }
- printf("\nhere 3");
- mp = libvlc_media_player_new_from_media(media);
- printf("\nhere 4");
- // To be continued.
- libvlc_media_player_play(mp);
- while(true){sleep(120);break;}
- libvlc_media_player_stop(mp);
- libvlc_media_player_release(mp);
- libvlc_release(vlcInstance);
- libvlc_media_release(media);
- fclose(myfile);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment