App to join all the recorded videos automatically from 1 folder

I misread the post, I thought this was a script to concatenate all videos from one day period, into 1 large MP4 file, in time order. But it’s to get a timelapse.

Is there anyone that can help with a script that can spit out 1 MP4 for the whole day just recursing through subfolders?

Thanks

This is what I use. It’s clunky but it does work. I copy the directory off the SD card to a storage folder and at the root of that folder I have ffmpeg.exe and these 4 bat files. I know there’s a more elegant way to do this but I just copy these files, paste them into each hour-folder and run the bat I need from within that folder.

There’s four versions. The first concat.bat creates a list of the mp4 files in the directory then concatenates them into a single video file. Occasionally there is a corrupt audio track on one of the files and the concatenate fails. It’s possible to go into each individual minute-file and repair the audio or replace the audio track with a null file. Once that’s done there is no need to create the file list again, so there is a version that just concatenates called just_concat.bat. And, Because my power is really spotty and power to my cams die a lot and corrupt my audio a lot, and I don’t really need the audio, I wrote up another two versions that just discard the audio.

Yes, I know this isn’t a slick app but the ffmpeg docs and videos are confusing and this is what I had when I was finally done trying to figure them out. I flat cut and pasted from tutorials wherever it would work, and added very little but it did take some tweaking to make it work. Copy these files and ffmpeg.exe into your hour-directory and run concat.bat or concat_no_sound.bat and it works.

Batchfile filenames are bolded, cut and paste the text that follows it.

concat.bat
:: Create File List
for %%i in (*.mp4) do echo file ‘%%i’>> mylist.txt

pause

:: Concatenate Files
ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.mp4

pause

just_concat.bat
Echo Just Concatenating Files
pause

:: Concatenate Files
ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.mp4

pause

concat_no_sound.bat
:: Create File List
for %%i in (*.mp4) do echo file ‘%%i’>> mylist.txt

pause

:: Concatenate Files
ffmpeg -f concat -safe 0 -i mylist.txt -c copy -an output.mp4

pause

just_concat_no_sound.bat
Echo Just Concatenating Files
pause

:: Concatenate Files
ffmpeg -f concat -safe 0 -i mylist.txt -c copy -an output.mp4

pause

2 Likes

After loading up RTSP FW, I’m now using BI to record what I need to record, to one or a handful of files, only clips with motion. Having it all on the SD card is great, but hugely cumbersome to create any kind concatenated file. Similar, the lack of being able to access the SD card remotely to pull off files, is impractical. Once I put on RTSP and implemented BI, I never looked back. This may not work for everyone, but it’s perfect for me.

I have ever used Joyoshare Video Joiner. It can merge videos very easily and quickly. You can try it.

Dear Wyze, making the videos you allow us to record more easily USABLE should be a top priority. Your minute by minute storage process is fine for optimizing your data flow. However, from the user’s perspective, making people either use the app and WATCH hours of video to be able to EXTRACT hours of video to record, is silly. No need for it to be a 1:1 ratio for export time. You need a tool that says, starting August 6th at 5pm, and ending August 6th at 1130pm, export to one file (preferably with an MP4 format that is universally used, not one that requires VLC to work). THAT would make the Wyze product line much more useful.

Hi Loki

I have been using the Quicktime method, but I find that if I try to drag more than 15-20 one min clips onto the first in the series, my QT player stops responding? I have 40 GB of RAM on a decent iMac ( 3.8 GHz Quad-Core Intel Core i5) ? Usually the first drag and drop works, but the second and third start timing out.

Any suggestions?

I figured it out for Linux Ubuntu and added an answer here.

Create an inputs.txt file containing a list of all file paths to combine (see example at link above). Then, combine all above videos into one like this:

# Option 1 (preferred): into a single mp4 video with AAC audio encoding
# and original video encoding
time ffmpeg -f concat -safe 0 -i inputs.txt -c:v copy -c:a aac output.mp4

# Option 2: into a single .mkv video with original audio and video encoding
time ffmpeg -f concat -safe 0 -i inputs.txt -c copy output.mkv
1 Like

Will any of the methods discussed in this thread maintain chronological order when combining clips?

Mine does: App to join all the recorded videos automatically from 1 folder - #27 by eRCaGuy

You just have to make sure your items in the inputs.txt file are sorted. I edit the file with the Sublime Text editor and it has sorting features and multi-cursor edit mode to make the creation of that file super fast.

This is what I use (windows) from a command prompt.

The structure of the folder is:

yyyymmdd
-00
-01

… and so on till 23

**note that there are 2 recording settings, record continuously or record on motion (I have it set for record on motion only as I don’t need it to record when there is no motion, wasted space)

I copy all the files locally, then I go into each HOUR folder and run this (copy paste)

(for %i in (*.mp4) do @echo file '%i') > mylist.txt
C:\Winapps\ffmpeg\bin\ffmpeg.exe -safe 0 -f concat -i mylist.txt -c copy all.mkv -nostdin
for %I in (.) do set CurrDirName=%~nxI
rename all.mkv %CurrDirName%.mkv
move %CurrDirName%.mkv ..
cd..

It creates a MKV file with name of the folder (hour), like for example 00.mkv, then goes back to the root of that date.

Then I manually change to 01 and paste the command again. It sucks, but can be pretty fast as you can queue/buffer and don’t need to wait till the joining is done.

Once all the hours are done, and I am in the date (yyyymmdd) folder, I run this.

(for %i in (*.mkv) do @echo file '%i') > mylist.txt
C:\Winapps\ffmpeg\bin\ffmpeg.exe -safe 0 -f concat -i mylist.txt -c copy all.mkv -nostdin
for %I in (.) do set CurrDirName=%~nxI
rename all.mkv %CurrDirName%.mkv
move %CurrDirName%.mkv ..

This takes all the HOUR.mkv files and joins them into a date file yyyymmmdd.mkv.

I’ve used this through and through, just use the folder where your ffmpeg is located instead in the above code

If someone knows how to make this work automatically to just get the end result of one file, it would be outstanding. I think first it would need to check for the list of HOUR folders, then use that list to feed it and change folders accordingly to append all the minute files. Then tie it back to the code that joins all the hour.mkv files together.

I’ve slowly moved off Wyze cams due to the unsupported RTSP implementation which is a MUST for me, I do still have a few cameras that I use, but with beta RTSP (which has been discussed to death in these forums).

The method I use does, because the files are named in numerical order, so they are also appended in that order.

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

  1. 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.
  2. 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.
  3. 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.
  4. 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.

1 Like

By the way, it’s been 3 years since I made a post asking Wyze to fix this… I made this posting because even now, it doesn’t work right in the app and I felt people could use this solution. That said, it isn’t for the non-programmer types. It requires downloading an executable file, placing relevant mp4s together, and creating a batch file, and if things don’t work as well for others as they did for me, troubleshooting. Wyze really needs a solution that is foundationally functional as the Wyze cameras were themselves when they came out!

Tim

Thanks for sharing. People ask about how to do this all the time. In the past I have done this with VLC media player, though I believe they changed their app to work differently from the last time I used it this way. Your post will make for a great walkthrough resource for those who ask how to splice a bunch of SD card recordings together. :+1:

2 Likes