[Ffmpeg-devel] -acodec copy an AMR 3gp file breaks

Rudolf Schwab sothoth732
Mon Dec 11 01:41:41 CET 2006


Hello,

Using ffmpeg with option '-acodec copy' to transcode from a h263 encoded
3gp file with AMR encoded audio to another fails with error
'sample duration is not set' for the audio track (see [1] below).
It works fine when omitting the '-acodec copy' flag which lets ffmpeg
actually encode and decode the audio frames (see [2] below).

Some investigation:

I have checked in the source and it seems that function mov_write_header in
libavformat/movenc.c breaks in line 1523 since the frame_size of the audio
stream is set to 0. The codec context's frame_size field is initialized by the
encoder/decoder initialization routines in libavcodec/amr.c to 160
once the encoders and decoders are actually allocated (which do not seem
to be allocated when using option '-acodec copy').

Is it possible to copy over an AMR encoded audio stream from a 3gp file to
another without decoding and encoding? I am willing to help fixing if this
actually is a bug but I would need some hints (just setting frame_size to 160
in the input and output stream codec contexts does not yield the expected
result). Would there be a workaround when using the API (instead of the ffmpeg
executable)?

Thank you,
Rudi

P.S.: If this belongs in ffmpeg-user list I am sorry. Please tell me if so.

[1] ---------------------------------------------------------------------------
Output with broken '-acodec copy':
dune:/tmp/ffmpeg$ ffmpeg -i matrixpong.3gp -vcodec h263 -r pal -s
352x288 -acodec copy matrixpong_big.3gp
FFmpeg version SVN-r7254, Copyright (c) 2000-2006 Fabrice Bellard, et al.
  configuration:  --enable-mp3lame --enable-static --enable-amr_wb
--enable-amr_nb
  libavutil version: 49.1.0
  libavcodec version: 51.26.0
  libavformat version: 51.6.0
  built on Dec 10 2006 22:59:57, gcc: 4.0.1 (Apple Computer, Inc. build 5367)

Seems stream 0 codec frame rate differs from container frame rate:
29.97 (30000/1001) ->
 25.00 (90000/3600)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'matrixpong.3gp':
  Duration: 00:01:43.4, start: 0.000000, bitrate: 57 kb/s
  Stream #0.0(eng): Video: h263, yuv420p, 176x144, 25.00 fps(r)
  Stream #0.1(eng): Audio: amr_nb, 8000 Hz, mono
Output #0, 3gp, to 'matrixpong_big.3gp':
  Stream #0.0: Video: h263, yuv420p, 352x288, q=2-31, 200 kb/s, 25.00 fps(c)
  Stream #0.1: Audio: amr_nb, 8000 Hz, mono
Stream mapping:
  Stream #0.0 -> #0.0
  Stream #0.1 -> #0.1
[3gp @ 0x35e598]track 1: sample duration is not set
Could not write header for output file #0 (incorrect codec parameters ?)

[2] ---------------------------------------------------------------------------
dune:/tmp/ffmpeg$ ffmpeg -i matrixpong.3gp -vcodec h263 -r pal -s
352x288  matrixpong_big.3gp
FFmpeg version SVN-r7254, Copyright (c) 2000-2006 Fabrice Bellard, et al.
  configuration:  --enable-mp3lame --enable-static --enable-amr_wb
--enable-amr_nb
  libavutil version: 49.1.0
  libavcodec version: 51.26.0
  libavformat version: 51.6.0
  built on Dec 10 2006 22:59:57, gcc: 4.0.1 (Apple Computer, Inc. build 5367)

Seems stream 0 codec frame rate differs from container frame rate:
29.97 (30000/1001) ->
 25.00 (90000/3600)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'matrixpong.3gp':
  Duration: 00:01:43.4, start: 0.000000, bitrate: 57 kb/s
  Stream #0.0(eng): Video: h263, yuv420p, 176x144, 25.00 fps(r)
  Stream #0.1(eng): Audio: amr_nb, 8000 Hz, mono
Output #0, 3gp, to 'matrixpong_big.3gp':
  Stream #0.0: Video: h263, yuv420p, 352x288, q=2-31, 200 kb/s, 25.00 fps(c)
  Stream #0.1: Audio: amr_nb, 8000 Hz, mono, 64 kb/s
Stream mapping:
  Stream #0.0 -> #0.0
  Stream #0.1 -> #0.1
Press [q] to stop encoding
[h263 @ 0x3530b8]warning, clipping 1 dct coefficients to -127..127
[h263 @ 0x3530b8]warning, clipping 1 dct coefficients to -127..127
frame= 2585 q=13.9 Lsize=    3021kB time=103.4 bitrate= 239.3kbits/s
video:2817kB audio:162kB global headers:0kB muxing overhead 1.419500%




More information about the ffmpeg-devel mailing list