Find the answer to your Linux question:
Results 1 to 5 of 5
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Question concatenate mp4 file

    I downloaded mp4 files from a TV show that have been segmented and I want to copy/concatenate them so that they are contiguous and continuous. I know how to do this in DOS, and I have tried and failed to do this with cmdline Linux using "cat" i.e.
    cat file1 file2 >> file3
    the copy worked (file3 file size was the sum of all the files I was copying) but the displaying of the mp4 file terminated at the end of file1.

  2. #2
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Seattle, WA, USA
    Indeed. The two files each have their own header information. I don't know exactly what the MP4 file format is, but I suspect that it contains a header with information on the length of the file. So file3 still had file1's header, which claimed to be as long as file1, so only file1's information was read.

    I found this page:
    Concatenate Video Files Using FFMPEG Ulyssesonline

    which describes the correct command to use:
    cat file1 file2 | ffmpeg -f mp4 -i - -vcodec copy -acodec copy file3

  3. #3
    I installed ffmpeg and am working with the command. The output file was created, but still only processed the first file in the concat list.
    I'm going to rtf the utility page and see if i can see what i'm doing wrong.

    Thanks for your help in pointing me in the right direction!

  4. $spacer_open
  5. #4
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    I wouldn't use cat to concatenate 2 mp4 files, but would use ffmpeg with two input parameters. It will happily transcode both and give you one resulting sum of the parts. So, try this:
    ffmpeg -i file1.mp4 -i file2.mp4 -vcodec copy -sameq file3.mp4
    Or you can just transcode them, such as generating DVD-compatible mpeg2 files with this:
    ffmpeg -i file1.mp4 -i file2.mp4 -target ntsc-dvd -sameq file3.mpg
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  6. #5
    Nice one. I think that are concentrated in mp4 files. Thanks for your information.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts