<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Hi,<div><br></div><div>I don't know about AMR codec but bitrate definitely impacts on final quality.</div><div>Try to increase bitrate value: I had same poor quality problems with MPEG4 encoding until I set the bitrate to width * height * 4.</div><div>Keep in mind that poor quality might comes from a wide bunch of parameters used to initialize the codec.</div><div>As for example, this is how I initialize an MPEG4 codec (A]), for clarity, in_ctx is initialized via the code in (B])</div><div><br></div><div><div>Concerning the delay issue: I also faced such a problem. I solved it using av_packet_rescale_ts() which relies on time_base, instead of setting timestamps myself manually.</div><div><br></div><div>I hope this comments will help put you on the road to success :-)</div><div><br></div><div>Good luck.</div></div><div><br></div><div>A]</div><div><div>    //codec found, now we param it</div><div>    o_codec_ctx->codec_id=AV_CODEC_ID_MPEG4;</div><div>    o_codec_ctx->bit_rate=in_ctx->picture_width * in_ctx->picture_height * 4;</div><div>    o_codec_ctx->width=in_ctx->format_ctx->streams[in_ctx->video_stream_idx]->codec->width;</div><div>    o_codec_ctx->height=in_ctx->format_ctx->streams[in_ctx->video_stream_idx]->codec->height;</div><div>    o_codec_ctx->time_base = in_ctx->format_ctx->streams[in_ctx->video_stream_idx]->codec->time_base;</div><div>    o_codec_ctx->ticks_per_frame = in_ctx->format_ctx->streams[in_ctx->video_stream_idx]->codec->ticks_per_frame;</div><div>    o_codec_ctx->sample_aspect_ratio = in_ctx->format_ctx->streams[in_ctx->video_stream_idx]->codec->sample_aspect_ratio;</div><div>    o_codec_ctx->gop_size=in_ctx->format_ctx->streams[in_ctx->video_stream_idx]->codec->gop_size;</div><div>    o_codec_ctx->pix_fmt=AV_PIX_FMT_YUV420P;</div></div><div><br></div><div><br></div><div><br></div><div>B]</div><div><div> // register all formats and codecs</div><div>    av_register_all();</div><div>    avcodec_register_all();</div><div><br></div><div>    // open input file, and allocate format context</div><div>    if (avformat_open_input(&in_fmt_ctx, filename, NULL, NULL) < 0)</div><div>    {</div><div>        fprintf(stderr, "Could not open source file %s\n", filename);</div><div>        exit(1);</div><div>    }</div><div><br></div><div>    // retrieve stream information </div><div>    if (avformat_find_stream_info(in_fmt_ctx, NULL) < 0)</div><div>    {</div><div>        fprintf(stderr, "Could not find stream information\n");</div><div>        exit(1);</div><div>    }</div><div><br></div><div>    if (open_codec_context(&video_stream_idx, in_fmt_ctx, AVMEDIA_TYPE_VIDEO, filename) >= 0)</div><div>    {</div><div>        video_stream = in_fmt_ctx->streams[video_stream_idx];</div><div>        video_dec_ctx = video_stream->codec;</div><div>    }</div><div><br></div><div>    if (open_codec_context(&audio_stream_idx, in_fmt_ctx, AVMEDIA_TYPE_AUDIO, filename) >= 0) {</div><div>        audio_stream = in_fmt_ctx->streams[audio_stream_idx];</div><div>        audio_dec_ctx = audio_stream->codec;</div><div>    }</div><div><br></div><div>    if (!video_stream) {</div><div>        fprintf(stderr, "Could not find video stream in the input, aborting\n");</div><div>        avformat_close_input(&in_fmt_ctx);</div><div>        exit(0);</div><div>    }</div><div><br></div><div>    in_video_ctx->format_ctx=in_fmt_ctx;</div><div>    in_video_ctx->filename=filename;</div><div>    in_video_ctx->codec_name=(char *) in_fmt_ctx->streams[video_stream_idx]->codec->codec->long_name;</div><div>    in_video_ctx->video_stream_idx=video_stream_idx;</div><div>    in_video_ctx->audio_stream_idx=audio_stream_idx;</div><div>    in_video_ctx->picture_width=in_fmt_ctx->streams[video_stream_idx]->codec->width;</div><div>    in_video_ctx->picture_height=in_fmt_ctx->streams[video_stream_idx]->codec->height;</div><div>    in_video_ctx->nb_streams=in_fmt_ctx->nb_streams;</div></div><div><br></div><div><br></div><div><br></div><div> </div><div><div><div>Le 1 juil. 2015 à 10:40, adev dev <<a href="mailto:androiddevmar11@gmail.com">androiddevmar11@gmail.com</a>> a écrit :</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr"><span style="font-size:12.8000001907349px">I am compressing movies from bitmaps and audio files. With AAC files it is working correctly. But when I have AMR_WB files sound is corrupted. I can recognise correct words in video file but it is delayed and with very bad quality.</span><div><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8000001907349px">My AMR files are recorded with parameters:</span><div><div><span style="font-size:12.8000001907349px">- sampling rate: 16000,</span></div><div><span style="font-size:12.8000001907349px">- bitrate: 23000.</span></div><div><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8000001907349px">I am setting this parameters in audio stream which is added to video. Sample format is set to </span>AV_SAMPLE_FMT_FLT. When using other formats app crashes with "Unsupported sample format". </div><div><br></div><div>What needs to be done to correctly add AMR stream to video file? Do I have to reencode it to AAC and add as AAC audio stream?? Thank you for all hints.</div></div></div></div>
_______________________________________________<br>Libav-user mailing list<br><a href="mailto:Libav-user@ffmpeg.org">Libav-user@ffmpeg.org</a><br>http://ffmpeg.org/mailman/listinfo/libav-user<br></blockquote></div><br></div></body></html>