Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- while (av_read_frame(pInputCtx, &pktIn) >= 0) {
- do {
- len = avcodec_decode_audio4(pInputStream->codec, frame, &got_frame, &pktIn);
- DIE_IF_LESS_ZERO(len, "Error decoding frame: %s", e2s(len));
- len = FFMIN(len, pktIn.size);
- if (len < 0) break;
- if (got_frame) {
- do {
- av_init_packet(&pktOut);
- pktOut.data = NULL;
- pktOut.size = 0;
- LOGI("encode frame");
- DIE_IF_UNDEFINED(pOutputStream->codec, "no output codec");
- DIE_IF_UNDEFINED(frame->nb_samples, "no nb samples");
- DIE_IF_UNDEFINED(pOutputStream->codec->internal, "no internal");
- LOGI("tests done");
- len = avcodec_encode_audio2(pOutputStream->codec, &pktOut, frame, &got_packet);
- LOGI("encode done");
- DIE_IF_LESS_ZERO(len, "Error (re)encoding frame: %s", e2s(len));
- } while (!got_packet);
- // write packet;
- LOGI("write packet");
- av_free_packet(&pktOut);
- }
- pktIn.data += len;
- pktIn.size -= len;
- } while (pktIn.size > 0);
- av_free_packet(&pktIn);
- }
- LOGI("write trailer");
- av_write_trailer(pOutputCtx);
- LOGI("end");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement