[FFmpeg-user] amr_nb in mp4 container?

Andrew Randrianasulu randrianasulu at gmail.com
Thu Feb 15 07:20:49 EET 2024


I managed to make video with amr_nb codec  in openCamera (android 11)

====
mediainfo /dev/shm/VID_20240215_064913.mp4
General
Complete name                            : /dev/shm/VID_20240215_064913.mp4
Format                                   : MPEG-4
Format profile                           : Base Media / Version 2
Codec ID                                 : mp42 (isom/mp42)
File size                                : 21.1 MiB
Duration                                 : 5 min 2 s
Overall bit rate mode                    : Variable
Overall bit rate                         : 586 kb/s
Frame rate                               : 19.929 FPS
Encoded date                             : 2024-02-15 03:54:16 UTC
Tagged date                              : 2024-02-15 03:54:16 UTC
com.android.version                      : 11

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : Constrained Baseline at L2
Format settings                          : 1 Ref Frames
Format settings, CABAC                   : No
Format settings, Reference frames        : 1 frame
Format settings, GOP                     : M=1, N=30
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 5 min 2 s
Source duration                          : 5 min 1 s
Bit rate                                 : 562 kb/s
Width                                    : 640 pixels
Height                                   : 480 pixels
Display aspect ratio                     : 4:3
Frame rate mode                          : Variable
Frame rate                               : 19.929 FPS
Minimum frame rate                       : 9.998 FPS
Maximum frame rate                       : 30.010 FPS
Standard                                 : Component
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.092
Stream size                              : 20.2 MiB (96%)
Source stream size                       : 20.2 MiB (96%)
Title                                    : VideoHandle
Language                                 : English
Encoded date                             : 2024-02-15 03:54:16 UTC
Tagged date                              : 2024-02-15 03:54:16 UTC
Color range                              : Limited
Color primaries                          : BT.601 NTSC
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.601
mdhd_Duration                            : 302037
Codec configuration box                  : avcC

Audio
ID                                       : 2
Format                                   : AMR
Format/Info                              : Adaptive Multi-Rate
Format profile                           : Narrow band
Codec ID                                 : samr
Duration                                 : 5 min 2 s
Bit rate mode                            : Variable
Bit rate                                 : 12.8 kb/s
Channel(s)                               : 1 channel
Sampling rate                            : 8 000 Hz
Bit depth                                : 13 bits
Stream size                              : 472 KiB (2%)
Title                                    : SoundHandle
Writing library                          :
Language                                 : English
Encoded date                             : 2024-02-15 03:54:16 UTC
Tagged date                              : 2024-02-15 03:54:16 UTC


====

ffmpeg (both 4.4.4 on Slackware 15.0 i586 and 6.1.1 on aarch64 Termux)
refuse to copy audio stream:

ffmpeg -i  /dev/shm/VID_20240215_064913.mp4 -c:a copy -c:v copy /dev/shm/ccc.mp4
ffmpeg version 4.4.4 Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 11.2.0 (GCC)
  configuration: --prefix=/usr --libdir=/usr/lib --shlibdir=/usr/lib
--docdir=/usr/doc/ffmpeg-4.4.4/html --mandir=/usr/man --disable-debug
--enable-shared --disable-static --enable-gpl --enable-version3
--enable-avresample --arch=i586 --enable-libfontconfig
--enable-libfreetype --enable-libfribidi --enable-gnutls
--enable-libass --enable-libbluray --enable-libcdio --enable-frei0r
--enable-libgsm --enable-openal --enable-libopus --enable-librtmp
--enable-libsnappy --enable-libspeex --enable-libssh
--enable-libtheora --enable-libtwolame --enable-libv4l2
--enable-libvidstab --enable-libvorbis --enable-libvpx
--enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid
--enable-libmp3lame --enable-opencl --enable-opengl
--enable-libopenjpeg --disable-libpulse --enable-libsmbclient
--enable-libsvtav1 --enable-libxml2 --enable-librsvg --enable-libdrm
--enable-libaom --enable-libdav1d --enable-libsoxr --enable-libzimg
--enable-vapoursynth
  libavutil      56. 70.100 / 56. 70.100
  libavcodec     58.134.100 / 58.134.100
  libavformat    58. 76.100 / 58. 76.100
  libavdevice    58. 13.100 / 58. 13.100
  libavfilter     7.110.100 /  7.110.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  9.100 /  5.  9.100
  libswresample   3.  9.100 /  3.  9.100
  libpostproc    55.  9.100 / 55.  9.100
[amrnb @ 0x87d54c0] Multiple frames in a packet.
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/dev/shm/VID_20240215_064913.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2024-02-15T03:54:16.000000Z
    com.android.version: 11
  Duration: 00:05:02.04, start: 0.000000, bitrate: 585 kb/s
  Stream #0:0(eng): Video: h264 (Constrained Baseline) (avc1 /
0x31637661), yuv420p(tv, smpte170m/smpte170m/bt709), 640x480, 562
kb/s, SAR 1:1 DAR 4:3, 19.93 fps, 60 tbr, 90k tbn, 180k tbc (default)
    Metadata:
      creation_time   : 2024-02-15T03:54:16.000000Z
      handler_name    : VideoHandle
      vendor_id       : [0][0][0][0]
  Stream #0:1(eng): Audio: amr_nb (samr / 0x726D6173), 8000 Hz, mono,
flt, 12 kb/s (default)
    Metadata:
      creation_time   : 2024-02-15T03:54:16.000000Z
      handler_name    : SoundHandle
      vendor_id       : [0][0][0][0]
[mp4 @ 0x87d9840] Could not find tag for codec amr_nb in stream #1,
codec not currently supported in container
Could not write header for output file #0 (incorrect codec parameters
?): Invalid argument
Error initializing output stream 0:1 --
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
    Last message repeated 1 times

====

well, I guess if Android somehow managed to put this into mp4 ffmpeg
should be able to do the same trick, no?


More information about the ffmpeg-user mailing list