1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| while(av_read_frame(ifmt_ctx, &pkt) >=0 ) { if(pkt.stream_index == audio_index) { char adts_header_buf[7] = {0}; adts_header(adts_header_buf, pkt.size, ifmt_ctx->streams[audio_index]->codecpar->profile, ifmt_ctx->streams[audio_index]->codecpar->sample_rate, ifmt_ctx->streams[audio_index]->codecpar->channels); fwrite(adts_header_buf, 1, 7, aac_fd); len = fwrite( pkt.data, 1, pkt.size, aac_fd); if(len != pkt.size) { av_log(NULL, AV_LOG_DEBUG, "warning, length of writed data isn't equal pkt.size(%d, %d)\n", len, pkt.size); } } av_packet_unref(&pkt); }
|