wkaisertexas / ScreenTimeLapse

Take color-accurate timelapses of your screens and cameras on MacOS
https://apps.apple.com/us/app/timelapze/id6473860445
MIT License
778 stars 25 forks source link

Possible to make recording size even smaller? #25

Closed wzulfikar closed 7 months ago

wzulfikar commented 8 months ago

Not really an issue, just wanted to bring reference if there's possibility to make the recording output smaller.

https://github.com/wkaisertexas/ScreenTimeLapse/assets/7823011/595e5b4d-5ffd-4722-97a2-a575d864f720

After optimizing with ffmpeg (no quality drop, imo): 5.6 mb

https://github.com/wkaisertexas/ScreenTimeLapse/assets/7823011/4bf2b7f5-c84a-40c1-ae76-b6c91b7fec68

ffmpeg command:

ffmpeg \
  -i timelapze-example-repo-1-minute.mp4 \
  -movflags faststart \
  -pix_fmt yuv420p \
  -vf 'scale=trunc(iw/2)*2:trunc(ih/2)*2' \
  timelapze-example-repo-1-minute.optimized.mp4

Note: this 1 minute recording example might not be the best example because it only reduced 18.8 mb to 5.6 (~3x smaller). But I had 1 minute 55 seconds recording that has 141.4 mb in size and reduced to 28.3 mb after optimization (~5x smaller!).

wkaisertexas commented 8 months ago

Yes. The answer is yes. Space can be saved.

I used a ridiculously large setting present for 8k video in my configuration.

From VideoConfiguration.swift,

var preset : AVOutputSettingsPreset {
    switch self {
        case .h264_sRGB : return .hevc3840x2160
        case .hevc_displayP3 : return .hevc7680x4320
    }
}

I need a way to find a more reasonable configuration for bitrate.

ffmpeg \
  -i timelapze-example-repo-1-minute.mp4 \
  -movflags faststart \
  -pix_fmt yuv420p \
  -vf 'scale=trunc(iw/2)*2:trunc(ih/2)*2' \
  timelapze-example-repo-1-minute.optimized.mp4

However, your command does save some space by changing from a 10-bit to an 8-bit pixel format. This can occasionally cause issues with how colors are presented.

wzulfikar commented 8 months ago

I see, good to know about the pixel format. Thanks!

wkaisertexas commented 8 months ago

I think this is a good issue for the next release. The pixel format difference should only account for like 20% of the file size difference, however.

wkaisertexas commented 7 months ago

I added a feature to not record frames which have not changed. Thanks!