title: Video data hash changes everytime I use `AVMutableComposition` & `AVAssetExportSession` to export even if goes through same steps with no changes
body: <p>Minimum snippet to regenerate. Exports a new <code>exportURL</code> from given <code>videoURL</code>.</p>
  <p>While exporting I am</p>
  <ul>
  <li>Adding the video track</li>
  <li>Adding the audio track</li>
  <li>Keeping the complete time range for export</li>
  </ul>
  <pre class="lang-swift prettyprint-override"><code>
      let asset = AVURLAsset(url: videoURL)
      let mixComposition = AVMutableComposition()
      
      guard let compositionTrack = mixComposition.addMutableTrack(withMediaType: .video, preferredTrackID: kCMPersistentTrackID_Invalid),
          let assetTrack = asset.tracks(withMediaType: .video).first
          else {
              print(&quot;Something is wrong with the asset.&quot;)
              return
      }
  
      do {
          let startTime = .zero
          let endTime = asset.duration
          let timeRange = CMTimeRangeFromTimeToTime(start: startTime, end: endTime)
          try compositionTrack.insertTimeRange(timeRange, of: assetTrack, at: .zero)
  
          // if audio isn't muted in the editor, add audio track from the asset
          if let audioAssetTrack = asset.tracks(withMediaType: .audio).first,
              let compositionAudioTrack = mixComposition.addMutableTrack(withMediaType: .audio, preferredTrackID: kCMPersistentTrackID_Invalid) {
              try compositionAudioTrack.insertTimeRange(timeRange, of: audioAssetTrack, at: .zero)
          }
      } catch {
          print(error)
          return
      }
  
      guard let export = AVAssetExportSession(asset: mixComposition, presetName: videoQuality.exportPreset)
          else {
              print(&quot;Cannot create export session.&quot;)
              onComplete(nil)
              return
      }
      
      let videoName = UUID().uuidString
      let exportURL = URL(fileURLWithPath: NSTemporaryDirectory())
          .appendingPathComponent(videoName)
          .appendingPathExtension(&quot;mp4&quot;)
      
      export.outputFileType = .mp4
      export.outputURL = exportURL
      
      export.exportAsynchronously {
          DispatchQueue.main.async {
              switch export.status {
              case .completed:
                  onComplete(exportURL)
              default:
                  print(&quot;Something went wrong during export.&quot;)
                  print(export.error ?? &quot;unknown error&quot;)
                  break
              }
          }
      }
  </code></pre>
  <p>Now after I have this <code>exportURL</code> can get data from it. And that data is hashed. But even if the same video goes through this same process which does not apply any edit to the video why the hash is changed?</p>
  <p>In case the function is needed which I am using to generate the hash.</p>
  <pre class="lang-swift prettyprint-override"><code>extension Data {
      
      var digest: Data {
          let digestLength = Int(CC_SHA256_DIGEST_LENGTH)
          var hash = [UInt8](repeating: 0, count: digestLength)
          CC_SHA256(bytes, UInt32(count), &amp;hash)
          return Data(bytes: hash, count: digestLength)
      }
      
      var hexString: String {
          let hexString = map { String(format: &quot;%02.2hhx&quot;, $0) }.joined()
          return hexString
      }
  }
  </code></pre>