Hello
   I've altered doc/examples/transcoding.c to encode using aac codec:

--- a/doc/examples/transcoding.c
+++ b/doc/examples/transcoding.c
@@ -114,7 +114,12 @@
         if (dec_ctx->codec_type == AVMEDIA_TYPE_VIDEO
                 || dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
             /* in this example, we choose transcoding to same codec */
+            if (dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
+                encoder = avcodec_find_encoder_by_name("aac");
+                avcodec_get_context_defaults3(enc_ctx, encoder);
+            } else {
             encoder = avcodec_find_encoder(dec_ctx->codec_id);
+            }
             if (!encoder) {
av_log(NULL, AV_LOG_FATAL, "Necessary encoder not found\n");
                 return AVERROR_INVALIDDATA;

And then transcoding fails as with:
[aac @ 0x28d5780] more samples than frame size (avcodec_encode_audio2)
Do I have to add some more filters to filter chain or use libswrresample and libavutil/audio_fifo as in example in transcode_aac.c?

Full output with DEBUG logging:
$ ./doc/examples/transcoding input.avi /tmp/tmp.avi
[file @ 0x27d2740] Setting default whitelist 'file'
[avi @ 0x27d2040] Format avi probed with size=2048 and score=100
[avi @ 0x27d28a0] use odml:1
[avi @ 0x27d2040] overriding sample_size
[avi @ 0x27d2040] Before avformat_find_stream_info() pos: 10030 bytes read:118568 seeks:4
[avi @ 0x27d2040] All info found
[avi @ 0x27d2040] After avformat_find_stream_info() pos: 58896 bytes read:151336 seeks:4 frames:2
detected 2 logical cores
Input #0, avi, from 'input.avi':
  Metadata:
    encoder         : Lavf52.64.2
  Duration: 00:00:10.00, start: 0.000000, bitrate: 2704 kb/s
Stream #0:0, 1, 1/25: Video: mpeg4 (Simple Profile), 1 reference frame (xvid / 0x64697678), yuv420p(left), 1024x576 [SAR 1:1 DAR 16:9], 1/25, 2372 kb/s, 25 fps, 25 tbr, 25 tbn, 25 tbc Stream #0:1, 1, 32/1225: Audio: mp3 (U[0][0][0] / 0x0055), 44100 Hz, stereo, s16p, 320 kb/s
[mpeg4 @ 0x27f74a0] intra_quant_bias = 0 inter_quant_bias = -64
Output #0, avi, to '/tmp/tmp.avi':
Stream #0:0, 0, 0/0: Video: mpeg4, 1 reference frame, yuv420p, 1024x576 [SAR 1:1 DAR 16:9], 1/25, q=2-31, 128 kb/s, 25 tbc
    Stream #0:1, 0, 0/0: Audio: aac (LC), 44100 Hz, stereo, fltp, 128 kb/s
[file @ 0x29fad80] Setting default whitelist 'file'
[avi @ 0x27f6aa0] Using AVStream.codec.time_base as a timebase hint to the muxer is deprecated. Set AVStream.time_base instead. [avi @ 0x27f6aa0] Using AVStream.codec.time_base as a timebase hint to the muxer is deprecated. Set AVStream.time_base instead.
[in @ 0x2a03e40] Setting 'video_size' to value '1024x576'
[in @ 0x2a03e40] Setting 'pix_fmt' to value '0'
[in @ 0x2a03e40] Setting 'time_base' to value '1/25'
[in @ 0x2a03e40] Setting 'pixel_aspect' to value '1/1'
[in @ 0x2a03e40] w:1024 h:576 pixfmt:yuv420p tb:1/25 fr:0/1 sar:1/1 sws_param: [AVFilterGraph @ 0x2a03480] query_formats: 3 queried, 2 merged, 0 already done, 0 delayed
[in @ 0x2a06880] Setting 'time_base' to value '1/44100'
[in @ 0x2a06880] Setting 'sample_rate' to value '44100'
[in @ 0x2a06880] Setting 'sample_fmt' to value 's16p'
[in @ 0x2a06880] Setting 'channel_layout' to value '0x3'
[in @ 0x2a06880] tb:1/44100 samplefmt:s16p samplerate:44100 chlayout:0x3
[Parsed_anull_0 @ 0x2a079a0] auto-inserting filter 'auto-inserted resampler 0' between the filter 'in' and the filter 'Parsed_anull_0' [AVFilterGraph @ 0x2a05f00] query_formats: 3 queried, 3 merged, 3 already done, 0 delayed [auto-inserted resampler 0 @ 0x2a094e0] [SWR @ 0x2a098c0] Using s16p internally between filters [auto-inserted resampler 0 @ 0x2a094e0] ch:2 chl:stereo fmt:s16p r:44100Hz -> ch:2 chl:stereo fmt:fltp r:44100Hz
Demuxer gave frame of stream_index 1
Going to reencode&filter the frame
Pushing decoded frame to filters
Pulling filtered frame from filters
Encoding frame
[aac @ 0x28d5780] more samples than frame size (avcodec_encode_audio2)
[aac @ 0x28d5780] Qavg: -nan
[AVIOContext @ 0x27da900] Statistics: 151336 bytes read, 4 seeks
[AVIOContext @ 0x2a02f20] Statistics: 0 seeks, 1 writeouts
--
Regards
Przemysław Sobala
_______________________________________________
Libav-user mailing list
Libav-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user

Reply via email to