1

I have 2 files: fileSequence0.ts and fileSequence1.ts, I use ffmpeg to inspected the number of frames of each file, the result is:

  • fileSequence0.ts, 29 frames
  • fileSequence1.ts, 28 frames

Then I concat the 2 files into one:

ffmpeg -i 'concat:fileSequence0.ts|fileSequence1.ts' -codec copy merge.mp4

Now, merge.mp4 has 58 frames, not 57 = 29 + 28, what's that about, can any one point out what knowlege I am missing?

The files mentioned here can be download at: https://github.com/ideawu/missing-frame-between-ts

ideawu
  • 2,287
  • 1
  • 23
  • 28

1 Answers1

1

The second file fileSequence1.ts also has 29 frames not 28.

Because of the way it was initially segmented, if you to play it on its own you will fail to get one frame as it's missing the required SPS/PPS data:

[h264 @ 0x4111460] non-existing PPS 0 referenced
    Last message repeated 1 times
[h264 @ 0x4111460] decode_slice_header error
[h264 @ 0x4111460] non-existing PPS 0 referenced
[h264 @ 0x4111460] decode_slice_header error
[h264 @ 0x4111460] no frame!

Since the SPS/PPS is present in the first file and when you concat it will read fileSequence0.ts first it will be able to decode the lost frame, hence the result is the correct value 58.

You can see this easily by reversing the order of the concat:

ffmpeg -i 'concat:fileSequence1.ts|fileSequence0.ts' -codec copy merge.mp4

This command results in 57 frames as it fails to decode the first one.

aergistal
  • 29,947
  • 5
  • 70
  • 92
  • Many thanks! I am doing video decoding with AVAssetReader on iOS, it also tells `fileSequence1.ts` has 28 frames not 29. Now I have to learn PPS things. – ideawu Dec 15 '15 at 11:10
  • @ideawu It has 29, but fails to decode one. See the Wikipedia [entry](https://en.wikipedia.org/wiki/Network_Abstraction_Layer#Parameter_Sets) and this [answer](http://stackoverflow.com/questions/24884827/possible-locations-for-sequence-picture-parameter-sets-for-h-264-stream) on SO – aergistal Dec 15 '15 at 11:17
  • Thanks again! You are such nice person! – ideawu Dec 15 '15 at 11:27