Bug 1771

Summary: xine/ffmpeg fails to decode properly H.264/AVC (1280x544) movie trailer
Product: Fedora Reporter: Chris Rankin <rankincj>
Component: xine-lib-extras-freeworldAssignee: Dominik 'Rathann' Mierzejewski <dominik>
Status: RESOLVED FIXED    
Severity: normal CC: kwizart
Priority: P5    
Version: 15   
Hardware: i386   
OS: GNU/Linux   
namespace:
Attachments: First few seconds of movie trailer.

Description Chris Rankin 2011-05-30 02:49:13 CEST
I have compiled xine-lib and xine-ui (from the hg repositories) against package

ffmpeg-libs-0.6.90-0.2.rc0.fc15

However, attempting to play a HD (H.264/AVC) movie trailer with this version of ffmpeg results in many errors and dropped frames.

Downgrading to ffmpeg-libs-0.6.2-1 by rebuilding F14's SRPM and then recompiling xine-lib fixes the problem.

I am assuming that this is a problem with the ffmpeg packages because the latest commit in xine-lib says:

changeset:   10059:4b98ea41b6f4
tag:         tip
user:        Brad Smith <brad@comstyle.com>
date:        Tue May 17 02:15:12 2011 +0000
summary:     Fix build with very recent copies of FFmpeg
Comment 1 Nicolas Chauvet 2011-06-12 22:55:47 CEST
The problem is that I cannot say if the said patch is backward compatible with the version of ffmpeg we have in F-15 (aka from  the oldabi branch), so we cannot support this.
If you need a newer xine-lib version, please get in touch with the xine-lib maintainer at rpmfusion.

At least for F-15, a newer updated package is in progress, ffmpeg-0.7-0.1-rc1 should hit rpmfusion-free-updates-testing soon.

Please re-open the bug if you can reproduce the problem with this version and curren xine-lib in Fedora/RPM Fusion
That been said, h264 playback works fine with others frameworks.

Thx for your report.
Comment 2 Chris Rankin 2011-07-16 15:46:16 CEST
I have upgraded to the following packages:

xine-lib-1.1.19-6.fc15.i686
xine-lib-extras-freeworld-1.1.19-1.fc14.i686
ffmpeg-libs-0.7-0.3.20110612git.fc15.i686

and playing the same movie trailer still gives me a constant stream of errors on my console:

[h264 @ 0xac558bc0] AVC: nal size 1081873426
[h264 @ 0xac558bc0] no frame!
[h264 @ 0xac5593a0] AVC: nal size 1099422463
[h264 @ 0xac5593a0] no frame!
[h264 @ 0xac558bc0] AVC: nal size -58973994
[h264 @ 0xac558bc0] no frame!
[h264 @ 0xac5593a0] AVC: nal size 489156271
[h264 @ 0xac5593a0] no frame!
[h264 @ 0xac558bc0] AVC: nal size 683902322
[h264 @ 0xac558bc0] no frame!
[h264 @ 0xac5593a0] AVC: nal size 620896079
[h264 @ 0xac5593a0] no frame!
[h264 @ 0xac558bc0] AVC: nal size -1113112523
[h264 @ 0xac558bc0] no frame!
[h264 @ 0xac5593a0] AVC: nal size 255406545
[h264 @ 0xac5593a0] no frame!

These presumably result in dropped frames, because xine soon starts to complain that my system is too slow for this trailer.

Switching to ffmpeg-0.6.3 from F14 (recompiled for F15) fixes the problem. The only message I get on my console with 0.6.3 is:

