11

I'm on Arch Linux 4.13.10 and I'd like to combine multiple .MOV files shot with a Canon EOS camera.

I tried to convert the files to transport streams (.ts files) using FFmpeg, as shown here, but sound was missing from the resulting file.

I'd prefer if the resulting file would be .mp4, but this is not strictly required.

How do I do this?

Matthias Braun
  • 1,162
  • 1
  • 17
  • 29

2 Answers2

18

I succeeded merging the files using FFmpeg's demuxing feature. For .mp4 conversion, I had to explicitly convert the audio stream to avoid this error:

Could not find tag for codec pcm_s16le in stream #1, codec not currently supported in container

This is the command combining the files to merged.mp4:

ffmpeg -f concat -i files_to_combine.txt -vcodec copy -acodec aac -strict -2 -b:a 384k merged.mp4

If the output file can be also a .MOV file, the command is:

ffmpeg -f concat -i files_to_combine.txt -vcodec copy -acodec copy merged.MOV

Here's the content of the text file files_to_combine.txt:

file ./first_file.MOV
file ./second_file.MOV

If you get the error

Unsafe file name 'file with spaces.mov' files_to_combine.txt: Operation not permitted

and trust the file names, you can add -safe 0 to get around this error. See FFmpeg's man page:

ffmpeg -safe 0 -f concat ...

Shorter commands

Trying the same task five years later, I also had success with

ffmpeg -f concat -i files_to_combine.txt merged.mov

and

ffmpeg -f concat -i files_to_combine.txt -f mp4 merged.mp4
Matthias Braun
  • 1,162
  • 1
  • 17
  • 29
  • From the single MOV, you can use [mp4box](https://gpac.wp.imt.fr/downloads/gpac-nightly-builds/) to get a MP4. `mp4box -add merged.mov -new merged.mp4` – Gyan Oct 04 '17 at 19:42
  • I get: [concat @ 0x55ba4a488b40] Line 1: unknown keyword 'IMG_9847.MOV' files_to_combine.txt: Invalid data found when processing input – Nathan B Apr 28 '23 at 09:15
  • @NathanB: I'm pretty sure you forgot the keyword "file" in front of your file names in `files_to_combine.txt`. – Matthias Braun Apr 28 '23 at 18:55
1
find *.MOV | sed 's:\ :\\\ :g'| sed 's/^/file /' > fl.txt; ffmpeg -f concat -i fl.txt -c copy output.mp4; rm fl.txt
Danil
  • 111
  • 3
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - [From Review](/review/low-quality-posts/1069112) – music2myear Jul 24 '21 at 02:49
  • No, it does many `.MOV` to single `.MP4` conversion – Danil Jul 25 '21 at 18:48
  • 2
    I had to change the output to .mov to get it to work, like: `find *.MOV | sed 's:\ :\\\ :g'| sed 's/^/file /' > fl.txt; ffmpeg -f concat -i fl.txt -c copy output.mov; rm fl.txt` – Lewis Cianci Jan 27 '22 at 10:45
  • yes the fl.txt file should include in every line the word 'file ' before the file name – Nathan B Apr 28 '23 at 09:24