[FFmpeg-user] FFMpeg problem using fieldmatch and decimate filters to IVTC

Steve Boyer steveboyer85 at gmail.com
Tue May 6 20:46:56 CEST 2014


Nicholas,

Thanks for looking at the sample files. I knew that the source material
switched back and forth between interlaced video, FILM, and funky
combinations of the two throughout each episode as you outlined. It didn't
click that the correct source frame rate would vary in these scenes - which
is starting to make sense that if a portion is made to be played at ~30
FPS, has a frame removed and shift the video stream, and played at ~24 FPS,
it would introduce the AV desync and quickly become noticeable. It simply
didn't occur to me! Sounds like either pullup, fieldmatch+yadif, or even
just yadif the whole thing without a framerate conversion would give me a
good encode without any AV desync.

I use MoboPlayer on Android and am going to try out another player soon. I
don't think they do VFR, but since the shows are authored to NTSC DVD
standards to a CFR of ~30 FPS (telecined ~24 fps and NTSC interlaced), it
shouldn't be a problem.

I noticed the ffprobe seemed to look quite strange as well. Mplayer and
other players think that the vob files are something stupid-short like a
minute as well. I ripped the files from the DVDs using dvdbackup and then
ran "cat *.VOB > 4.18.vob" to join the two together. If you have a
suggestion on a better method, I'm all ears.

Thanks for taking the time to put me back in my place!

Finally, the output of the ffprobe files (for posterity) are:

steve at moose-linux:/media/steve/G/tng/sample$ ffprobe -select_streams v
-show_streams -count_frames -i sample.vob
ffprobe version 2.2.git Copyright (c) 2007-2014 the FFmpeg developers
  built on May  4 2014 14:50:41 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
  configuration: --prefix=/home/steve/ffmpeg_build
--extra-cflags=-I/home/steve/ffmpeg_build/include
--extra-ldflags=-L/home/steve/ffmpeg_build/lib --bindir=/home/steve/bin
--extra-libs=-ldl --enable-gpl --enable-libass --enable-libfdk-aac
--enable-libfreetype --enable-libmp3lame --enable-libopus
--enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264
--enable-nonfree --enable-x11grab
  libavutil      52. 81.100 / 52. 81.100
  libavcodec     55. 60.103 / 55. 60.103
  libavformat    55. 37.102 / 55. 37.102
  libavdevice    55. 13.101 / 55. 13.101
  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 'sample.vob':
  Duration: 00:00:37.66, start: 0.192267, bitrate: 6682 kb/s
    Stream #0:0[0x1bf]: Data: dvd_nav_packet
    Stream #0:1[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, smpte170m),
720x480 [SAR 8:9 DAR 4:3], max. 9800 kb/s, 29.97 fps, 29.97 tbr, 90k tbn,
59.94 tbc
    Stream #0:2[0x80]: Audio: ac3, 48000 Hz, 5.1(side), fltp, 448 kb/s
    Stream #0:3[0x81]: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
    Stream #0:4[0x20]: Subtitle: dvd_subtitle
Unsupported codec with id 1145979222 for input stream 0
[STREAM]
index=1
codec_name=mpeg2video
codec_long_name=MPEG-2 video
profile=Main
codec_type=video
codec_time_base=1001/60000
codec_tag_string=[0][0][0][0]
codec_tag=0x0000
width=720
height=480
has_b_frames=1
sample_aspect_ratio=8:9
display_aspect_ratio=4:3
pix_fmt=yuv420p
level=8
timecode=01:00:36;17
id=0x1e0
r_frame_rate=30000/1001
avg_frame_rate=30000/1001
time_base=1/90000
start_pts=17304
start_time=0.192267
duration_ts=N/A
duration=N/A
bit_rate=N/A
nb_frames=N/A
nb_read_frames=1142
nb_read_packets=N/A
DISPOSITION:default=0
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
[/STREAM]
steve at moose-linux:/media/steve/G/tng/sample$

and for the large, ~2 GB vob:

steve at moose-linux:/media/steve/G/tng$ ffprobe -select_streams v
-show_streams -count_frames -i 4.18.vob
ffprobe version 2.2.git Copyright (c) 2007-2014 the FFmpeg developers
  built on May  4 2014 14:50:41 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
  configuration: --prefix=/home/steve/ffmpeg_build
--extra-cflags=-I/home/steve/ffmpeg_build/include
--extra-ldflags=-L/home/steve/ffmpeg_build/lib --bindir=/home/steve/bin
--extra-libs=-ldl --enable-gpl --enable-libass --enable-libfdk-aac
--enable-libfreetype --enable-libmp3lame --enable-libopus
--enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264
--enable-nonfree --enable-x11grab
  libavutil      52. 81.100 / 52. 81.100
  libavcodec     55. 60.103 / 55. 60.103
  libavformat    55. 37.102 / 55. 37.102
  libavdevice    55. 13.101 / 55. 13.101
  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 '4.18.vob':
  Duration: 00:01:04.91, start: 0.192267, bitrate: 246741 kb/s
    Stream #0:0[0x1bf]: Data: dvd_nav_packet
    Stream #0:1[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, smpte170m),