[h264 @ 0xb1a00dc0]Cannot parallelize deblocking type 1, decoding such frames in sequential order
Comment 3 Nicolas Chauvet 2011-07-16 23:50:40 CEST
(In reply to comment #2)

> [h264 @ 0xb1a00dc0]Cannot parallelize deblocking type 1, decoding such frames
> in sequential order

Which CPU do you have actually ?

Comment 4 Chris Rankin 2011-07-17 00:57:17 CEST
(In reply to comment #3)
> Which CPU do you have actually ?

Dual P4 2.66 GHz Xeons (with HT enabled). It's not a new machine, but it does play this H.264 trailer at 1280x544.

I suppose it's also possible that the bug is in xine-lib instead of ffmpeg.
Comment 5 Chris Rankin 2011-07-17 01:10:27 CEST
Created attachment 673 [details]
First few seconds of movie trailer.

This is enough of the .mov file to reproduce the problem.
Comment 6 Dominik 'Rathann' Mierzejewski 2011-08-24 18:17:46 CEST
With FFmpeg-0.7.3 (ffplay), I'm getting a lot of these:

[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f5d100013c0] stream 1, offset 0x6984e: partial file

Could you provide a link to the full file?
Comment 7 Chris Rankin 2011-08-24 18:45:16 CEST
(In reply to comment #6)
> Could you provide a link to the full file?

I believe the following command will download it for you:

$ wget -U Quicktime/7.6.2 http://trailers.apple.com/movies/fox/xmenfirstclass/xmenfirstclass-tlr2_h720p.mov

Note that you do need to pretend to be using Quicktime...
Comment 8 Dominik 'Rathann' Mierzejewski 2011-08-24 22:02:08 CEST
Thanks for the link. I see no issues when playing the full trailer using ffplay from ffmpeg-0.7.3 release. I'm working on an update for F-15, so this should be fixed soon. If the issue still persists then, then it's a bug in xine-lib.
Comment 9 Chris Rankin 2011-08-24 22:23:26 CEST
(In reply to comment #8)
> If the issue still persists then, then it's a bug in xine-lib.

Personally, I am suspecting xine-lib more and more, but you can already verify this trivially by installing the xine-ui RPM and using it to watch the trailer.

Is there a document anywhere which describes the ffmpeg API changes between 0.6 and 0.7, please? There weren't many changes made to xine-lib's ffmpeg video decoder; presumably the intention was to translate rather than to change any behaviour.

Comment 10 Dominik 'Rathann' Mierzejewski 2011-08-24 23:13:26 CEST
(In reply to comment #9)
> (In reply to comment #8)
> > If the issue still persists then, then it's a bug in xine-lib.
> 
> Personally, I am suspecting xine-lib more and more, but you can already verify
> this trivially by installing the xine-ui RPM and using it to watch the trailer.
> 
> Is there a document anywhere which describes the ffmpeg API changes between 0.6
> and 0.7, please? There weren't many changes made to xine-lib's ffmpeg video
> decoder; presumably the intention was to translate rather than to change any
> behaviour.
> 

Frankly, F-14 xine seems to work just fine for me. I don't have a machine with F-15 at the moment. I'll test later.
Comment 11 Chris Rankin 2011-08-25 00:12:41 CEST
(In reply to comment #10)
> Frankly, F-14 xine seems to work just fine for me.

Well, yes. Like I said originally, I fixed the problem in F15 by taking the ffmpeg-0.6.3-1.fc14.src.rpm package and rebuilding it.
Comment 12 Chris Rankin 2011-08-25 01:18:48 CEST
(In reply to comment #10)
> Frankly, F-14 xine seems to work just fine for me. 

Heh, I should mention that my $HOME/.xine/config file contains the following setting:

# FFmpeg video decoding thread count
# numeric, default: 1
video.processing.ffmpeg_thread_count:2

Not unreasonable, I thought, on a PC with 2 physical, hyper-threaded 2.66GHz P4 Xeon CPUs.

Revert the ffmpeg_thread_count to 1 and all the errors disappear. This setting triggers the following code in xine's decoder:

  if (this->class->thread_count > 1) {
    if (this->codec->id != CODEC_ID_SVQ3
        && avcodec_thread_init(this->context, this->class->thread_count) != -1)
      this->context->thread_count = this->class->thread_count;
  }
Comment 13 Chris Rankin 2011-08-25 01:30:28 CEST
> Heh, I should mention that my $HOME/.xine/config file contains the following
> setting:
> 
> # FFmpeg video decoding thread count
> # numeric, default: 1
> video.processing.ffmpeg_thread_count:2

So to be clear: ffmpeg 0.6.3 works fine with this setting, but ffmpeg 0.7 chokes instead. Ouch. I don't think this is a xine bug.
Comment 14 Dominik 'Rathann' Mierzejewski 2011-08-25 18:27:06 CEST
(In reply to comment #13)
> So to be clear: ffmpeg 0.6.3 works fine with this setting, but ffmpeg 0.7
> chokes instead. Ouch. I don't think this is a xine bug.

ffplay -threads 2 works fine for me with that trailer. So I guess it's fixed in 0.7.3.
Comment 15 Chris Rankin 2011-08-30 20:38:58 CEST
(In reply to comment #14)
> ffplay -threads 2 works fine for me with that trailer. So I guess it's fixed in
> 0.7.3.

The problem is not fixed, it's actually a bug in xine-lib after all. Specifically, xine-lib 1.1.19's FFmpeg decoder plugin needs the following patch to be included before multi-threaded video decoding will work again:

http://sourceforge.net/mailarchive/message.php?msg_id=27998734

Comment 16 Chris Rankin 2011-09-06 13:13:23 CEST
(In reply to comment #15)
> Specifically, xine-lib 1.1.19's FFmpeg decoder plugin needs the following patch
> to be included before multi-threaded video decoding will work again:
> 
> http://sourceforge.net/mailarchive/message.php?msg_id=27998734

This patch has now been included in the upstream xine-lib repository for 1.1.19.
Comment 17 Nicolas Chauvet 2012-05-08 23:20:56 CEST
I expect the problem to be fixed with current release.