Last active
February 5, 2025 01:51
-
-
Save priintpar/f7a56af8977206e9f45b486f767b02ac to your computer and use it in GitHub Desktop.
Convert many .media files created by security cameras and babyphones to a single .mkv file using ffmpeg on Macos or Linux. Even skips defective files.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find . -type f -name '*media' >> unsortedlist.txt | |
sort unsortedlist.txt >> sortedlist.txt | |
while read line; do ffprobe $line; if [ $? = "1" ]; then echo $line; fi; done < sortedlist.txt >> corruptfiles.txt | |
awk 'NR==FNR{a[$0];next} !($0 in a)' corruptfiles.txt sortedlist.txt > temp; mv temp sortedlist.txt | |
while read line; do echo "file '$line'"; done < sortedlist.txt >> sortedlistwithoutcorruptfiles.txt | |
ffmpeg -f concat -safe 0 -i sortedlistwithoutcorruptfiles.txt -c copy outputvideo.mkv | |
rm unsortedlist.txt sortedlist.txt sortedlistwithoutcorruptfiles.txt corruptfiles.txt |
Video link is not working for me. There is player but without video
The convertion code doesn't work when embedded audio is encoded in NHNT format typical for cloud cameras, but not usually recognised by default config ffprobe.
You need to buy mac
Irrelevant for this error. Further, the code purges present in the media folder structure "non-media" files with audio codec info, and fails to identify in the targeted day folder structure correct start & sequence & stop fragments belonging to the same motion event video. Too simplistic to be universally useful.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm curious if you were actually able to convert the .media file while retaining the audio, and if you could send it back to me. If this works, I would consider borrowing a Mac to perform the conversions instead of purchasing one.