]> git.sesse.net Git - ffmpeg/commitdiff
examples/encode_video: only add sequence end code for mpeg1/2 video
authorJun Zhao <barryjzhao@tencent.com>
Mon, 5 Aug 2019 04:53:55 +0000 (12:53 +0800)
committerJun Zhao <barryjzhao@tencent.com>
Thu, 8 Aug 2019 09:58:50 +0000 (17:58 +0800)
Only add sequence end code for mpeg1/mpeg2 video, or else use the encoder
libx264 or libx265 in this sample, decoding the output file will get
unknow NALU type error.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
doc/examples/encode_video.c

index 6731b2ad19bf1a29d52e93797d5bb1e1405ddeef..d9ab409908283708104bc8432a71d46a36346c84 100644 (file)
@@ -186,7 +186,8 @@ int main(int argc, char **argv)
     encode(c, NULL, pkt, f);
 
     /* add sequence end code to have a real MPEG file */
-    fwrite(endcode, 1, sizeof(endcode), f);
+    if (codec->id == AV_CODEC_ID_MPEG1VIDEO || codec->id == AV_CODEC_ID_MPEG2VIDEO)
+        fwrite(endcode, 1, sizeof(endcode), f);
     fclose(f);
 
     avcodec_free_context(&c);