diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 6ae2391480ec401aa6493bfad88eae3930ad6b07..1a54c1ad026c713708f3b3bde118aa69bdbde65c 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -1177,7 +1177,7 @@ int ff_check_h264_startcode(AVFormatContext *s, const AVStream *st, const AVPack
         if (!st->nb_frames) {
             av_log(s, AV_LOG_ERROR, "H.264 bitstream malformed, "
                    "no startcode found, use the h264_mp4toannexb bitstream filter (-bsf h264_mp4toannexb)\n");
-            return AVERROR(EINVAL);
+            return AVERROR_INVALIDDATA;
         }
         av_log(s, AV_LOG_WARNING, "H.264 bitstream error, startcode missing\n");
     }