Author Topic: Audio encoding chooses channel format at beginning of file, not cutpoint  (Read 586 times)

cheesemonster

  • Newbie
  • *
  • Posts: 2
Given a MPEG-TS recording that may consist of an TV earlier programme recorded in 2.0 AC3 followed by a 5.1 AC3 recording in the same file, setting the A-B cutpoints to save the programme section with 5.1AC3 recording will result in using a 2.0 channel format only when audio encoding in any format.  It seems that the channel output is defined by the start of the MPEG-TS file rather than what is set at the start of the cut-point.

Tested with avidemux master from 20180301

eumagga0x2a

  • Moderator
  • Hero Member
  • *****
  • Posts: 2293
Yes, this is a current design limitation. Does saving the part of the stream after the switch to 5.1 in copy mode as an intermediate step and loading the resulting video file help?

cheesemonster

  • Newbie
  • *
  • Posts: 2
Yes that does work, with the caveat that the programme and sound channel switch may start on a B-frame, so there's some frame-loss/sync issue when using copy.

eumagga0x2a

  • Moderator
  • Hero Member
  • *****
  • Posts: 2293
This is exactly the reason I wrote "after the switch to 5.1". You must start the selection on an IDR to avoid video corruption (notwithstanding the issue of streams which don't include IDR frames at all). Don't even try to cut at the B-frame where the switch occurs. Avidemux will try to go back to the previous I-frame and you will probably end up with the 2-channels layout again.

hai

  • Newbie
  • *
  • Posts: 1
Is there an easy way to find out from within avidemux where the audio format changes in such a MPEG-TS recording?
I'd rather lose a few seconds of a recording than have broken audio. Cutting at the first I-Frame of the desired subset of the recording is not a guarantee for success unless all TV stations switch the audio format before or at the first I-Frame after the movie starts.

eumagga0x2a

  • Moderator
  • Hero Member
  • *****
  • Posts: 2293
If you use Avidemux built from 2018-05-13 or earlier, you can hear when the layout switches. After that, you would need to remove the *ad_a52.* plugin file first, in order to force Avidemux to use the internal lavcodec instead of liba52 for AC3 decoding due to [audioDecoders/ac3] Force downmix to stereo on switch from 2.0 to 5.0/5.1, based on patch by Basic.Master (http://avidemux.org/smif/index.php/topic,18332.0.html).