Site Map - skip to main content

Hacker Public Radio

Your ideas, projects, opinions - podcasted.

New episodes Monday through Friday.

hpr4077 :: FFMPEG Series: Joining and Splitting files

In this episode, I explain how to use FFMGEG to join and split media files

<< First, < Previous, , Latest >>

Thumbnail of Mr. Young
Hosted by Mr. Young on 2024-03-19 is flagged as Clean and is released under a CC-BY-SA license.
recording,ffmpeg,audio,video. 1.

Listen in ogg, spx, or mp3 format. Play now:

Duration: 00:09:22


FFMPEG Series Part 2: Joining and Splitting files

Joining Files


For lossless files of the same codecs

ffmpeg -i "concat:input1.ts|input2.ts|input3.ts" -c copy output.ts

For mp4 files, using intermediate files

ffmpeg -i input1.mp4 -c copy intermediate1.ts
ffmpeg -i input2.mp4 -c copy intermediate2.ts
ffmpeg -i "concat:intermediate1.ts|intermediate2.ts" -c copy output.ts

Brief explanation of the options used in the command:

  • -i: input
  • -c copy: use codec same codecs as input

Splitting Files

Splitting by Duration:

ffmpeg -i input.mp4 -t 00:05:00 output_part1.mp4
ffmpeg -i input.mp4 -t 00:05:00 -ss 00:05:00 output_part2.mp4

Brief explanation of the options used in the command:

  • -i: Input file
  • -t: Duration of the output file
  • -ss: Start position of the output file (optional)

Splitting by Chapters or Markers:

Use additional scripting to get out chapter marker times, then use above

C. Splitting by Size:

ffmpeg -i input.mp4 -map 0 -c copy -segment_size 50M -segment_times 1 output_%03d.mp4

Brief explanation of the options used in the command:

  • -map 0: Select the first stream (video and audio)
  • -c copy: Copy the stream without re-encoding (faster)
  • -segment_size: Size of each output file segment
  • -segment_times: Number of segments to create
  • output_%03d.mp4: printf-style pattern for the output files


Subscribe to the comments RSS feed.

Comment #1 posted on 2024-03-20 11:15:45 by Henrik Hemrin

Useful to learn how ffmpeg can be used

Your presentation, in particular the concatenate command, gave me an idea for some ts files where this can be useful for me.

Leave Comment

Note to Verbose Commenters
If you can't fit everything you want to say in the comment below then you really should record a response show instead.

Note to Spammers
All comments are moderated. All links are checked by humans. We strip out all html. Feel free to record a show about yourself, or your industry, or any other topic we may find interesting. We also check shows for spam :).

Provide feedback
Your Name/Handle:
Anti Spam Question: What does the P in HPR stand for ?