diff --git a/media/formats/mp4/box_definitions.cc b/media/formats/mp4/box_definitions.cc
index 62c49ad1a52e6..9a4dcca3bc737 100644
--- a/media/formats/mp4/box_definitions.cc
+++ b/media/formats/mp4/box_definitions.cc
@@ -2,10 +2,9 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#ifdef UNSAFE_BUFFERS_BUILD
-// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
-#pragma allow_unsafe_buffers
-#endif
+#include "base/containers/auto_spanification_helper.h"
+
+
 
 #include "media/formats/mp4/box_definitions.h"
 
@@ -17,6 +16,7 @@
 #include "base/containers/span.h"
 #include "base/containers/span_writer.h"
 #include "base/logging.h"
+#include "base/numerics/byte_conversions.h"
 #include "base/numerics/safe_math.h"
 #include "base/strings/string_number_conversions.h"
 #include "build/build_config.h"
@@ -306,9 +306,9 @@ bool SampleEncryptionEntry::Parse(BufferReader* reader,
   // the constant IV must be ensured by the caller.
   RCHECK(iv_size == 0 || iv_size == 8 || iv_size == 16);
 
-  memset(initialization_vector, 0, sizeof(initialization_vector));
+  std::ranges::fill(initialization_vector, 0);
   for (uint8_t i = 0; i < iv_size; i++)
-    RCHECK(reader->Read1(initialization_vector + i));
+    RCHECK(reader->Read1(&initialization_vector[i]));
 
   if (!has_subsamples) {
     subsamples.clear();
@@ -406,9 +406,9 @@ bool TrackEncryption::Parse(BoxReader* reader) {
     if (default_iv_size == 0) {
       RCHECK(reader->Read1(&default_constant_iv_size));
       RCHECK(default_constant_iv_size == 8 || default_constant_iv_size == 16);
-      memset(default_constant_iv, 0, sizeof(default_constant_iv));
+      std::ranges::fill(default_constant_iv, 0);
       for (uint8_t i = 0; i < default_constant_iv_size; i++)
-        RCHECK(reader->Read1(default_constant_iv + i));
+        RCHECK(reader->Read1(&default_constant_iv[i]));
     } else {
       RCHECK(default_iv_size == 8 || default_iv_size == 16);
     }
@@ -1547,11 +1547,13 @@ bool OpusSpecificBox::Parse(BoxReader* reader) {
 #error The code below assumes little-endianness.
 #endif
 
-  memcpy(&extradata[OPUS_EXTRADATA_SKIP_SAMPLES_OFFSET], &codec_delay_in_frames,
-         sizeof(codec_delay_in_frames));
-  memcpy(&extradata[OPUS_EXTRADATA_SAMPLE_RATE_OFFSET], &sample_rate,
-         sizeof(sample_rate));
-  memcpy(&extradata[OPUS_EXTRADATA_GAIN_OFFSET], &gain_db, sizeof(gain_db));
+  auto extradata_span = base::span(extradata);
+  extradata_span.subspan(OPUS_EXTRADATA_SKIP_SAMPLES_OFFSET)
+      .copy_from(base::U16ToLittleEndian(codec_delay_in_frames));
+  extradata_span.subspan(OPUS_EXTRADATA_SAMPLE_RATE_OFFSET)
+      .copy_from(base::U32ToLittleEndian(sample_rate));
+  extradata_span.subspan(OPUS_EXTRADATA_GAIN_OFFSET)
+      .copy_from(base::I16ToLittleEndian(gain_db));
 
   channel_count = extradata[OPUS_EXTRADATA_CHANNELS_OFFSET];
 
@@ -2312,9 +2314,9 @@ bool CencSampleEncryptionInfoEntry::Parse(BoxReader* reader) {
     if (iv_size == 0) {
       RCHECK(reader->Read1(&constant_iv_size));
       RCHECK(constant_iv_size == 8 || constant_iv_size == 16);
-      memset(constant_iv, 0, sizeof(constant_iv));
+      std::ranges::fill(constant_iv, 0);
       for (uint8_t i = 0; i < constant_iv_size; i++)
-        RCHECK(reader->Read1(constant_iv + i));
+        RCHECK(reader->Read1(&constant_iv[i]));
     } else {
       RCHECK(iv_size == 8 || iv_size == 16);
     }
diff --git a/media/formats/mp4/box_definitions.h b/media/formats/mp4/box_definitions.h
index c64ab171a2ac4..821684e0b1ad1 100644
--- a/media/formats/mp4/box_definitions.h
+++ b/media/formats/mp4/box_definitions.h
@@ -12,6 +12,7 @@
 #include <string>
 #include <vector>
 
+#include <array>
 #include "base/compiler_specific.h"
 #include "base/time/time.h"
 #include "media/base/decrypt_config.h"
@@ -102,7 +103,7 @@ struct MEDIA_EXPORT SampleEncryptionEntry {
   // anywhere.
   bool GetTotalSizeOfSubsamples(size_t* total_size) const;
 
-  uint8_t initialization_vector[kInitializationVectorSize];
+  std::array<uint8_t, kInitializationVectorSize> initialization_vector;
   std::vector<SubsampleEntry> subsamples;
 };
 
@@ -143,7 +144,7 @@ struct MEDIA_EXPORT TrackEncryption : Box {
   uint8_t default_crypt_byte_block;
   uint8_t default_skip_byte_block;
   uint8_t default_constant_iv_size;
-  uint8_t default_constant_iv[kInitializationVectorSize];
+  std::array<uint8_t, kInitializationVectorSize> default_constant_iv;
 };
 
 struct MEDIA_EXPORT SchemeInfo : Box {
@@ -499,7 +500,7 @@ struct MEDIA_EXPORT CencSampleEncryptionInfoEntry {
   uint8_t crypt_byte_block;
   uint8_t skip_byte_block;
   uint8_t constant_iv_size;
-  uint8_t constant_iv[kInitializationVectorSize];
+  std::array<uint8_t, kInitializationVectorSize> constant_iv;
 };
 
 struct MEDIA_EXPORT SampleGroupDescription : Box {  // 'sgpd'.
diff --git a/media/formats/mp4/track_run_iterator.cc b/media/formats/mp4/track_run_iterator.cc
index dbc4fcaba5932..bcce3c2a1536c 100644
--- a/media/formats/mp4/track_run_iterator.cc
+++ b/media/formats/mp4/track_run_iterator.cc
@@ -516,10 +516,12 @@ bool TrackRunIterator::Init(const MovieFragment& moof) {
                 index == 0 ? track_encryption->default_constant_iv_size
                            : info_entry->constant_iv_size;
             RCHECK(constant_iv_size != 0);
-            const uint8_t* constant_iv =
-                index == 0 ? track_encryption->default_constant_iv
-                           : info_entry->constant_iv;
-            memcpy(entry.initialization_vector, constant_iv, constant_iv_size);
+            auto constant_iv_span =
+                index == 0 ? base::span(track_encryption->default_constant_iv)
+                           : base::span(info_entry->constant_iv);
+            base::span(entry.initialization_vector)
+                .first(constant_iv_size)
+                .copy_from(constant_iv_span.first(constant_iv_size));
           }
         }
       }
@@ -740,8 +742,8 @@ std::unique_ptr<DecryptConfig> TrackRunIterator::GetDecryptConfig() {
     SampleEncryptionEntry sample_encryption_entry;
     if (ApplyConstantIv(sample_idx, &sample_encryption_entry)) {
       std::string iv(reinterpret_cast<const char*>(
-                         sample_encryption_entry.initialization_vector),
-                     std::size(sample_encryption_entry.initialization_vector));
+                         sample_encryption_entry.initialization_vector.data()),
+                     sample_encryption_entry.initialization_vector.size());
       switch (run_itr_->encryption_scheme) {
         case EncryptionScheme::kUnencrypted:
           return nullptr;
@@ -762,8 +764,8 @@ std::unique_ptr<DecryptConfig> TrackRunIterator::GetDecryptConfig() {
   const SampleEncryptionEntry& sample_encryption_entry =
       run_itr_->sample_encryption_entries[sample_idx];
   std::string iv(reinterpret_cast<const char*>(
-                     sample_encryption_entry.initialization_vector),
-                 std::size(sample_encryption_entry.initialization_vector));
+                     sample_encryption_entry.initialization_vector.data()),
+                 sample_encryption_entry.initialization_vector.size());
 
   size_t total_size = 0;
   if (!sample_encryption_entry.subsamples.empty() &&
@@ -823,16 +825,19 @@ bool TrackRunIterator::ApplyConstantIv(size_t sample_index,
                                        SampleEncryptionEntry* entry) const {
   DCHECK(IsSampleEncrypted(sample_index));
   uint32_t index = GetGroupDescriptionIndex(sample_index);
-  const uint8_t constant_iv_size =
-      index == 0
-          ? track_encryption().default_constant_iv_size
-          : GetSampleEncryptionInfoEntry(*run_itr_, index)->constant_iv_size;
-  RCHECK(constant_iv_size != 0);
-  const uint8_t* constant_iv =
-      index == 0 ? track_encryption().default_constant_iv
-                 : GetSampleEncryptionInfoEntry(*run_itr_, index)->constant_iv;
-  RCHECK(constant_iv != nullptr);
-  memcpy(entry->initialization_vector, constant_iv, kInitializationVectorSize);
+  if (index == 0) {
+    const auto& tenc = track_encryption();
+    RCHECK(tenc.default_constant_iv_size != 0);
+    base::span(entry->initialization_vector)
+        .copy_from(tenc.default_constant_iv);
+  } else {
+    const CencSampleEncryptionInfoEntry* entry_info =
+        GetSampleEncryptionInfoEntry(*run_itr_, index);
+    RCHECK(entry_info);
+    RCHECK(entry_info->constant_iv_size != 0);
+    base::span(entry->initialization_vector)
+        .copy_from(entry_info->constant_iv);
+  }
   return true;
 }
 
diff --git a/media/formats/mp4/track_run_iterator_unittest.cc b/media/formats/mp4/track_run_iterator_unittest.cc
index cb00b0cb7037c..05866a3ed8055 100644
--- a/media/formats/mp4/track_run_iterator_unittest.cc
+++ b/media/formats/mp4/track_run_iterator_unittest.cc
@@ -634,7 +634,7 @@ class TrackRunIteratorTest : public testing::Test {
     sinf->info.track_encryption.default_crypt_byte_block = 1;
     sinf->info.track_encryption.default_skip_byte_block = 9;
     sinf->info.track_encryption.default_constant_iv_size = 16;
-    memcpy(sinf->info.track_encryption.default_constant_iv, kIv3.data(), 16);
+    base::span(sinf->info.track_encryption.default_constant_iv).copy_from(kIv3);
     sinf->info.track_encryption.default_kid.assign(
         kKeyId.data(),
         base::span<const uint8_t>(kKeyId).subspan(std::size(kKeyId)).data());
@@ -647,20 +647,20 @@ class TrackRunIteratorTest : public testing::Test {
     track_cenc_group.entries[0].crypt_byte_block = 1;
     track_cenc_group.entries[0].skip_byte_block = 9;
     track_cenc_group.entries[0].constant_iv_size = 16;
-    memcpy(track_cenc_group.entries[0].constant_iv, kIv4.data(), 16);
+    base::span(track_cenc_group.entries[0].constant_iv).copy_from(kIv4);
 
     frag->sample_group_description.entries[1].iv_size = 0;
     frag->sample_group_description.entries[1].crypt_byte_block = 1;
     frag->sample_group_description.entries[1].skip_byte_block = 9;
     frag->sample_group_description.entries[1].constant_iv_size = 16;
-    memcpy(frag->sample_group_description.entries[1].constant_iv, kIv5.data(),
-           16);
+    base::span(frag->sample_group_description.entries[1].constant_iv)
+        .copy_from(kIv5);
     frag->sample_group_description.entries[2].iv_size = 0;
     frag->sample_group_description.entries[2].crypt_byte_block = 1;
     frag->sample_group_description.entries[2].skip_byte_block = 9;
     frag->sample_group_description.entries[2].constant_iv_size = 16;
-    memcpy(frag->sample_group_description.entries[2].constant_iv, kIv5.data(),
-           16);
+    base::span(frag->sample_group_description.entries[2].constant_iv)
+        .copy_from(kIv5);
   }
 
   void AddSampleEncryptionCbcs(TrackFragment* frag) {
