0

My mp4 videos have the same encoding: h264

I know because I ran this command on them:

ffprobe -v error -select_streams v:0 -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 a.mp4

Now I combine them using the following command:

ffmpeg -loglevel quiet -f concat -safe 0 -i video-list.txt -c copy video-final.mp4

my video-list.txt file looks like this:

file 'a.mp4'
file 'b.mp4'
file 'c.mp4'

Now the video-final.mp4 which is the combined video actually has duration which is equal to the sum of its' component videos and also is quite larger in size. The issue is that when I play the video, it only plays the first video then stops.

What's going on here? Any insight would be appreciated.

I've looked at: ffmpeg: Combine/merge multiple mp4 videos not working, output only contains the first video and the answers suggested there are the ones I'm using: specifically, concating from a text file containing the component videos.

Ayudh
  • 1,673
  • 1
  • 22
  • 55
  • Having the same codec is not sufficient. Codec profile, resolution, pixel format, reference count ..etc need to match. – Gyan Apr 05 '20 at 10:40
  • is there a way for me to make it possible to concat the mp4 videos then? a way to make everything you listed the same? – Ayudh Apr 05 '20 at 10:53
  • Re-encode all videos with the same parameters: `-s 1280x720 -pix_fmt yuv420p -video_track_timescale 12000` – Gyan Apr 05 '20 at 11:13
  • I tried this, it didn't work... I ran this command on two videos and tried to concat them, same issue – Ayudh Apr 05 '20 at 12:08
  • Share both those commands and their full logs + concat command. – Gyan Apr 05 '20 at 14:27
  • I've added the two videos for ease of your debugging – Ayudh Apr 12 '20 at 10:24

1 Answers1

2

The audio streams in your sample files don't match.

output1.mp4:

Audio: aac (LC) (mp4a / 0x6134706D), 24000 Hz, mono, fltp, 112 kb/s (default)

vide-static-final.mp4:

Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 155 kb/s (default)

The sampling rate and channel layout doesn't match. One of these should be converted to match the other.

For audio, codec (aac), codec profile (LC), sampling rate or frequency (48000 Hz), channel layout (stereo) and sample format (fltp) should match. Bitrate isn't important.

Video: h264 (High 4:4:4 Predictive) (avc1 / 0x31637661), yuv444p, 640x360, 1365 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)

For video, codec (h264), profile (High 4:4:4 Predictive), pixel format (yuv444p) and resolution (640x360) should match. If the timescale (12800 tbn) is different, then playback speed won't be correct and total duration will be wrong. Audio sync will also be lost.

Gyan
  • 85,394
  • 9
  • 169
  • 201
  • I see, thanks for the thorough answer, I'll try to convert the audio streams to be the same and see if that works – Ayudh Apr 13 '20 at 01:48
  • It works. Again, thanks for your thorough answer. It is immensely helpful to have the details of what needs to the the same. Thanks and Jai Hind. – Ayudh Apr 13 '20 at 06:18