docstr: Saving video as MP4 properly keep all the frames
docstr_tok: ["Saving","video","as","MP4","properly","keep","all","the","frames"]
code: def test_video_num_frames(self, framerate, resolution, format):
      """Saving video as MP4 properly keep all the frames"""
  
      ext = "mp4"
      filename = f"test.{ext}"
      h, w = resolution
  
      # Write data
      dst = self.get_temp_path(filename)
      s = torchaudio.io.StreamWriter(dst=dst, format=ext)
      s.add_video_stream(
          frame_rate=framerate, height=h, width=w, format=format
      )
      chunk = torch.stack(
          [
              torch.full((3, h, w), i, dtype=torch.uint8)
              for i in torch.linspace(0, 255, 256)
          ]
      )
      with s.open():
          s.write_video_chunk(0, chunk)
  
      # Load data
      s = torchaudio.io.StreamReader(src=self.get_temp_path(filename))
      print(s.get_src_stream_info(0))
      s.add_video_stream(-1)
      s.process_all_packets()
      (saved,) = s.pop_chunks()
  
      assert saved.shape == chunk.shape
  
      if format == "yuv444p":
          # The following works if encoder_format is also yuv444p.
          # Otherwise, the typical encoder format is yuv420p which incurs some data loss,
          # and assertEqual fails.
          #
          # This is the case for libx264 encoder, but it's not always available.
          # ffmpeg==4.2 from conda-forge (osx-arm64) comes with it but ffmpeg==5.1.2 does not.
          # Since we do not have function to check the runtime availability of encoders,
          # commenting it out for now.
  
          # self.assertEqual(saved, chunk)
          pass
  
imports: import io
  import math
  import torch
  import torchaudio
  from parameterized import parameterized, parameterized_class
  from torchaudio.io import CodecConfig, StreamReader, StreamWriter
  from torchaudio_unittest.common_utils import get_asset_path, get_sinusoid, nested_params, rgb_to_yuv_ccir, skipIfNoFFmpeg, skipIfNoModule, TempDirMixin, TorchaudioTestCase
  from .common import lt42
label_desc: Use image node_id 4 for calling the StreamWriterCorrectnessTest obj's underlying member method code with example usage: obj.test_video_num_frames(framerate, resolution, format) without return types