I’ve been creating camera videos a lot on my Android phone. I usually take 4K videos. However, recently the video has been occupying over 100GB size of total 256G. If I don’t fix that, I can store no more things on my OnePlus 7 Pro.
I’ve been thinking if I could select some of the videos and delete others. However, even all my videos/photos have backups on my OneDrive, I still need to watch the videos with my family from time to time. So I don’t want to delete them.
In my first thought, the solutions could be, 1) buy a new phone 2) NAS / Network Attached Storage. However, my phone is functioning so well that I don’t think I could find another phone that could be better (except OP7tPro). And for the second solution, I’ve already got a network disk setup, the performance seems okay. However, it seems not okay to use NAS to watch videos. You know, long VST/VRT, high CIRR, and something VPF. 😔
After several months with this pain in my head, a new idea came up to me. How about re-encoding the videos? Actually, I thought about compression. However, it seems not tolerable when the video is not clear any longer…
Another thought came to me that H.265/HEVC is somehow widely used. How about encode my videos to HEVC as lossless compression? Then I just installed FFmpeg Media Encoder from Google Play, and encoded one of my videos.
And then I was shocked by the result.. A video with 500M size is compressed into 70M. In case the video bit rate is not so good, I compared the videos for almost 10 times. And I don’t see difference… Holly…
So, let’s get started!
On the Phone
Try FFmpeg Media Encoder by your own to see if you could accept the long time for encoding.
Select videos to encode.
However, It seems not very efficient on phone. Why not use my Mac? With my Mac, I could do more scripting and also I could process the video as a batch.
ADB or Network ADB.
brew cask install android-platform-tools to install
For network ADB,
# while connecting the phone to mac adb tcpip 5555 # network adb connect adb connect 192.168.xxx.xxx:5555
Pull the video files to Mac.
adb pull /sdcard/DCIM/Camera/VID_20200202_020202.mp4
brew install ffmpeg to install
ffmpeg -i VID_20200202_020202.mp4 -c:v libx265 -c:a aac VID_20200202_020202_HEVC.mp4 # if you want to customize the parameters, check the ffmpeg manual. man ffmpeg # or just ffmpeg
Restore EXIF metadata with
exiftool to copy original EXIF tags to the new video file.
brew install exiftool to install
exiftool -tagsFromFile VID_20200202_020202.mp4 VID_20200202_020202_HEVC.mp4
Send video file back to phone.
adb push VID_20200202_020202_HEVC.mp4 /sdcard/DCIM/
Now compare these two videos.
Now, it’s been a while since the first encoding. And the result till now is pretty promising. At this moment, I’ve got ~500M of videos files encoded from ~5G original video files.