Author Topic: avidemux works fine but trying the same with ffmpeg don't  (Read 470 times)

eumagga0x2a

  • Hero Member
  • *****
  • Posts: 2201
Re: avidemux works fine but trying the same with ffmpeg don't
« Reply #15 on: October 09, 2018, 07:00:44 PM »
The search for the actual bug in Avidemux is ongoing, but the nature of the problem becomes apparent: when indexing TS files, Avidemux gets the size of each keyframe slightly wrong (in the samples I tried +6 bytes), which means that following PES packets are shifted 6 bytes relative to respective frame boundaries. This confuses ffmpeg which sees the beginning of a second frame in the first packet but doesn't have DTS/PTS for it yet. When the second packet arrives from the demuxer, it pushes it with timestamps unset to the muxer so that saving fails.

If you edit the .idx2 file to subtract 6 from the first field following each IF or DF marker, reload the TS file in Avidemux and save a portion of it in copy mode using the MpegTS muxer, ffmpeg is able to remux resulting video to mkv without problems.

manbau00

  • Newbie
  • *
  • Posts: 9
Re: avidemux works fine but trying the same with ffmpeg don't
« Reply #16 on: October 10, 2018, 04:54:48 PM »
Fine, hopefully you find it.

At the moment I use ffmpeg to cut the ts files.

eumagga0x2a

  • Hero Member
  • *****
  • Posts: 2201
Re: avidemux works fine but trying the same with ffmpeg don't
« Reply #17 on: October 11, 2018, 02:22:32 PM »
the nature of the problem becomes apparent: when indexing TS files, Avidemux gets the size of each keyframe slightly wrong (in the samples I tried +6 bytes)

It turned out to be that it is the internal FFmpeg that adds these 6 bytes to each packet with H.264 video, my first analysis was plain wrong.