720x480 [SAR 8:9 DAR 4:3], max. 9800 kb/s, 29.97 fps, 29.97 tbr, 90k tbn,
59.94 tbc
    Stream #0:2[0x80]: Audio: ac3, 48000 Hz, 5.1(side), fltp, 448 kb/s
    Stream #0:3[0x81]: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
    Stream #0:4[0x20]: Subtitle: dvd_subtitle
Unsupported codec with id 1145979222 for input stream 0
[mpeg2video @ 0x3a7dc40] ac-tex damaged at 43 28
[mpeg2video @ 0x3a7dc40] Warning MVs not available
[mpeg2video @ 0x3a7dc40] concealing 90 DC, 90 AC, 90 MV errors in P frame
[STREAM]
index=1
codec_name=mpeg2video
codec_long_name=MPEG-2 video
profile=Main
codec_type=video
codec_time_base=1001/60000
codec_tag_string=[0][0][0][0]
codec_tag=0x0000
width=720
height=480
has_b_frames=1
sample_aspect_ratio=8:9
display_aspect_ratio=4:3
pix_fmt=yuv420p
level=8
timecode=01:45:28;24
id=0x1e0
r_frame_rate=30000/1001
avg_frame_rate=30000/1001
time_base=1/90000
start_pts=17304
start_time=0.192267
duration_ts=5831467
duration=64.794078
bit_rate=N/A
nb_frames=N/A
nb_read_frames=71617
nb_read_packets=N/A
DISPOSITION:default=0
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
[/STREAM]
steve at moose-linux:/media/steve/G/tng$

> On Monday, May 5, 2014 11:42 PM, Steve Boyer <steveboyer85 at gmail.com>
wrote:

> > Hey all,
>
> Originally, I posted this to the wrong mailing list and had a request to
> execute an ffprobe command. I am reposting and including the output of the
> commands.
>
> The ffprobe.txt file is for the sample.vob and the ffprobe.4.18.txt is for
> the full, ~2GB vob.

I was the one who asked him for the ffprobe output. List protocal is to
post the output of these kinds of commands to the list so that it is
archived for posterity.

Something fishy is going on with these files. Both ffprobe files seem
strange to me:

Looking at the short file, ffprobe reports the file is 37.66 seconds long
and contains 1142 frames. That is 32.35 fps, very strange.

Looking at the long file, ffprobe reports that the files is 64 seconds long
and contains 71617 frames.  I suspect that the 64 seconds part is
crazytalk. If I assume the long file is somewhere between 42 and 46 minutes
long  I get a frame rate of between 28.42 and 25.95. All nonsense frame
rates, no sensible frame rate is in that range AFAIK.

The problem is that decimate butchers PTS's. It recalculates the PTS's
based on the stream's stated frame rate and the frame count. So if your
stream says it is 29.97 fps then fieldmatch will set the PTS's of the
output frames to be 23.98 fps, regardless of the actual input timestamps.
If the actual input frame rate is different this causes sync issues of
course

It looks like you have a mix of frame rates in your video. Can you play VFR
video on your phone?

If so, the solution is just use pullup. Pullup introduces judder sometimes.
You might want to use the dejudder filter after the pullup.

When they made these shows they used different methods for different types
of scenes, some was filed at 24fps and TC'ed, some at interlaced 30fps,
etc. I would scan through the vide and look to see if the whole thing is
TC'ed. I would look at four kinds of scenes:

1) All live action, like the start of sample.vob
2) Composite shots, like the end of sample.vob (that TV is porbably not
actually in the shot) also shots of the bridge screen will be composites.
The ship orbiting might or might not be composite.
3) All model-work, outside shots of the ship in space
4) Live action with some FX, like someone getting phasered or a transporter.

If possible cut these out using ffmpeg -c copy or dd. If you are using
ffmpeg, chuck the ther streams for this analysis. Then run the ffprobe
command on each scene and see what frame count is "nb_read_frames" and
divide the duration into that to get a fps. Hopefully it will be one of:
23.98, 24, 29.97, 30, 59.94, 60.

Once you figure out what the producers of the show are doing frame rate,
interlace, progressive, TC'ed wise, you can make a filterchain that should
work.

If my STB could deal with VFR I would just use -vf pullup,dejudder for this
kind of material, mixed telecine & progressive. If there was also
interlaced in there, I might add yadif

-vf pullup,dejudder,idet,yadif=deint=interlaced:mode=1

Since my STB can't deal with VFR I make it CFR at the highest FR my box can
deal with, "60" in my case, so I add fps=fps=60000/1001 to my filterchain.


> Steven Boyer
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user

_______________________________________________
ffmpeg-user mailing list
ffmpeg-user at ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user


More information about the ffmpeg-user mailing list