Could not find tag for codec pcm_alaw in stream #1, codec not currently supported in container when concatenating 2 files using ffmpeg

A_Matar picture A_Matar · Nov 26, 2017 · Viewed 19.4k times · Source

I am trying to concatenate two files, the first of which has audio and video while the second is video only. I use the following ffmpeg command:

ffmpeg_command = ["ffmpeg", "-f", "concat", "-safe", "0", "-i", "clips_to_join.txt", "-vcodec", "copy", "-acodec", "copy", output_file_path] # output_filename = ch0X-start_time-end_time
p = subprocess.Popen(ffmpeg_command)
p.communicate()

but I get the following error:

  libavutil      54. 31.100 / 54. 31.100
  libavcodec     56. 60.100 / 56. 60.100
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 40.101 /  5. 40.101
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc    53.  3.100 / 53.  3.100
Invalid UE golomb code
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x1394700] Auto-inserting h264_mp4toannexb bitstream filter
Invalid UE golomb code
Guessed Channel Layout for  Input Stream #0.1 : mono
Input #0, concat, from 'clips_to_join.txt':
  Duration: N/A, start: 0.000000, bitrate: 5954 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 5894 kb/s, 14.06 fps, 30 tbr, 90k tbn, 180k tbc
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: pcm_alaw (alaw / 0x77616C61), 8000 Hz, 1 channels, s16, 64 kb/s
    Metadata:
      handler_name    : SoundHandler
[mp4 @ 0x13b16e0] Codec for stream 0 does not use global headers but container format requires global headers
[mp4 @ 0x13b16e0] Codec for stream 1 does not use global headers but container format requires global headers
[mp4 @ 0x13b16e0] Could not find tag for codec pcm_alaw in stream #1, codec not currently supported in container
Output #0, mp4, to '/path/ch1-20171109-131750-131949-101000000000-padded.mp4':
  Metadata:
    encoder         : Lavf56.40.101
    Stream #0:0(und): Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 1920x1080, q=2-31, 5894 kb/s, 14.06 fps, 30 tbr, 90k tbn, 90k tbc
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: pcm_alaw (alaw / 0x77616C61), 8000 Hz, mono, 64 kb/s
    Metadata:
      handler_name    : SoundHandler
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument

Answer

llogan picture llogan · Nov 26, 2017

codec not currently supported in container

ffmpeg does not support pcm_alaw in the MP4 container. Encode the audio as AAC, or use a different output container format such as MOV or MKV.

Encode the audio to AAC

  ffmpeg -i input.mov -c:v copy -c:a aac output.mp4

Or output to MOV or MKV

  ffmpeg -i input.mp4 -c copy output.mkv

copy enables stream copy mode which only re-muxes and avoids re-encoding (like a copy and paste).