
Start with the transcode_aac official example."How can I convert m4p to mp3 when not authorized to play? On iTunes, I have DRM protected songs that were purchased from a family apple id that is no longer active"Ī new audio file format, M4P, is difficult to open because of its strong and limited protection. You can looking into demuxing.c and muxing.c provided in ffmpeg examples. You can use av_read_frame(informat, &pkt), avcodec_decode_audio4(in_aud_codec_ctx, pframeT, &got_vid_pkt, &pkt), avcodec_encode_audio2() and av_write_frame().įinally write trailer using av_write_trailer. Now in while loop start reading packet, decode only audio packet encode them and write them in opened output file. Write the output headers using avformat_write_header(outformat, NULL). Now for output file guess the outformat using av_guess_format(NULL, (const char*)outfile, NULL).įind output audio encoder using avcodec_find_encoder(outfmt->audio_codec).Īdd new stream audio stream avformat_new_stream(outformat, out_aud_codec).įill output codec context with desired sample rate, sample fmt, channel etc. Use avcodec_find_decoder(in_aud_strm->codec->codec_id) and avcodec_open2(in_aud_codec_ctx, in_aud_codec, NULL). Once you have input audio stream you can find audio decoder and open the decoder.


Open input file using avformat_open_input( &informat, sourcefile, 0, 0)).įind stream info using avformat_find_stream_info(informat, 0)).įind the audio stream by iterating through streams and comparing codec_type to AVMEDIA_TYPE_AUDIO. You can try using ffmpeg to do it in C or C++.
