[FFmpeg-user] aspect ratio changes in the middle of the stream

Michael Kasch - SmartCast kasch at smartcast.de
Thu Sep 5 18:21:19 CEST 2013


Hi,
i'm recording some TV Streams into *.ts files. Afterwards they will be encoded with ffmpeg+x264 into a h246 file. The Problem now is that I don't know, the aspect ratio currently used in the streams.
In the end all streams should be 16:9 so 4:3 has to be padded.

I found the following command doing the job, if the aspect ratio remains the same the whole video:

ffmpeg  -y -i test.ts  -vf "yadif, scale=iw*sar:ih , pad=max(iw\,ih*(16/9)):ow/(16/9):(ow-iw)/2:(oh-ih)/2" -aspect 16:9 test.mp4

But often I have the situation that the ratio changes in the middle of a stream. 4:3 Film with 16:9 commercials, or first 4:3 and next show 16:9. Is there a solution to get ffmpeg or x264 to recheck the aspect ratio every i-frame?

Best Regard, Michael



More information about the ffmpeg-user mailing list