1

I tried this command:

ffmpeg -f concat -i mylist.txt -c copy output.mp4

But output.mp4 has no audio.

mylist.txt contains:

file '1.mp4'
file '2.mp4'

Information about 1.mp4 and 2.mp4:

C:\Users\Admin\OneDrive\Desktop\New folder>ffmpeg -n -i 1.mp4 -i 2.mp4
ffmpeg version git-2020-05-23-26b4509 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9.3.1 (GCC) 20200523
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libsrt --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --disable-w32threads --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
  libavutil      56. 48.100 / 56. 48.100
  libavcodec     58. 87.101 / 58. 87.101
  libavformat    58. 43.100 / 58. 43.100
  libavdevice    58.  9.103 / 58.  9.103
  libavfilter     7. 83.100 /  7. 83.100
  libswscale      5.  6.101 /  5.  6.101
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '1.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp41isom
    creation_time   : 2020-05-31T08:12:56.000000Z
  Duration: 00:00:05.93, start: 0.000000, bitrate: 186 kb/s
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 184 kb/s, 30 fps, 30 tbr, 30k tbn, 60 tbc (default)
    Metadata:
      creation_time   : 2020-05-31T08:21:56.000000Z
      handler_name    : VideoHandler
      encoder         : AVC Coding
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '2.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp41isom
    creation_time   : 2020-06-01T03:32:58.000000Z
  Duration: 00:00:12.23, start: 0.000000, bitrate: 1909 kb/s
    Stream #1:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 1708 kb/s, 30 fps, 30 tbr, 30k tbn, 60 tbc (default)
    Metadata:
      creation_time   : 2020-06-01T04:17:17.000000Z
      handler_name    : VideoHandler
      encoder         : AVC Coding
    Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 196 kb/s (default)
    Metadata:
      creation_time   : 2020-06-01T04:17:17.000000Z
      handler_name    : SoundHandler
At least one output file must be specified
llogan
  • 121,796
  • 28
  • 232
  • 243
  • Run this command: `ffmpeg -n -i 1.mp4 -i 2.mp4`. It will provide useful info about the inputs and your `ffmpeg` version. This info is required to provide an answer that you can copy and paste. Copy the **complete** log from that command. [Edit] your question and paste the complete log into your question. Ignore the `At least one output file must be specified error` in the log. – llogan May 31 '20 at 19:43
  • Unfortunately you provided the log for the wrong command. I am looking for information about each of the inputs referenced in `mylist.txt`. For proper concatenation all inputs must have the same attributes. I wanted to check the inputs to see if their attributes match. – llogan Jun 01 '20 at 18:44
  • Again, that's the wrong command and the screenshots are not informative. Please run the exact command I suggested (`ffmpeg -n -i 1.mp4 -i 2.mp4`). This command is only to provide info: it is not meant for converting anything. You do not need to modify it. The log is text so copy and paste it instead of making screenshots of text. Screenshots of text are less helpful and are harder to use. – llogan Jun 03 '20 at 18:15
  • the log added for this command `ffmpeg -n -i 1.mp4 -i 2.mp4` – Easy Tricks For Android Jun 05 '20 at 14:50

1 Answers1

1

For concatenation to work:

According to the concat demuxer documentation:

  • Each input must have the same number of video and audio streams.
  • Each video and audio stream must have the same attributes.
  • Each input must have the same video and audio format.

What is wrong with your inputs

1.mp4 has no audio. 2.mp4 has audio.

1.mp4 needs audio to be able to concatenate to 2.mp4.

Solution

Add silent audio to 1.mp4 using anullsrc filter:

ffmpeg -i input.mp4 -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=48000 -map 0:v -map 1:a -c:v copy -c:a aac -shortest 1b.mp4

Then update mylist.txt to:

file '1b.mp4'
file '2.mp4'

Finally run your ffmpeg command to concatenate:

ffmpeg -f concat -i mylist.txt -c copy -movflags +faststart output.mp4
llogan
  • 121,796
  • 28
  • 232
  • 243
  • thank-you for the solution. when running this command `ffmpeg -f concat -i mylist.txt -c copy -movflags +faststart output.mp4` 2 hour video shrunked to 5 minutes – Easy Tricks For Android Jun 06 '20 at 17:04
  • @EasyTricksForAndroid You must be using different inputs than shown in your question. This answer was specific to those two inputs. There must be some attribute that differs between the new files. – llogan Jun 06 '20 at 18:47
  • is it support different codec (h264 & h265) and different extension (.mp4 & .mkv). – Easy Tricks For Android Jun 07 '20 at 12:40
  • @EasyTricksForAndroid Each input must have the same video and audio format. It seems like you are looking for a generic answer, and not an answer that works for the particular inputs you provided. – llogan Jun 08 '20 at 21:16