How to backup your last time with Xiaomi camera

I bought a Xiaomi camera, with 32GB microSD, it can record about 10 days, but it saves data to many folders, per folder has many files, the length of file less than 60 seconds. When I backup data from microSD to hard disk, it is difficult to watch because I must open file many many time.
So, I want to merge all file in the folder to one file and upload to youtube to easy to access. I have to code something.
The first, I install FFmpeg to my Mac, it is not easy as installing FFmpeg on Ubuntu, but I did. That’s ok, FFmpeg saves my life :p. This is my code:


import os
def list_file(path):
list = os.listdir(path)
return list
base_path = "/Users/phihongthai/Documents/Yicam/"
def create_file(list, path):
file_path = path + "ffmpeg-sound.txt"
with open(file_path, "w") as f:
for file in list:
if str(file).endswith("mp4"):
f.write("file " + file + "\n")
list_dir = list_file(base_path)
for dir in list_dir:
if not str(dir).startswith("."):
path = base_path + dir + "/"
#get list file mp4 in folder
list = list_file(path)
#write list file mp4 to a txt file
create_file(list, path)
#create command
out_name = dir + ".mp4"
cmd = "/usr/local/bin/ffmpeg -f concat -i ffmpeg-sound.txt -c copy " + out_name
print (path)
cmd1 = "cd " + path + " && " + cmd + " && mv " + out_name + " ../"
#run command to merge files to a file
os.system(cmd1)
#call API to upload to youtube

view raw

merge_mp4.py

hosted with ❤ by GitHub

1 thought on “How to backup your last time with Xiaomi camera”

  1. 1 cách làm ko cần code trên Windows: search 1 phát *.mp4, cut rồi paste ra 1 folder, dùng freemake hoặc mkvtoolnix combine lại là xong :))

    Reply

Leave a Reply