Dev.to Security 🔐 Cybersecurity 👁 0 📖 8 min read

H.264 or H.265 for an Offline Phone Security Camera? Half the Storage, or Footage You Can Actually Play

If you turn an old Android phone into a security camera with no cloud and no subscription, every hour of video lands on the phone's own storage. Sooner or later you find a setting that promises to fit roughly twice as mu

If you turn an old Android phone into a security camera with no cloud and no subscription, every hour of video lands on the phone's own storage. Sooner or later you find a setting that promises to fit roughly twice as much footage in the same space: H.265, also called HEVC, sometimes labelled "High efficiency video".

It is a fair promise, and it has a catch you only meet on the day you need the footage. This guide covers both sides, using what Android's compatibility rules, Mozilla's codec documentation and Microsoft's store listing actually say, so you can choose on purpose instead of by default.

The short answer

  • Choose H.264 (AVC) if footage needs to play on any PC, any browser, or be handed to someone else without fuss. It is the format every Android phone must be able to record and almost everything can play.
  • Choose H.265 (HEVC) only if storage is your real limit, your phone actually offers a hardware HEVC encoder, and you have checked that every device you will watch on can decode it.
  • Whatever you pick, test it once: record five minutes, copy the file to the computer you would use in an emergency, and press play. That one test settles more than any spec sheet.

Why HEVC is tempting on a budget phone

On a phone camera running offline, storage is the bill you pay instead of a cloud subscription. Mozilla's web codec guide summarises the trade plainly: "Theoretically, HEVC can achieve compressed file sizes half that of AVC but with comparable image quality." The word "theoretically" matters. Real savings depend on the scene and the encoder; a cheap phone's hardware encoder is not tuned like a studio one. But even a partial saving changes the arithmetic on a 32 GB or 64 GB card.

Here is the storage maths at three bitrates (computed, decimal GB):

Video bitrate Per hour Per 24 h Days on a 64 GB card Minutes per FAT32 file (stops at 95% of 4 GiB)
8 Mbps 3.6 GB 86.4 GB 0.7 68
4 Mbps 1.8 GB 43.2 GB 1.5 136
2 Mbps 0.9 GB 21.6 GB 3.0 272

If HEVC lets you hold similar quality at half the bitrate, you move down one row: twice the days before the card fills, and twice the minutes before a single file hits the FAT32 limit we covered in Why Does a Phone Security Camera Recording Stop at Almost 4 GB?. Fewer bytes written per day is also gentler on a cheap microSD card's write endurance, which is the weak part of a 24/7 setup (more in The microSD Card Is the Weakest Part of a 24/7 Phone Camera).

That is the whole case for HEVC. Now the other half.

What Android guarantees: every phone records H.264, not every phone records H.265

Android's Compatibility Definition Document (CDD) is the rulebook a manufacturer must follow to ship Google's apps. The current Android 16 CDD lists the video formats a handheld device must be able to encode (record) and make available to third-party apps:

  • H.264 AVC
  • VP8
  • AV1

H.265 HEVC is not on the encoding list. It is on the list of formats every handheld must be able to decode (play back), alongside H.264, MPEG-4 SP, VP8, VP9 and AV1.

So on any certified Android phone, playing an HEVC file back on the phone itself is guaranteed. Recording one is not. Many phones do have a hardware HEVC encoder, which is why camera apps offer the toggle, but it is the manufacturer's choice. On an older or entry-level phone, the option may be missing, or it may exist only as a slower software path that makes the phone work harder and warmer.

For developers: MediaRecorder.VideoEncoder.HEVC has existed since API level 24 (Android 7.0), but the constant existing is not the same as the device having an encoder for it. Ask the device: MediaCodecList(MediaCodecList.REGULAR_CODECS).findEncoderForFormat(MediaFormat.createVideoFormat(MediaFormat.MIMETYPE_VIDEO_HEVC, width, height)) returns null when there is no encoder for that format and size. Check MediaCodecInfo.isHardwareAccelerated() (API 29+) before making HEVC a default on a phone that will run all night.

Where HEVC footage gets stuck: the playback side

The recording is only useful if you can watch it. This is where H.264 and H.265 really differ.

On a Windows PC

Windows does not always play HEVC out of the box. Microsoft sells the codec separately as HEVC Video Extensions in the Microsoft Store; the US listing shows $0.99, and prices vary by region. Microsoft's own support answers describe it as an optional paid add-on because HEVC is a licensed technology.

Mozilla's support pages note that recent Windows 11 versions (22H2, 23H2, 24H2) include HEVC support by default, while several Windows 10 builds and Windows 11 21H2 need the extension installed manually. Hardware support also varies by graphics chip.

For a family that uses an old phone as a camera precisely because they do not want to pay for anything, "buy a codec before you can see what happened" is a real problem, especially at 2 a.m. after something has happened. The free workaround most people end up using is VLC, which ships its own decoders and plays HEVC on Windows, macOS, Linux and Android without the Store extension.

