Yes, it is absolutely possible to combine (concatenate) multiple WebM videos without re-encoding using FFmpeg. WebM is a wonderful container format for this purpose, as it allows for straightforward concatenation, thanks to its Matroska-based design.
Each line starts with file (note the space) followed by the exact path to your WebM file. If the files are in the same directory as the text file, just the filenames are enough. Otherwise, use absolute or relative paths (e.g., file '../videos/input2.webm').
Step 2: Run the FFmpeg command
Now, execute the FFmpeg command I mentioned earlier:
-f concat: tells FFmpeg to use the concat demuxer, which reads the file list from the input text file.
-i mylist.txt: specifies the input text file containing the list of WebM files.
-c copy: this is the crucial part! -c stands for "codec" and copy means: don't touch the video and audio streams; just copy them as-is from the input files to the output file. No re-encoding happens here!
output.webm: the resulting concatenated WebM file.
What happens during concatenation?
When you run the command, FFmpeg:
Reads the mylist.txt file and understands the list of WebM files to concatenate.
Verifies that all input WebM files have the same codecs (e.g., VP8 or VP9 video, Opus or Vorbis audio) and similar metadata (e.g., resolution, frame rate, sample rate). If they don't match, FFmpeg will abort.
Simply "glues" the video and audio packets from each input file together, maintaining the original encoding and quality.
Writes the concatenated stream into the output.webm file.
Prerequisites for successful concatenation:
Ensure that:
All input WebM files use the same codecs (video: VP8 or VP9; audio: Opus or Vorbis).
Similar encoding settings (e.g., same bitrate, profile, and level) are used across all files. While not strictly necessary, this ensures a smooth concatenation.
No file has weird timestamps (e.g., negative or unsorted timestamps). FFmpeg will complain or produce a broken output if timestamps are wonky.
If these conditions are met, FFmpeg will concatenate your WebM files without re-encoding, preserving the original quality and encoding settings. This process is fast (almost as fast as copying the files) and lossless (no quality degradation).
Give it a try, and you should see FFmpeg concatenating your WebM videos in no time!