📄 transcode.c
字号:
char *psz_aenc; sout_cfg_t *p_audio_cfg; int i_sample_rate; int i_channels; int i_abitrate; /* Video */ vlc_fourcc_t i_vcodec; /* codec video (0 if not transcode) */ char *psz_venc; sout_cfg_t *p_video_cfg; int i_vbitrate; double f_scale; double f_fps; unsigned int i_width, i_maxwidth; unsigned int i_height, i_maxheight; vlc_bool_t b_deinterlace; char *psz_deinterlace; sout_cfg_t *p_deinterlace_cfg; int i_threads; vlc_bool_t b_high_priority; vlc_bool_t b_hurry_up; char *psz_vfilters[10]; sout_cfg_t *p_vfilters_cfg[10]; int i_vfilters; int i_crop_top; int i_crop_bottom; int i_crop_right; int i_crop_left; int i_padd_top; int i_padd_bottom; int i_padd_right; int i_padd_left; int i_canvas_width; int i_canvas_height; int i_canvas_aspect; /* Video, calculated */ int i_src_x_offset; int i_src_y_offset; int i_crop_width; int i_crop_height; int i_dst_x_offset; int i_dst_y_offset; int i_nopadd_width; int i_nopadd_height; /* SPU */ vlc_fourcc_t i_scodec; /* codec spu (0 if not transcode) */ char *psz_senc; vlc_bool_t b_soverlay; sout_cfg_t *p_spu_cfg; spu_t *p_spu; /* OSD Menu */ sout_stream_id_t *id_osd; /* extension for streaming OSD menus */ vlc_fourcc_t i_osdcodec; /* codec osd menu (0 if not transcode) */ char *psz_osdenc; sout_cfg_t *p_osd_cfg; vlc_bool_t b_es_osd; /* VLC_TRUE when osd es is registered */ vlc_bool_t b_sout_osd; /* Sync */ vlc_bool_t b_master_sync; mtime_t i_master_drift;};struct decoder_owner_sys_t{ picture_t *pp_pics[PICTURE_RING_SIZE]; sout_stream_sys_t *p_sys;};struct filter_owner_sys_t{ picture_t *pp_pics[PICTURE_RING_SIZE]; sout_stream_sys_t *p_sys;};/***************************************************************************** * Open: *****************************************************************************/static int Open( vlc_object_t *p_this ){ sout_stream_t *p_stream = (sout_stream_t*)p_this; sout_stream_sys_t *p_sys; vlc_value_t val; p_sys = vlc_object_create( p_this, sizeof( sout_stream_sys_t ) ); p_sys->p_out = sout_StreamNew( p_stream->p_sout, p_stream->psz_next ); if( !p_sys->p_out ) { msg_Err( p_stream, "cannot create chain" ); vlc_object_destroy( p_sys ); return VLC_EGENERIC; } p_sys->i_master_drift = 0; sout_CfgParse( p_stream, SOUT_CFG_PREFIX, ppsz_sout_options, p_stream->p_cfg ); /* Audio transcoding parameters */ var_Get( p_stream, SOUT_CFG_PREFIX "aenc", &val ); p_sys->psz_aenc = NULL; p_sys->p_audio_cfg = NULL; if( val.psz_string && *val.psz_string ) { char *psz_next; psz_next = sout_CfgCreate( &p_sys->psz_aenc, &p_sys->p_audio_cfg, val.psz_string ); if( psz_next ) free( psz_next ); } if( val.psz_string ) free( val.psz_string ); var_Get( p_stream, SOUT_CFG_PREFIX "acodec", &val ); p_sys->i_acodec = 0; if( val.psz_string && *val.psz_string ) { char fcc[4] = " "; memcpy( fcc, val.psz_string, __MIN( strlen( val.psz_string ), 4 ) ); p_sys->i_acodec = VLC_FOURCC( fcc[0], fcc[1], fcc[2], fcc[3] ); } if( val.psz_string ) free( val.psz_string ); var_Get( p_stream, SOUT_CFG_PREFIX "ab", &val ); p_sys->i_abitrate = val.i_int; if( p_sys->i_abitrate < 4000 ) p_sys->i_abitrate *= 1000; var_Get( p_stream, SOUT_CFG_PREFIX "samplerate", &val ); p_sys->i_sample_rate = val.i_int; var_Get( p_stream, SOUT_CFG_PREFIX "channels", &val ); p_sys->i_channels = val.i_int; if( p_sys->i_acodec ) { if( p_sys->i_acodec == VLC_FOURCC('m','p','3',0) && p_sys->i_channels > 2 ) { msg_Warn( p_stream, "%d channels invalid for mp3, forcing to 2", p_sys->i_channels ); p_sys->i_channels = 2; } msg_Dbg( p_stream, "codec audio=%4.4s %dHz %d channels %dKb/s", (char *)&p_sys->i_acodec, p_sys->i_sample_rate, p_sys->i_channels, p_sys->i_abitrate / 1000 ); } /* Video transcoding parameters */ var_Get( p_stream, SOUT_CFG_PREFIX "venc", &val ); p_sys->psz_venc = NULL; p_sys->p_video_cfg = NULL; if( val.psz_string && *val.psz_string ) { char *psz_next; psz_next = sout_CfgCreate( &p_sys->psz_venc, &p_sys->p_video_cfg, val.psz_string ); if( psz_next ) free( psz_next ); } if( val.psz_string ) free( val.psz_string ); var_Get( p_stream, SOUT_CFG_PREFIX "vcodec", &val ); p_sys->i_vcodec = 0; if( val.psz_string && *val.psz_string ) { char fcc[4] = " "; memcpy( fcc, val.psz_string, __MIN( strlen( val.psz_string ), 4 ) ); p_sys->i_vcodec = VLC_FOURCC( fcc[0], fcc[1], fcc[2], fcc[3] ); } if( val.psz_string ) free( val.psz_string ); var_Get( p_stream, SOUT_CFG_PREFIX "vb", &val ); p_sys->i_vbitrate = val.i_int; if( p_sys->i_vbitrate < 16000 ) p_sys->i_vbitrate *= 1000; var_Get( p_stream, SOUT_CFG_PREFIX "scale", &val ); p_sys->f_scale = val.f_float; var_Get( p_stream, SOUT_CFG_PREFIX "fps", &val ); p_sys->f_fps = val.f_float; var_Get( p_stream, SOUT_CFG_PREFIX "hurry-up", &val ); p_sys->b_hurry_up = val.b_bool; var_Get( p_stream, SOUT_CFG_PREFIX "width", &val ); p_sys->i_width = val.i_int; var_Get( p_stream, SOUT_CFG_PREFIX "height", &val ); p_sys->i_height = val.i_int; var_Get( p_stream, SOUT_CFG_PREFIX "maxwidth", &val ); p_sys->i_maxwidth = val.i_int; var_Get( p_stream, SOUT_CFG_PREFIX "maxheight", &val ); p_sys->i_maxheight = val.i_int; var_Get( p_stream, SOUT_CFG_PREFIX "vfilter", &val ); p_sys->i_vfilters = 0; if( val.psz_string && *val.psz_string ) { char *psz_parser = val.psz_string; while( psz_parser != NULL && *psz_parser != '\0' ) { psz_parser = sout_CfgCreate( &p_sys->psz_vfilters[p_sys->i_vfilters], &p_sys->p_vfilters_cfg[p_sys->i_vfilters], psz_parser ); p_sys->i_vfilters++; if( psz_parser != NULL && *psz_parser != '\0' ) psz_parser++; } } if( val.psz_string ) free( val.psz_string ); p_sys->psz_vfilters[p_sys->i_vfilters] = NULL; p_sys->p_vfilters_cfg[p_sys->i_vfilters] = NULL; var_Get( p_stream, SOUT_CFG_PREFIX "deinterlace", &val ); p_sys->b_deinterlace = val.b_bool; var_Get( p_stream, SOUT_CFG_PREFIX "deinterlace-module", &val ); p_sys->psz_deinterlace = NULL; p_sys->p_deinterlace_cfg = NULL; if( val.psz_string && *val.psz_string ) { char *psz_next; psz_next = sout_CfgCreate( &p_sys->psz_deinterlace, &p_sys->p_deinterlace_cfg, val.psz_string ); if( psz_next ) free( psz_next ); } if( val.psz_string ) free( val.psz_string ); var_Get( p_stream, SOUT_CFG_PREFIX "croptop", &val ); p_sys->i_crop_top = val.i_int; var_Get( p_stream, SOUT_CFG_PREFIX "cropbottom", &val ); p_sys->i_crop_bottom = val.i_int; var_Get( p_stream, SOUT_CFG_PREFIX "cropleft", &val ); p_sys->i_crop_left = val.i_int; var_Get( p_stream, SOUT_CFG_PREFIX "cropright", &val ); p_sys->i_crop_right = val.i_int; var_Get( p_stream, SOUT_CFG_PREFIX "paddtop", &val ); p_sys->i_padd_top = val.i_int; var_Get( p_stream, SOUT_CFG_PREFIX "paddbottom", &val ); p_sys->i_padd_bottom = val.i_int; var_Get( p_stream, SOUT_CFG_PREFIX "paddleft", &val ); p_sys->i_padd_left = val.i_int; var_Get( p_stream, SOUT_CFG_PREFIX "paddright", &val ); p_sys->i_padd_right = val.i_int; var_Get( p_stream, SOUT_CFG_PREFIX "canvas-width", &val ); p_sys->i_canvas_width = val.i_int; var_Get( p_stream, SOUT_CFG_PREFIX "canvas-height", &val ); p_sys->i_canvas_height = val.i_int; var_Get( p_stream, SOUT_CFG_PREFIX "canvas-aspect", &val ); p_sys->i_canvas_aspect = 0; if( val.psz_string && *val.psz_string ) { char *psz_parser = strchr( val.psz_string, ':' ); if( psz_parser ) { *psz_parser++ = '\0'; p_sys->i_canvas_aspect = atoi( val.psz_string ) * VOUT_ASPECT_FACTOR / atoi( psz_parser ); } else msg_Warn( p_stream, "bad aspect ratio %s", val.psz_string ); } if( val.psz_string ) free( val.psz_string ); var_Get( p_stream, SOUT_CFG_PREFIX "threads", &val ); p_sys->i_threads = val.i_int; var_Get( p_stream, SOUT_CFG_PREFIX "high-priority", &val ); p_sys->b_high_priority = val.b_bool; if( p_sys->i_vcodec ) { msg_Dbg( p_stream, "codec video=%4.4s %dx%d scaling: %f %dkb/s", (char *)&p_sys->i_vcodec, p_sys->i_width, p_sys->i_height, p_sys->f_scale, p_sys->i_vbitrate / 1000 ); } /* Subpictures transcoding parameters */ p_sys->p_spu = NULL; p_sys->psz_senc = NULL; p_sys->p_spu_cfg = NULL; p_sys->i_scodec = 0; var_Get( p_stream, SOUT_CFG_PREFIX "senc", &val ); if( val.psz_string && *val.psz_string ) { char *psz_next; psz_next = sout_CfgCreate( &p_sys->psz_senc, &p_sys->p_spu_cfg, val.psz_string ); if( psz_next ) free( psz_next ); } if( val.psz_string ) free( val.psz_string ); var_Get( p_stream, SOUT_CFG_PREFIX "scodec", &val ); if( val.psz_string && *val.psz_string ) { char fcc[4] = " "; memcpy( fcc, val.psz_string, __MIN( strlen( val.psz_string ), 4 ) ); p_sys->i_scodec = VLC_FOURCC( fcc[0], fcc[1], fcc[2], fcc[3] ); } if( val.psz_string ) free( val.psz_string ); if( p_sys->i_scodec ) { msg_Dbg( p_stream, "codec spu=%4.4s", (char *)&p_sys->i_scodec ); } var_Get( p_stream, SOUT_CFG_PREFIX "soverlay", &val ); p_sys->b_soverlay = val.b_bool; var_Get( p_stream, SOUT_CFG_PREFIX "sfilter", &val ); if( val.psz_string && *val.psz_string ) { p_sys->p_spu = spu_Create( p_stream ); var_Create( p_sys->p_spu, "sub-filter", VLC_VAR_STRING ); var_Set( p_sys->p_spu, "sub-filter", val ); spu_Init( p_sys->p_spu ); } if( val.psz_string ) free( val.psz_string ); /* OSD menu transcoding parameters */ p_sys->psz_osdenc = NULL; p_sys->p_osd_cfg = NULL; p_sys->i_osdcodec = 0; p_sys->b_es_osd = VLC_FALSE; var_Get( p_stream, SOUT_CFG_PREFIX "osd", &val ); p_sys->b_sout_osd = val.b_bool; if( p_sys->b_sout_osd ) { vlc_value_t osd_val; char *psz_next; psz_next = sout_CfgCreate( &p_sys->psz_osdenc, &p_sys->p_osd_cfg, strdup( "dvbsub") ); if( psz_next ) free( psz_next ); p_sys->i_osdcodec = VLC_FOURCC('Y','U','V','P' ); msg_Dbg( p_stream, "codec osd=%4.4s", (char *)&p_sys->i_osdcodec ); if( !p_sys->p_spu ) { osd_val.psz_string = strdup("osdmenu"); p_sys->p_spu = spu_Create( p_stream ); var_Create( p_sys->p_spu, "sub-filter", VLC_VAR_STRING ); var_Set( p_sys->p_spu, "sub-filter", osd_val ); spu_Init( p_sys->p_spu ); if( osd_val.psz_string ) free( osd_val.psz_string ); } else { osd_val.psz_string = strdup("osdmenu"); var_Set( p_sys->p_spu, "sub-filter", osd_val ); if( osd_val.psz_string ) free( osd_val.psz_string );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -