Advertisement
Guest User

convert audio

a guest
Aug 24th, 2013
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.16 KB | None | 0 0
  1. while (av_read_frame(pInputCtx, &pktIn) >= 0) {
  2.             do {
  3.                 len = avcodec_decode_audio4(pInputStream->codec, frame, &got_frame, &pktIn);
  4.                 DIE_IF_LESS_ZERO(len, "Error decoding frame: %s", e2s(len));
  5.                 len = FFMIN(len, pktIn.size);
  6.                 if (len < 0) break;
  7.                 if (got_frame) {
  8.                     do {
  9.                         av_init_packet(&pktOut);
  10.                         pktOut.data = NULL;
  11.                         pktOut.size = 0;
  12.                         LOGI("encode frame");
  13.                         DIE_IF_UNDEFINED(pOutputStream->codec, "no output codec");
  14.                         DIE_IF_UNDEFINED(frame->nb_samples, "no nb samples");
  15.                         DIE_IF_UNDEFINED(pOutputStream->codec->internal, "no internal");
  16.                         LOGI("tests done");
  17.                         len = avcodec_encode_audio2(pOutputStream->codec, &pktOut, frame, &got_packet);
  18.                         LOGI("encode done");
  19.                         DIE_IF_LESS_ZERO(len, "Error (re)encoding frame: %s", e2s(len));
  20.                     } while (!got_packet);
  21.                     // write packet;
  22.                     LOGI("write packet");
  23.                     av_free_packet(&pktOut);
  24.                 }
  25.                 pktIn.data += len;
  26.                 pktIn.size -= len;
  27.             } while (pktIn.size > 0);
  28.             av_free_packet(&pktIn);
  29.     }
  30.  
  31.     LOGI("write trailer");
  32.     av_write_trailer(pOutputCtx);
  33.     LOGI("end");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement