Opened 12 years ago

Last modified 10 years ago

#2595 open defect

Last frame of partly deintelacted video stream, not deinterlaced

Reported by: Jean Delvare Owned by:
Priority: normal Component: avfilter
Version: git-master Keywords: yadif
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

I have an input video file where some sequences are interlaced and the rest isn't. I am using -vf yadif=enable='between(t,A,B)+...' to only deinterlace where needed. It works almost fine, except that the very last frame of each specified time sequence is not deinterlaced.

How to reproduce:

% ffmpeg -i input.mpg -vf yadif=enable='between(t,0,1.040)' output.mpg
ffmpeg version N-53323-gb8a9876 Copyright (c) 2000-2013 the FFmpeg developers
  built on May 21 2013 16:20:56 with gcc 4.7 (SUSE Linux)

As a workaround, I am adding one frame at the end of every sequence which needs to be deinterlaced.

Attachments (2)

ffmpeg-bug-2595.mpg (1.1 MB ) - added by Jean Delvare 12 years ago.
Sample to reproduce the bug
interlaced.mpg (186.0 KB ) - added by Carl Eugen Hoyos 11 years ago.

Download all attachments as: .zip

Change History (13)

comment:1 by Carl Eugen Hoyos, 12 years ago

Keywords: yadif added

Please provide a sample and a failing command line together with the complete, uncut console output.

by Jean Delvare, 12 years ago

Attachment: ffmpeg-bug-2595.mpg added

Sample to reproduce the bug

comment:2 by Carl Eugen Hoyos, 12 years ago

To make this a valid ticket, please provide the command line that allows to reproduce the problem together with the complete, uncut console output.

comment:3 by Jean Delvare, 12 years ago

$ ffmpeg -i ffmpeg-bug-2595.mpg -vf "yadif=enable='between(t,0,1.040)'" -codec:v libx264 ffmpeg-bug-2595.mp4
ffmpeg version N-53323-gb8a9876 Copyright (c) 2000-2013 the FFmpeg developers
  built on May 21 2013 16:20:56 with gcc 4.7 (SUSE Linux)
  configuration: --prefix=/opt/ffmpeg --enable-shared --enable-libmp3lame --enable-libxvid --enable-postproc --enable-gpl --enable-x11grab --enable-avfilter --enable-version3 --enable-libx264 --enable-pthreads --enable-libvorbis --enable-libtheora
  libavutil      52. 33.100 / 52. 33.100
  libavcodec     55. 10.101 / 55. 10.101
  libavformat    55.  7.100 / 55.  7.100
  libavdevice    55.  1.100 / 55.  1.100
  libavfilter     3. 68.102 /  3. 68.102
  libswscale      2.  3.100 /  2.  3.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  3.100 / 52.  3.100
Input #0, mpeg, from 'ffmpeg-bug-2595.mpg':
  Duration: 00:00:01.96, start: 0.245800, bitrate: 4838 kb/s
    Stream #0:0[0x1e0]: Video: mpeg2video (Main), yuv420p, 720x576 [SAR 64:45 DAR 16:9], 25.25 fps, 25 tbr, 90k tbn, 100 tbc
[libx264 @ 0x15e6d20] using SAR=64/45
[libx264 @ 0x15e6d20] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2
[libx264 @ 0x15e6d20] profile High, level 3.0
[libx264 @ 0x15e6d20] 264 - core 129 - H.264/MPEG-4 AVC codec - Copyleft 2003-2013 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'ffmpeg-bug-2595.mp4':
  Metadata:
    encoder         : Lavf55.7.100
    Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 720x576 [SAR 64:45 DAR 16:9], q=-1--1, 12800 tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg2video -> libx264)
Press [q] to stop, [?] for help
frame=   50 fps=0.0 q=-1.0 Lsize=     251kB time=00:00:01.92 bitrate=1069.8kbits/s dup=1 drop=0    
video:250kB audio:0kB subtitle:0 global headers:0kB muxing overhead 0.474299%

If you look at the output video file you'll see that the frame at 00:01.040 was not deinterlaced. I tried a different container format (avi) and a different video codec (libxvid) and the problem is still present. I tries using between(n,0,16) and the result is the same. If I use between(t,0,1.080) instead then it looks OK.

in reply to:  3 comment:4 by Jean Delvare, 12 years ago

Replying to khali:

I tried using between(n,0,16) and the result is the same.

Sorry that was a typo, I really meant between(n,0,26). The output file is exactly the same as with between(t,0,1.040).

comment:5 by Jean Delvare, 12 years ago

Note that the problem is specific to the yadif filter. Using for example the removelogo filter, the filter is properly applied to the last picture of the selection.

comment:6 by Carl Eugen Hoyos, 11 years ago

Reproduced by developer: set
Status: newopen

Your input video is not actually interlaced but the phase is inverted for the first 27 frames, this can be fixed with the phase filter:

$ ffmpeg -i ffmpeg-bug-2595.mpg -vf phase out.mp4

I am not saying that there is no issue with yadif though.

comment:7 by Carl Eugen Hoyos, 11 years ago

Reproduced by developer: unset

comment:8 by Jean Delvare, 11 years ago

Thanks for the tip! Very helpful. I'll try to remember next time I face a similar issue.

by Carl Eugen Hoyos, 11 years ago

Attachment: interlaced.mpg added

comment:9 by Carl Eugen Hoyos, 11 years ago

Reproduced by developer: set

I attached nine interlaced frames from a dvb recording.
The following command produces a file with the first, eighth and ninth frame still interlaced (the documentation explains that n starts from 0):

$ ffmpeg -i interlaced.mpg -vf yadif=enable="'between(n,2,7)'" -qscale 2 out.avi
ffmpeg version N-62898-g1ccd1a3 Copyright (c) 2000-2014 the FFmpeg developers
  built on May  2 2014 08:38:05 with gcc 4.7 (SUSE Linux)
  configuration: --enable-gpl
  libavutil      52. 80.100 / 52. 80.100
  libavcodec     55. 60.103 / 55. 60.103
  libavformat    55. 37.102 / 55. 37.102
  libavdevice    55. 13.100 / 55. 13.100
  libavfilter     4.  5.100 /  4.  5.100
  libswscale      2.  6.100 /  2.  6.100
  libswresample   0. 18.100 /  0. 18.100
  libpostproc    52.  3.100 / 52.  3.100
Input #0, mpeg, from 'interlaced.mpg':
  Duration: 00:00:00.24, start: 1.320000, bitrate: 6348 kb/s
    Stream #0:0[0x1e0]: Video: mpeg2video (Main), yuv420p(tv), 720x576 [SAR 64:45 DAR 16:9], max. 3500 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
Please use -q:a or -q:v, -qscale is ambiguous
Output #0, avi, to 'out.avi':
  Metadata:
    ISFT            : Lavf55.37.102
    Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 720x576 [SAR 64:45 DAR 16:9], q=2-31, 200 kb/s, 25 tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg2video -> mpeg4)
Press [q] to stop, [?] for help
frame=    9 fps=0.0 q=2.0 Lsize=     229kB time=00:00:00.36 bitrate=5215.3kbits/s dup=0 drop=1
video:223kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.615136%

comment:10 by Clément Bœsch, 11 years ago

Note: timeline support added to phase filter in 69d72140, if you want to compare, somehow.

comment:11 by Jean Delvare, 10 years ago

Thank you for that, it could be handy.

Note: See TracTickets for help on using tickets.