1

I have a source video (mpeg2video) which I'm transcoding to x264. The source contains 2 different programs recorded from TV. One is in 4:3 AR and the other 16:9 AR. When I play the source file through VLC the player correctly changes size to show the video at the correct AR. So far so good.

When I transcode the conversion process auto detects the AR from the first few frames and then transcodes the whole video using this AR. If the 16:9 section comes first then the whole conversion is done in 16:9 and the 4:3 section looks stretch horizontally. If the 4:3 section is at the start of the source file then the whole transcode is done in 4:3 and the 16:9 section looks squashed horizontally.

No black bars are ever visible.

Here's my command:

nice -n 17 ffmpeg -i source.mpg -acodec libfaac -ar 48000 -ab 192k -async 1 -copyts -vcodec libx264 -b 1250k -threads 2 -level 31 -map 0:0 -map 0:1 -map 0:2 -scodec copy -deinterlace output.mkv

I don't fully understand what's going on. How do I get the same 'change in AR' mid video in the output file that I have in the input video?

andyvn22
  • 14,696
  • 1
  • 52
  • 74
kingrolo
  • 2,857
  • 2
  • 16
  • 11

1 Answers1

0

I don't think ffmpeg is designed to do that midway. You will have to write your own application using libav for it. The simpler way would be create two chunks of video that you combine.

EDIT: The best way to deal with it is if you can detect the change of AR yourself and transcode the two segments seperately and join them.

EDIT2: Use ffmpeg itself to chunk the video, demux anything you want and mux it back again. It should work fine. You needn't use avidemux.

av501
  • 6,645
  • 2
  • 23
  • 34
  • oh no. i hoped the solution would be more straight forward. The irony is that I actually wanted to split the file first and transcode it second, but avidemux absolutely refuses to maintain audio sync when handling the source file even though all other players don't have a problem. I've been looking at other open source alternatives that do a straight copy (not transcode) with no luck. – kingrolo Aug 26 '12 at 18:00
  • You should ask on the ffmpeg user list once to confirm just in case – av501 Aug 26 '12 at 18:02
  • See my edit. You can fix this by doing two seperate transcodes and then just muxing the two together. – av501 Aug 26 '12 at 18:04
  • hmm not sure I follow...the 2 streams are audio. (1 video + 2 audio). the AR problem is all about the video stream only. – kingrolo Aug 26 '12 at 18:07
  • Ok. My bad. Will remove the edit. You have a single video. Got it. The first answer still applies then. I don't think ffmpeg can auto detect AR in the fly – av501 Aug 26 '12 at 18:12
  • Why use avidemux? ffmpeg can do the demux and muxing for you. – av501 Aug 26 '12 at 18:15
  • I used (tried) avidemux to visually split the source video file (remove commercial breaks, top and tail, etc). Need to usable GUI to do this type of thing by hand. Once I have the trimmed source the ffmpeg AR issue above would not be a problem. As I am informed that ffmpeg can't handle files with multiple ARs (resolutions) I will have to go back to my original problem and find out why avidemux fails to audio sync more mpeg2video source file. – kingrolo Aug 27 '12 at 10:14