[FFmpeg-devel] [PATCH] read sample aspect ratio from video stream if not known from container

Paweł Kołodziej Pawel.Kolodziej
Mon Feb 9 16:55:53 CET 2009


Hello,

File 
http://derchris.eu/ccc/25C3/video_h264_720x576/25c3-2596-en-swf_and_the_malware_tragedy.mp4
(h264 in mp4) has SampleAspectRato 5:4 but information about it is not
stored in container but in video stream (VUI). This information is not
read by ffmpeg[1] and this results in output stream with SAR 1:1
(wrong).

Attached patch fix it - if SAR is not known from container then it's
read from video stream. I hope it does not break anything. 

Regards,
Pawel

[1] I've used command: 
?./ffmpeg_g -y -i 25c3-2596-en-swf_and_the_malware_tragedy.mp4  
-t 1  -vcodec libx264 output.mp4
-------------- next part --------------
Index: libavformat/utils.c
===================================================================
--- libavformat/utils.c	(wersja 17098)
+++ libavformat/utils.c	(kopia robocza)
@@ -1833,7 +1833,7 @@
             return 0;
         break;
     case CODEC_TYPE_VIDEO:
-        val = enc->width && enc->pix_fmt != PIX_FMT_NONE;
+        val = enc->width && enc->pix_fmt != PIX_FMT_NONE && enc->sample_aspect_ratio.num;
         break;
     default:
         val = 1;



More information about the ffmpeg-devel mailing list