[FFmpeg-user] Adding an option to dvbsubs.c
JULIAN GARDNER
joolzg at btinternet.com
Sat Mar 12 14:48:55 CET 2016
Ive tried to add a "dvbs_y_offset" into the dvb subtitles encoder and finding that i now have a crash in opt.c when i set this value to anything
added in the variable in the context
typedef struct DVBSubtitleContext {
int object_version;
int dvbs_y_offfset;
} DVBSubtitleContext;
code added
static av_cold int dvbsub_init_encode(AVCodecContext *avctx)
{
DVBSubtitleContext *s = avctx->priv_data;
av_log( avctx, AV_LOG_INFO, "offset now %d\r\n", s->dvbs_y_offfset);
return 0;
}
static av_cold int dvbsub_close_encode(AVCodecContext *avctx)
{
av_log( avctx, AV_LOG_INFO, "Closedown\r\n");
return 0;
}
#define DS AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_ENCODING_PARAM
static const AVOption options[] = {
{"dvbs_y_offfset", "Sets offset for moving subtitles up/down", offsetof(DVBSubtitleContext, dvbs_y_offfset), AV_OPT_TYPE_INT, {.i64 = 0}, -128, 128, DS},
{NULL}
};
static const AVClass dvbsub_class = {
.class_name = "DVB Sub Encoder",
.item_name = av_default_item_name,
.option = options,
.version = LIBAVUTIL_VERSION_INT,
};
AVCodec ff_dvbsub_encoder = {
.name = "dvbsub",
.long_name = NULL_IF_CONFIG_SMALL("DVB subtitles"),
.type = AVMEDIA_TYPE_SUBTITLE,
.id = AV_CODEC_ID_DVB_SUBTITLE,
.priv_data_size = sizeof(DVBSubtitleContext),
.init = dvbsub_init_encode,
.close = dvbsub_close_encode,
.encode_sub = dvbsub_encode,
.priv_class = &dvbsub_class,
};
Now I get a crash in opt.c once ffmpeg closes
comand lineffmpeg -i x.ts -c:v copy -c:a copy -y_offset -32 -s:dvbsub -y -f mpegts a.ts
[dvbsub @ 0xe761b00] Closedown
==26910== Invalid read of size 8
==26910== at 0xF019C2: av_opt_next (opt.c:51)
==26910== by 0xF019C2: av_opt_free (opt.c:1450)
==26910== by 0x44C549: avcodec_close (utils.c:2691)
==26910== by 0x9CF688: avcodec_free_context (options.c:171)
==26910== by 0x499B31: ffmpeg_cleanup (ffmpeg.c:807)
==26910== by 0x481C40: exit_program (cmdutils.c:120)
==26910== by 0x47F8E3: main (ffmpeg.c:4650)
==26910== Address 0x14 is not stack'd, malloc'd or (recently) free'd
==26910==
==26910==
==26910== Process terminating with default action of signal 11 (SIGSEGV)
==26910== Access not within mapped region at address 0x14
==26910== at 0xF019C2: av_opt_next (opt.c:51)
==26910== by 0xF019C2: av_opt_free (opt.c:1450)
==26910== by 0x44C549: avcodec_close (utils.c:2691)
==26910== by 0x9CF688: avcodec_free_context (options.c:171)
==26910== by 0x499B31: ffmpeg_cleanup (ffmpeg.c:807)
==26910== by 0x481C40: exit_program (cmdutils.c:120)
==26910== by 0x47F8E3: main (ffmpeg.c:4650)
==26910== If you believe this happened as a result of a stack
==26910== overflow in your program's main thread (unlikely but
==26910== possible), you can try to increase the size of the
==26910== main thread stack using the --main-stacksize= flag.
==26910== The main thread stack size used in this run was 8388608.
Joolz Joolz
More information about the ffmpeg-user
mailing list