In a web browser

If you watch your camera, or replay clips, in a browser, browser support decides everything. From Mozilla's codec guide:

  • Chrome supports HEVC for devices with hardware support on Windows 8+, Linux and ChromeOS, and for all devices on macOS Big Sur 11+ and Android 5.0+. (Hardware HEVC decoding arrived in Chrome 107.)
  • Edge supports HEVC on Windows 10 1709+ for devices with hardware support when the HEVC Video Extensions are installed.
  • Firefox enables HEVC on Windows from version 134 (hardware where supported, or software if the user pays for and installs the extension), macOS from 136, Linux from 137, and Android from 137 (hardware only).
  • Safari supports HEVC on macOS High Sierra or later.

Notice how often "with hardware support" appears. An older office laptop or a cheap Windows tablet may simply show a black box or an error for an HEVC file, while the same browser plays H.264 without complaint. H.264 is the format that plays almost everywhere.

When you hand footage to someone else

If you ever need to pass a clip to a landlord, an insurer, a shop owner or the police, you do not control what they open it with. A file that plays on your phone and fails on their computer costs time exactly when time matters. Formal archives are cautious here too: as we found in The National Archives Will Take Phone Video as a Permanent Record, that list includes MP4 with H.264 inside it, and HEVC does not appear in its digital video table at all.

If you do record in HEVC, keep a way to make an H.264 copy of an important clip. With ffmpeg on a computer:

ffmpeg -i clip_hevc.mp4 -c:v libx264 -crf 20 -preset medium -c:a copy clip_h264.mp4

That re-encodes the video track to H.264 and copies the audio unchanged. The copy will be larger, which is the point: it is the version for other people.

How to check what your phone is actually recording

The file extension does not tell you. An .mp4 can contain H.264 or H.265. Three easy ways to find out:

  1. VLC on a computer: open the file, then Tools → Codec Information. It will say H264 - MPEG-4 AVC (part 10) or MPEG-H Part2/HEVC (H.265).
  2. MediaInfo (free, Windows/macOS/Linux/Android): open the file and read the Format line under Video: AVC or HEVC.
  3. ffprobe, if you already use ffmpeg:
ffprobe -v error -select_streams v:0 -show_entries stream=codec_name,bit_rate -of default=nw=1 clip.mp4

It prints codec_name=h264 or codec_name=hevc. Divide the file size by its duration to see the real bitrate your phone is using, then use the table above to work out how many days your card will last.

A simple decision for a no-cloud camera

Use H.264 if any of these are true:

  • The phone is older or entry-level, or you are not sure it has a hardware HEVC encoder.
  • You watch footage on a Windows PC, an older laptop, or a browser you have not tested.
  • Other people in the house or shop need to open clips without help.
  • You may need to share clips with someone outside the house.

Consider H.265 if all of these are true:

  • Storage is the thing that actually runs out first (small card, long retention).
  • Your phone offers HEVC as a normal recording option and stays cool recording with it for an hour.
  • You tested a file on every device you would use to watch, including the emergency one.
  • You know how to make an H.264 copy when you need to share.

Either way:

  • Lower the bitrate or resolution before switching codec. A fixed camera looking at a hallway rarely needs 4K. 1080p or 720p at a modest bitrate is often the bigger, safer storage win.
  • Keep the phone on a charger in a ventilated spot. Continuous encoding is real, steady work for any phone.
  • Copy important clips off the phone promptly. Our guide How to Get Recordings Off an Old-Phone Security Camera Without a Cloud Account covers the offline ways to do it.

Where Background Camera RemoteStream fits

Background Camera RemoteStream is the app we build for this kind of setup: it turns an Android phone into a camera that keeps recording with the screen off, saves video locally on the phone with no cloud account, and runs a built-in web server so you can watch the live view from a browser on the same Wi-Fi, no internet needed. If you want to watch from away, it can also stream to YouTube Live.

The codec question in this article applies to any phone camera setup, including ours. The test we recommend is the same: record a short clip with your real settings, copy it to the computer you would use on a bad day, and make sure it plays before you rely on it.

Sources

  • Android 16 Compatibility Definition, section 2.2.2 (handheld media requirements: video encoding and decoding lists) — source.android.com/docs/compatibility/16/android-16-cdd
  • MDN Web Docs, Web video codec guide, HEVC (H.265) section and browser compatibility notes — developer.mozilla.org/en-US/docs/Web/Media/Guides/Formats/Video_codecs
  • Microsoft Store, HEVC Video Extensions listing — microsoft.com/en-us/p/hevc-video-extensions/9nmzlz57r3t7
  • Mozilla Support, Audio and video files in Firefox (Windows versions with built-in HEVC support) — support.mozilla.org/en-US/kb/audio-and-video-firefox
  • Android Developers, MediaRecorder.VideoEncoder, MediaCodecList, MediaCodecInfo reference pages

More about the app and how it works offline: superfunicular.com.

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.