vlc-3.0.8添加录像接口及rtsp流断流后内存暴涨问题解决
转自:https://blog.csdn.net/z373248439/article/details/113885300?spm=1001.2014.3001.5502
一、添加录像接口
1、vlc-3.0.8/include/vlc/libvlc_media_player.h 中添加
LIBVLC_API int libvlc_media_player_recorder_start(libvlc_media_player_t *p_mi, const char* pFilePath, const char* pFileName); LIBVLC_API int libvlc_media_player_recorder_stop(libvlc_media_player_t *p_mi);
2、vlc-3.0.8/lib/media_player.c 中添加,也可在vlc-3.0.8/lib/video.c 中添加
int libvlc_media_player_recorder_start( libvlc_media_player_t *p_mi, const char* pFilePath, const char* pFileName ) { input_thread_t *p_input = libvlc_get_input_thread( p_mi ); if(p_input == NULL) return -1; var_CreateGetString(p_input, "input-record-path"); var_SetString( p_input, "input-record-path", pFilePath ); var_CreateGetString(p_input, "record-video-name"); var_SetString( p_input, "record-video-name", pFileName ); var_SetBool( p_input, "record", true); vlc_object_release(p_input); return 0; } int libvlc_media_player_recorder_stop( libvlc_media_player_t *p_mi ) { input_thread_t *p_input_thread; p_input_thread = libvlc_get_input_thread( p_mi ); if( !p_input_thread ) return -1; var_SetBool( p_input_thread, "record", false ); vlc_object_release( p_input_thread ); return 0; }
3、修改vlc-3.0.8/modules/stream_filter/record.c
1 把psz_file = input_CreateFilename( s->p_input, psz_path, INPUT_RECORD_PREFIX, psz_extension ); 2 替换为 3 char *psz_recordVideoFileName = var_CreateGetNonEmptyString( s->p_input, "record-video-name" ); 4 psz_file = input_CreateFilename( s->p_input, psz_path, psz_recordVideoFileName, psz_extension );
4、修改vlc-3.0.8/src/input/es_out.c中EsOutSetRecord()函数
1 把char *psz_file = input_CreateFilename( p_input, psz_path, INPUT_RECORD_PREFIX, NULL ); 2 替换为 3 char *psz_recordVideoFileName = var_CreateGetNonEmptyString( p_input, "record-video-name" ); 4 char *psz_file = input_CreateFilename( p_input, psz_path, psz_recordVideoFileName, NULL );
5、修改vlc-3.0.8/lib/libvlc.sym文件,添加libvlc_media_player_recorder_start 和
1 libvlc_media_player_recorder_stop 建议放在libvlc_media_list_player_stop后面: 2 libvlc_media_list_player_stop 3 libvlc_media_player_recorder_start 4 libvlc_media_player_recorder_stop
二、解决rtsp流断流时内存暴涨问题。
修改vlc-3.0.8/modules/access/live555.cpp,TimeoutPrevention 函数直接返回,即函数内第一行 return;
1 static void TimeoutPrevention( void *p_data ) 2 { 3 return; 4 demux_t *p_demux = (demux_t *) p_data; 5 demux_sys_t *p_sys = p_demux->p_sys; 6 char *bye = NULL; 7 ... 8 }
参考: