Software⏱️ 3 min read📅 2026-06-11

How to Fix: FFMPEG: Error splitting the input into NAL units / Timestamps are unset in a packet for stream 0 when changing from avi to mp4

FFmpeg error fixing for NAL unit splitting and timestamp issues in converting AVI to MP4.

Quick Answer: Use the -an option with -c:v copy to force re-encoding and fix the issue.

FFmpeg is unable to convert AVI files to MP4 due to an error in splitting the input into NAL units. This issue affects users who want to change the container of a video acquired from an NVR using FFmpeg.

This error can be frustrating for users as it prevents their output video from being playable by popular media players like VLC or QuickTime.

🔍 Why This Happens

  • The primary reason for this error is that AVI files contain a different format than MP4. Specifically, the timestamp information in the video stream is not properly encoded.
  • Another possible cause is that the input file contains corrupted or invalid data, which can lead to incorrect NAL unit splitting.

🔧 Proven Troubleshooting Steps

Using FFmpeg with the -c:v copy option

  1. Step 1: To fix this issue, use the following command: ffmpeg -i input.avi -c:v copy output.mp4. This option tells FFmpeg to copy the video stream without re-encoding it.
  2. Step 2: This method works because AVI files typically contain a single video stream with timestamp information encoded in the file's header. MP4 files, on the other hand, require separate timestamp information for each NAL unit.
  3. Step 3: By using the -c:v copy option, FFmpeg can preserve the original timestamp information and avoid splitting the input into NAL units.

Re-encoding the video stream with a different preset

  1. Step 1: Alternatively, you can re-encode the video stream using a different preset that is compatible with MP4. For example: ffmpeg -i input.avi -c:v libx264 -crf 18 output.mp4.
  2. Step 2: This method works because it allows FFmpeg to re-encode the video stream in a format that is compatible with MP4, which can help resolve issues with NAL unit splitting.

💡 Conclusion

To summarize, FFmpeg's error splitting the input into NAL units can be resolved by using the -c:v copy option or re-encoding the video stream with a different preset. By following these steps, you should be able to successfully convert your AVI file to MP4 and play it in popular media players like VLC or QuickTime.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions