Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- while (1) {
- if ((ret = av_read_frame(fmt_ctx, &packet)) < 0)
- break;
- if ( (packet.stream_index == audio_stream_index) ) {
- ret = avcodec_decode_audio4(aud_ctx, aud_frame, &got_frame, &packet);
- if (ret < 0) {
- audio_errors++;
- if (audio_errors>99) {
- fprintf(stderr, "CRITICAL: INPUT: Aborting as >99 Errors decoding audio! : %s\n",av_err2str(ret));
- break;
- } else {
- fprintf(stderr, "INPUT: Error #%d decoding audio! : %s\n",audio_errors,av_err2str(ret));
- }
- }
- if ( (ret>0) && (got_frame) )
- {
- if (!swr)
- {
- init_resampler(aud_ctx,sinfo->audContext->codec,&swr);
- init_fifo(sinfo->audContext->codec,&aud_fifo);
- //init_swr(aud_frame,sinfo->audContext->codec);
- }
- int finished;
- read_decode_convert_and_store(aud_frame, aud_fifo,
- audio_stream,
- aud_ctx,
- sinfo->audContext,
- sinfo->audContext->codec,
- swr);
- //if (av_audio_fifo_size(aud_fifo)>=sinfo->audContext->codec->frame_size )
- {
- load_encode_and_write(aud_fifo, sinfo->audContext, sinfo->fmtContext, sinfo->audContext->codec, sinfo->muxed_pts);
- }
- /*int err = av_buffersrc_write_frame(abuffer_ctx, aud_frame);
- if (err < 0) {
- fprintf(stderr, "CRITICAL: INPUT: error writing audio frame to buffersrc\n");
- goto end;
- }
- // pull filtered audio from the filtergraph
- for (;;) {
- err = av_buffersink_get_frame(abuffersink_ctx, audio_filt_frame);
- if (err == AVERROR_EOF || err == AVERROR(EAGAIN))
- break;
- if (err < 0) {
- fprintf(stderr, "CRITICAL: INPUT: Error sending data to audio filtersink\n");
- return -1;
- }
- int finished;
- read_decode_convert_and_store(audio_filt_frame, aud_fifo,
- audio_stream,
- aud_ctx,
- sinfo->audContext,
- sinfo->audContext->codec,
- swr);
- //if (av_audio_fifo_size(aud_fifo)>=sinfo->audContext->codec->frame_size )
- {
- load_encode_and_write(aud_fifo, sinfo->audContext, sinfo->fmtContext, sinfo->audContext->codec, sinfo->muxed_pts);
- }
- }*/
- }
- got_frame = 0;
- }
- // Process Video Packets ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement