Overwrite the text of displayed subtitles
Posted: 23 Jul 2024 15:25
hi!
im new to developing to VLC.
currently, im working on a project that as a part of it, I need to be able to overwrite the subtitles that are about to be displayed, both when online streaming and playing an offline file.
after going through the source code i understood that the relevant file will be 'modules\codec\subsdec.c'. and the relevant methods are 'DecodeBlock' and 'ParseText'.
this is how i tried modifying the 'DecodeBlock' method but unfortunately it doesn't work. im unable to access the variable/field that actually holds the text in order to change it.
I'll be happy to hear any suggestions on how to go on with that issue and get the aimed result.
Thanks!
im new to developing to VLC.
currently, im working on a project that as a part of it, I need to be able to overwrite the subtitles that are about to be displayed, both when online streaming and playing an offline file.
after going through the source code i understood that the relevant file will be 'modules\codec\subsdec.c'. and the relevant methods are 'DecodeBlock' and 'ParseText'.
this is how i tried modifying the 'DecodeBlock' method but unfortunately it doesn't work. im unable to access the variable/field that actually holds the text in order to change it.
Code: Select all
static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
{
subpicture_t *p_spu;
if( p_block == NULL ) /* No Drain */
return VLCDEC_SUCCESS;
if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
{
block_Release( p_block );
return VLCDEC_SUCCESS;
}
//original
//p_spu = ParseText( p_dec, p_block );
//block_Release( p_block );
//if( p_spu != NULL )
// decoder_QueueSub( p_dec, p_spu );
//return VLCDEC_SUCCESS;
//edited
// Overwrite subtitle text with "hi"
if (p_spu != NULL)
{
// Assuming p_spu->p_region is the region containing the subtitle text
if (p_spu->p_region != NULL && p_spu->p_region->p_text != NULL)
{
// Free the existing text
free(p_spu->p_region->p_text);
// Allocate new text and set it to "hi"
p_spu->p_region->p_text = strdup("hi");
}
decoder_QueueSub(p_dec, p_spu);
}
block_Release(p_block);
return VLCDEC_SUCCESS;
}
I'll be happy to hear any suggestions on how to go on with that issue and get the aimed result.
Thanks!