4

This is somewhat related to Looping a video with AVFoundation AVPlayer but that question is answered. What I'm trying to achieve is seamless looping using an AVPlayer. There is a noticeable stutter between loops using h264-encoded videos* that has gotten worse for some reason with the update to iOS 5. Could this have something to do with the way the videos are encoded rather than the AVPlayer? The looping is triggered by a playerItemDidReachEnd notification as described in the link above.

Thanks.

* here's the ffmpeg command we're using to encode the videos, if that helps:

ffmpeg -i -y -sameq -vcodec libx264 -vpre hq -crf 20 -an

(yes, the files don't have sound (yet) so the -an is intentional.)

Community
  • 1
  • 1
bennettk
  • 213
  • 2
  • 11
  • http://stackoverflow.com/questions/3410003/iphone-smooth-transition-from-one-video-to-another/17138580#17138580 – MoDJ Jun 18 '13 at 01:12
  • Looping full HD content via VideoToolbox APIs: http://stackoverflow.com/a/33335884/763355 – MoDJ Apr 14 '16 at 18:53

1 Answers1

0

How about you set number of reference frames to 1 and/or b frames to 0 and/or profile to baseline?

One plausible explanation:

By default for a h.264 decode decode all kinds of videos, it must buffer some frames at the begining of a video. So if you are looping (if it is reseting the decoder) perhaps the buffering is coming in. Are you looping without reseting the decoder? Is the decoder getting reset because of eos while reading file? If yes, can you prevent that by avoiding reading beyond last frame and triggering eos condition?

If you had finer control ( not sure on that though ) one way you can avoid it is by not feeding the stream header (sps/pps) when returning back to loop?

av501
  • 6,645
  • 2
  • 23
  • 34