Tool

DVR/CCTV Raw .h264/.264 File Analyzer: Estimate fps and Resolution, Get the MP4 Conversion Command

If a .h264 or .264 file exported from a DVR or NVR won’t open in your player, or opens but plays like fast-forward or like slow motion, the file is often a ‘raw stream’: picture data strung together with no container. Pick the file and the tool reads the resolution, profile and level written inside it, the frame count and the clues for fps, and builds the ffmpeg command that moves it into an MP4. The file is read only inside this browser.

Choose a .h264 / .264 file

The file is never uploaded. It is only read from start to end inside this browser (the video is not played or decoded). The synthetic sample is a fake byte sequence that matches the structure only; it is not a video.

Why raw files get the speed wrong

A container such as MP4 or MKV holds a timetable that says when each frame should be shown. A raw H.264 stream (Annex B format) has no such table, only chunks of data (NAL units) separated by 00 00 01 start codes. So the player or converter has to decide on its own how many frames per second there are. ffmpeg assumes 25 fps for raw H.264 input unless you say otherwise (the default of the framerate option in the ffmpeg documentation). If a file was actually recorded at 15 fps and is assumed to be 25 fps, the same number of frames goes by in less time, so it looks like fast-forward.

What this tool reads

  • SPS (sequence parameter set): holds the profile, level, resolution (with cropping applied), chroma format and bit depth. The resolution is computed from the macroblock count and the crop values, so a 1080p video comes out as 1080, not 1088.
  • VUI timing: the optional num_units_in_tick and time_scale at the end of the SPS. The fps is time_scale ÷ (2 × num_units_in_tick). Some encoders are known not to include this information, so when it is missing the tool shows ‘none’.
  • Frame count: among slice NAL units (type 1 and 5), the ones with first_mb_in_slice equal to 0 are counted as the start of a frame. A file whose frames are split into several slices is still counted once per frame.
  • IDR count and slice types: show the keyframe interval and whether B-frames are used. They help you locate the IDR positions that serve as starting points when you cut or join a file in the middle.

How to decide the fps

  1. If a VUI value exists, take it as a first hint. A value being present doesn’t guarantee it is right, so check it against step 2.
  2. If you know the actual recording length, frame count ÷ length is the most reliable. You can get the length from the recorder’s event list or from the start and end times in the original file names. If the result is close to a common value such as 15.0 or 25.0, use that value.
  3. If you don’t know the length, look at the playback length for each candidate fps in the table and judge by whether people move at a natural speed. If the camera’s settings screen shows a frame rate, that value is the surest evidence.

Note: a DVR that stores frames only when there is motion doesn’t have a constant number of frames per hour (variable fps). A file like that has the wrong speed in some sections no matter which single fps you convert with. This tool can’t know the time of each frame, so it can’t tell that case apart; the most you can do is guess from whether the fps worked out from the length is far from a common value.

The conversion command explained

ffmpeg -framerate 15 -i "input.264" -c copy "input.mp4"
  • -framerate 15: sets the fps of the raw H.264 input. Put it before the input file.
  • -c copy: moves the picture data into an MP4 box without re-encoding it. There is no quality loss and the size stays almost the same.
  • After converting, check the length with ffprobe. If the length is right, the fps is right too.

If the converted MP4 won’t play on a device, the profile or bit depth may be the cause, so paste the ffprobe output into the playability checker to find out. You can compare the level needed for the resolution and fps with the H.264/HEVC level calculator, and you can see the details of the finished file in the video file info inspector. How long a CCTV system can keep its footage is calculated from this site’s measurements by the CCTV/NVR storage calculator. This analyzer doesn’t deal with bitrate or quality numbers.

Limits worth knowing

  • It reads only raw H.264 (Annex B). HEVC (.265), vendor-specific containers and encrypted files may show no start code or be read wrongly. For a file with a vendor header at the front, it tells you where the first start code is but doesn’t cut the header off automatically.
  • It doesn’t decode the pictures. It looks only at the NAL structure and doesn’t check whether the file is broken in the middle or actually plays.
  • Interlaced video, if it is coded per field, can have its frame count counted at twice the real number.
  • The resolution shown is from the first SPS; if SPS with other resolutions are mixed in, it only warns you.
  • The synthetic sample is a fake byte sequence to show how the tool works, not measured data. It isn’t a result checked against a real DVR file, so play the result yourself after converting.
  • The command is an example. Keep the original file even after converting.