[FFmpeg-devel] Facing Seg Fault
Abhinav Singh
singhabhinav0796 at gmail.com
Sun Mar 28 11:20:13 EEST 2021
Hello everyone, I m trying to convert my audio from planner 32bit(
AV_SAMPLE_FMT_S32P) to AV_SAMPLE_FMT_S16 . I m doing this so that I can
play sound using libsdl, this is code for it
```
SwrContext* context = swr_alloc_set_opts(
nullptr,
dst_channel_layout,
AV_SAMPLE_FMT_S16,
avctx->sample_rate,
avctx->channel_layout, //dest
avctx->sample_fmt, //dest
avctx->sample_rate, //dest
0,
NULL
);
swr_init(context);int dst_nb_samples =
av_rescale_rnd(swr_get_delay(context,avctx->sample_rate)+avctx->frame_size,avctx->sample_rate,avctx->sample_rate,AVRounding(1));uint8_t**
dst_data = NULL;
int dst_linesize = 0;
int ret = av_samples_alloc_array_and_samples(&dst_data,
&dst_linesize, avctx->channels,dst_nb_samples,avctx->sample_fmt,0);
.......
AVFrame* decodedAudioFrame;
swr_convert(context,dst_data,dst_nb_samples,(const
uint8_t**)decodedAudioFrame->data[0],decodedAudioFrame->nb_samples);
```
and this the frame structure
```
{data = {0x5555555f04c0
"#a=5\tFl5h1K\264\322h\t\266\201\363\220\266[o\352\266\001\324+\267́n\267\037\203\235\267\320\tŷX\370",
<incomplete sequence \360>,
0x555555606740
"\r[\366\263f\244õ\264X\203\266q\231\354\266a~A\267\374K\222\267\022\277Ƿ(\215",
0x55555560a800
"\022#\030\265j\v\f\266\213\234\202\266\230п\266\256\025\372\266\243\335\026\267\332\314/\267\367;F\267\337\067J\267\312\063\070\267\243\277%\267\066a
\267\060j(\267\214\262?\267\061$Z\267\237\347k\267땂\267\vf\225\267\361w\242\267\270\023\247\267k\035\245\267\333n\227\267\365\021\207\267\245ꂷzd\202\267`\266u\267ĩX\267I\024\n\267*U\220\065\353\361C7\357\b\247\067\372!\334\067\276\217\006\070}\025\037\070\272\353:8\377)[8{\316y8\322m\205\070\266\033\203\070\231\300t8\243\232e8\003",
0x55555560c840 "",
0x55555560e880
"\224\062m\264\224P\023\265\305\305q\265=\366\246\265
4\266\265\341\345ǵ!\375\002\266]14\266o\350\177\266\f\255\257\266\276\aŶ䰡\266\177f\023\266\021\226\005\066Α\001\067\240n`7QF\215\067挖7\210\234\224\067a\365\213\067\371\262\177\067(\304a7\377\333:7\276(\037\067\276\262\026\067\350y\313\066}\372ٵV\263+\267\360@\210\267қ\251\267\r",
0x5555556108c0
";\232\061\064\"\305\064\065Po\245\065\212\217\360\065\372\251\001\066\223T\275\065\060\372\066\065\361\354\001\265\030\340\061\266\022J\244\266\070\303ضв\b\267\333O\037\267&\333\017\267
\273\277\266b\002C\266\223
\375\264Z\201\377\065\003\353Y6S^H6*\203\t6w\260\230\065ߣ\004\063\031k\262\265\366\217T\266\274cѶ\377;\035\267\351\306\034\267\262\234ɶ\364\224\063\266\365\357\246\062d\307t6\211\246\334\066m\320\325\066)\207_6\023-/\266\370\r@\267\347Q\247\267D\351ӷ\211\207\340\267\276\206\274\267\340\211F\267\024\177\212\065V\034^7\354?\321\067N\314\016\070\245H\037\070!6\036\070J\375\022\070\036\242\004\070"...,
0x0, 0x0}, linesize = {8192, 0, 0, 0, 0, 0, 0, 0}, extended_data =
0x555555631640, width = 0, height = 0, nb_samples = 1024, format = 8,
key_frame = 1,
pict_type = AV_PICTURE_TYPE_NONE, sample_aspect_ratio = {num = 0,
den = 1}, pts = 0, pkt_pts = 0, pkt_dts = 0, coded_picture_number = 0,
display_picture_number = 0, quality = 0, opaque = 0x0,
error = {0, 0, 0, 0, 0, 0, 0, 0}, repeat_pict = 0, interlaced_frame
= 0, top_field_first = 0, palette_has_changed = 0, reordered_opaque =
-9223372036854775808, sample_rate = 48000,
channel_layout = 63, buf = {0x5555555b1c80, 0x5555556a23c0,
0x5555555f9a40, 0x5555555b6500, 0x5555555f0180, 0x5555555b62c0, 0x0,
0x0}, extended_buf = 0x0, nb_extended_buf = 0, side_data = 0x0,
nb_side_data = 0, flags = 0, color_range = AVCOL_RANGE_UNSPECIFIED,
color_primaries = AVCOL_PRI_RESERVED0, color_trc =
AVCOL_TRC_RESERVED0, colorspace = AVCOL_SPC_RGB,
chroma_location = AVCHROMA_LOC_UNSPECIFIED, best_effort_timestamp =
0, pkt_pos = 48, pkt_duration = 1024, metadata = 0x0,
decode_error_flags = 0, channels = 6, pkt_size = 967, qscale_table =
0x0,
qstride = 0, qscale_type = 0, qp_table_buf = 0x0, hw_frames_ctx =
0x0, opaque_ref = 0x0, crop_top = 0, crop_bottom = 0, crop_left = 0,
crop_right = 0, private_ref = 0x0}
```
I m facing a seg fault at swr_convert function, I dont know why? Any help
is appreciated. I have even asked this in stackoveflow, anyone can answer
there to if they want.
Ubuntu - 20.04
ffmpeg version 4.2.4
Thank You,
Abhinav Singh.
More information about the ffmpeg-devel
mailing list