Windows based SOLUTION!!! (and commentary to Wyze)
- Should work for any number of hours folders for the SAME DAY only. Don’t try to combine files across different days… it won’t work.
- Changes the audio track interpreter (CODEC) so it will work on virtually any video player.
- Once you have the FFMPEG.exe file and create the text batch file, it is very reusable.
- Trying to export from Wyze app on Android and also on iPad with 4.5 hours of source takes 4.5 hours! You have to sit through the whole thing again. Once it’s done, you stop the recording, go to the Album, and try to share IF it works, you may end up as I did repeatedly missing as much 1.5 hours of content. Non-starter, and not trustworthy.
I worked hand in hand with ChatGPT tonight as I had 4.5 hours of videos I needed to combine, which is about 270 minute long mp4 clips. Ugh.
I wanted a reusable solution, so I spent about 3 hours. Here’s the end game.
Download ffmpeg.exe from wherever you trust. If you have doubts about exe files, you can download the source and compile it yourself. Otherwise Google it and get the .exe.
Copy all of your 00, 01, 02, 03… hourly folders to a parent folder all by themselves. KEEP the folder structures (you have to because the minute long files are duplicated within each subfolder).
Copy the ffmpeg.exe file to the same parent folder where all the subfolders exist.
Create a batch file (a text file that runs commands) with the text provided in the instructions below.
Run the batch file. It opens each hourly file in order and copies the minute files into a newly created folder called “combined”. It renames them in order as it goes so all the minutes from all the hours are unique and in order. Then it creates a text file ffmpeg needs to understand the files it is going to combine. Then it tells ffmpeg.exe to combine the files in the list into one big file.
I did 289 files, which was about 1.7gb in the “output.mp4” file that shows up in the parent directory.
This should be tolerant of starting at hour 00 to 05, or hour 12 to 16, for examples, based on my testing. I’m not sure how well will work for a full day, but this is much, much better!
The options I used for ffmpeg command line switches changes the audio track to a format that works on virtually every player.
Finally, Wyze, this is brutally bad that I have to do any of this. I tried to just use the “Record” option and Album and Share/Export, but after multiple files, my 4.5 hours of recording always ended up with big chunks missing, I was getting less than 3 hours in the final every time. When I built from the raw minute long MP4’s as described below, I got the full 4.5 hours, no gaps. This suggests real flaws to Wyze’s data handling approach during recording and export. I’m not blasting Wyze, I have your cameras all over my house, RV, etc. But basic stress testing should have caught this. I highly recommend making a way for users to export without having to re-watch everything. Let us pick the start and stop on your timeline, and then export it digitally from the camera to the target device without having to “play” the whole thing real time! Your users will love you for it.
THE SOLUTION:
Instructions to Concatenate MP4 Files from Numbered Directories
-
Preparation:
- Ensure you have a parent folder that contains the hourly folders named with numbers (e.g., “00”, “12”, “13”, “14” etc.).
- Each of these hourly folders should contain MP4 files you wish to concatenate.
-
Download and Extract FFmpeg:
- Visit the FFmpeg official download page: https://ffmpeg.org/download.html.
- Under the “Windows” section, click on the link for
Windows builds by BtbN
. This will redirect you to a page where you can select a version to download.
- Download the appropriate version for your system, ensuring you get the
.7z
version (most commonly ffmpeg-<version>-win64-static.7z
).
- After downloading, extract the contents of the
.7z
file using a program like 7-Zip. If you don’t have 7-Zip installed, you can download and install it from the given link.
- Within the extracted contents, locate the
ffmpeg.exe
file. It’s typically inside the bin
directory.
- Copy
ffmpeg.exe
to your parent directory that contains the hourly numbered folders.
-
Creating the Batch File:
- In the parent directory, right-click and choose
New
> Text Document
. Name it something like concatenate.bat
.
- Open this newly created file in a text editor like Notepad.
- Copy the below script and paste it into this file:
@echo off
setlocal enabledelayedexpansion
:: Step 1 - Copy files to combined
set count=0
:: Create 'combined' directory if not exists
if not exist combined mkdir combined
:: Loop through directories starting with 0 or 1
for /f "delims=" %%d in ('dir /b /ad ^| findstr "^[01]"') do (
for %%f in (%%d\*.mp4) do (
set "paddedNumber=00000000!count!"
set "paddedNumber=!paddedNumber:~-8!"
copy "%%f" "combined\!paddedNumber!.mp4"
echo copied: "%%f" to "combined\!paddedNumber!.mp4"
set /a count+=1
)
)
:: Step 2 - Generate files.txt
echo. > files.txt
:: Loop through the files in 'combined' and append their paths to files.txt
for %%f in (combined\*.mp4) do (
echo file '%%f' >> files.txt
)
echo Files list created: files.txt
:: Step 3 - Use ffmpeg to concatenate
ffmpeg -f concat -safe 0 -i files.txt -c:v copy -c:a aac -b:a 128k output.mp4
echo Videos concatenated as output.mp4
pause
- Save and close the text document.
-
Running the Batch File:
- Double-click on the
concatenate.bat
file you just created in the parent directory.
- The script will run: It will first copy the MP4 files from the numbered folders into a new
combined
folder, then it will create a files.txt
list, and finally, it will concatenate all the MP4 files into an output.mp4
file.
- Wait for the process to finish. Once done, you’ll have your concatenated video file named
output.mp4
in the parent directory.
Remember, before running the script again, ensure you remove or move the previously generated output.mp4
, combined
folder, and files.txt
to avoid potential issues.