How to merge all 1min files into one video

This simple guide is for windows users but should work as easily under linux or mac.

Put all your files and daily folders in /record/ into a folder, example /wizemerge/

Press start key and type “cmd” to open command line.

Go to that folder by typing “cd folder” until you’re into it.

for me that was;
cd desktop
cd wyzemerge

type
dir /s/b *.mp4 > list.txt

This will print a list of all mp4 files in all subdirectory into a file called list.txt

Open that file and make it compatible with FFMPEG by turning

C:\Users\T3\Desktop\wyzemerge\Videos\20230301\00\06.mp4
C:\Users\T3\Desktop\wyzemerge\Videos\20230301\00\07.mp4

into

file ‘C:\Users\T3\Desktop\wyzemerge\Videos\20230301\09\47.mp4’
file ‘C:\Users\T3\Desktop\wyzemerge\Videos\20230301\09\48.mp4’

Open a text editor and use replace tool, CTRL-H

Replace
C:
by
file 'C:

Replace
.mp4
by
.mp4’

Now download a copy of FFMPED and put it into that same folder.

choose ffmpeg-master-latest-win64-gpl.zip

then type the command
ffmpeg.exe -safe 0 -f concat -i list.txt -c copy all.mkv

to create a single video called all.mkv

It should be very fast as there are no re-encoding.

10 Likes

Very nice!

2 Likes

This is fantastic! Thanks for the step by step. This post earns a bookmark!

2 Likes

Not seeing where this is sorted into proper name or date order?

Awesome post

1 Like

Yeah, That was my surprise too, Didn’t expect they’d all be in order.

It’s sorted by folder and given the largest unit is in front, it stay chronological.

Year, Month, Day / Hours / Minutes

Well that’s good to hear but it’s not something I’d count on, especially as the drive gets rewritten. All you’d need to tweak is a sort parameter in your command, e.g., /od or /on.

1 Like

FFmpeg works good on windows.

For a few days worth of wyze data (about 4000 one minute files), it does take a while to create one big video. Be prepared for using up hard drive space. Better yet, use an SSD.

-F

I like @Customer’s suggestion of directory sorting, so I tried that:

dir /b /od /s *.mp4 > list.txt

Unfortunately, that didn’t quite give me the results that I wanted, because my output ended up looking like this:

T:\record\20240423\00\00.mp4
T:\record\20240423\00\01.mp4
T:\record\20240423\00\02.mp4
⋮
T:\record\20240505\20\15.mp4
T:\record\20240505\20\16.mp4
T:\record\20240505\20\17.mp4
T:\record\20240418\07\38.mp4
T:\record\20240418\07\39.mp4
T:\record\20240418\07\40.mp4
⋮
T:\record\20240422\23\57.mp4
T:\record\20240422\23\58.mp4
T:\record\20240422\23\59.mp4

This also happened when I used the /on switch for my dir command.

Since I was still on the command line, I just did this:

sort list.txt /o list_sorted.txt

That fixed the file order issue, so I might as well do it all with a single command, using a pipe:

dir /b /s *.mp4 | sort /o list.txt

Then instead of opening the sorted file in a text editor and doing two different find/replace operations, we can just stay on the command line and take care of it here:

for /f %r in (list.txt) do echo file '%r' >> FFlist.txt

Note that we changed the final output file name here to FFlist.txt for the FFmpeg format we’re going to use, but at this point we might as well just modify our command and do it all at once with the original file name:

for /f %r in ('dir /b /s *.mp4 ^| sort') do echo file '%r' >> file.txt

That at least gets us to the point where we pass the work off to FFmpeg, but I haven’t yet taken the time to muck about with that in Windows. (My limited experience with it so far has been on Linux, and in that instance I had to change the audio encoding to make it work.)

There are probably better and/or faster ways to do it (maybe PowerShell has some cool tool that makes it even easier; I haven’t ever taken the time to learn PowerShell), but I like trying to make friends with the regular ol’ DOS-like command line and use its built-in tools to make life easier. Of course, if this is something I intended to do on a regular basis, I’d just write a script or batch file to do everything in one go.

I like MP4Joiner. It is open source and completely free. No need to re-encode and no quality loss.

https://www.mp4joiner.org/en/

1 Like

Ooh! Cross-platform, too! I haven’t used it, but I appreciate the suggestion of a new toy to try. Thanks!

2 Likes

The only issue with MP4Joiner is that you have to manually drag and drop each individual file. Unless there is a awy to do folders

I have no experience with MP4Joiner, but I would think selecting all the files in a folder and dragging them would do the trick?

May be out of order though :grin: