0

I have a series of files from the same source and so of the exact same format in every way that I'm concatenating with FFMPEG

  • file1.mov
  • file2.mov
  • file3.mov

This is very fast and is working fine however no I want to take optional intro file (from many different source and of many different types) and convert that to match the others before joining.

  • intro.mp4

How do I do this with FFMPEG?

Does this give me everything I need?

ffprobe -select_streams a:0 -show_entries \
  stream=codec_name,channels -of default=nw=1:nk=1 -v 0 ./file1.mov

ffprobe -select_streams v:0 -show_entries \
  stream=codec_name,width,height,r_frame_rate,pix_fmt \
  -of default=nw=1:nk=1 -v 0 ./file1.mov

So with that I can just:

ffmpeg -i intro.mp4 \ 
   -c:v h264 -s 1280x720 -pix_fmt yuv420p -framerate 30/1  \ 
   -c:a pcm_s16le -ca 1 intro.mov

and then merge it seamlessly to the rest?

ffmpeg -f concat -safe 0 -i videos.txt -c copy merged.mov -y

The answer is of course "no", hence the request for your support. The audio is fine when files 1, 2 & 3 are merged but is too fast when the intro + 1, 2 & 3 are merged. The converted intro file always plays fine on it's own after the conversion and after the merge, but the others play audio too fast after the merge.

What am I missing?

UPDATE:

So in the end this worked for the intro:

ffmpeg -i intro.mp4 \ 
   -c:v h264 -s 1280x720 -pix_fmt yuv420p -framerate 30 \ 
   -c:a pcm_s16le -ac 1 -b:a 512k -ar 32000 intro.mov -y
user1748217
  • 143
  • 8

1 Answers1

0

I suspect intro.mp4 has higher audio sampling rate than the rest, and -f concat is setting the virtual input file's audio sampling rate to that of the intro.mov and running with it.

To fix this run your probe again and check the audio sampling rate (I can't remember off the top of head what it's called in the output, but could be "sample_rate"). Let this number of fs then transcode intro.mp4

ffmpeg -i intro.mp4 \
  -c:v h264 -s 1280x720 -pix_fmt yuv420p -framerate 30/1 \
  -c:a pcm_s16le -ar fs -ca 1 intro.mov

Replace fs with the rate you found. If it just played faster, all the other audio formats are compatible.

kesh
  • 4,515
  • 2
  • 12
  • 20