[FFmpeg-user] Confusion about fieldmatch, decimate and framerate

Nicholas Robbins nickrobbins at yahoo.com
Thu Nov 7 04:00:45 CET 2013


I'm dealing with a mpeg2 video file that I think has been telescened. This is my first foray into detelescening. If I look frame by frame, 4 frames looked interlaced, then 4 look progressive. This is what ffprobe has to say about the file:

$ ffprobe start.mkv 
ffprobe version 2.0.2 Copyright (c) 2007-2013 the FFmpeg developers
  built on Nov  6 2013 20:33:17 with gcc 4.7.3 (Gentoo Hardened 4.7.3-r1 p1.3, pie-0.5.5)
  configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --enable-shared --cc=x86_64-pc-linux-gnu-gcc --cxx=x86_64-pc-linux-gnu-g++ --ar=x86_64-pc-linux-gnu-ar --optflags='-O2 -pipe -march=native -fomit-frame-pointer' --extra-cflags='-O2 -pipe -march=native -fomit-frame-pointer' --extra-cxxflags='-O2 -pipe -march=native -fomit-frame-pointer' --disable-static --enable-gpl --enable-postproc --enable-avfilter --enable-avresample --disable-stripping --enable-nonfree --disable-indev=v4l2 --disable-outdev=v4l2 --disable-indev=alsa --disable-indev=oss --disable-indev=jack --disable-outdev=alsa --disable-outdev=oss --disable-outdev=sdl --enable-bzlib --disable-runtime-cpudetect --disable-debug --disable-doc --disable-gnutls --enable-hardcoded-tables --enable-iconv --enable-network --disable-openssl --disable-ffplay --disable-vaapi --disable-vdpau --enable-zlib --disable-libvo-aacenc --disable-libvo-amrwbenc
 --enable-libmp3lame --disable-libfdk-aac --disable-libaacplus --enable  libavutil      52. 38.100 / 52. 38.100
  libavcodec     55. 18.102 / 55. 18.102
  libavformat    55. 12.100 / 55. 12.100
  libavdevice    55.  3.100 / 55.  3.100
  libavfilter     3. 79.101 /  3. 79.101
  libavresample   1.  1.  0 /  1.  1.  0
  libswscale      2.  3.100 /  2.  3.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  3.100 / 52.  3.100
[mpeg2video @ 0x665042ba40] Warning: not compiled with thread support, using thread emulation
[ac3 @ 0x665042c100] Warning: not compiled with thread support, using thread emulation
Input #0, matroska,webm, from 'start.mkv':
  Metadata:
    creation_time   : 2013-11-07 01:06:12
  Duration: 00:01:00.22, start: 0.000000, bitrate: 6419 kb/s
    Chapter #0.0: start 0.000000, end 60.224000
    Metadata:
      title           : Chapter 01
    Stream #0:0(eng): Video: mpeg2video (Main), yuv420p, 720x480 [SAR 32:27 DAR 16:9], SAR 186:157 DAR 279:157, 59.94 fps, 59.94 tbr, 1k tbn, 59.94 tbc (default)
    Stream #0:1(eng): Audio: ac3, 48000 Hz, 5.1(side), fltp, 448 kb/s (default)
[mpeg2video @ 0x665042ba40] Warning: not compiled with thread support, using thread emulation
[ac3 @ 0x665042c100] Warning: not compiled with thread support, using thread emulation

So I think I should run -vf fieldmatch on it:

ffmpeg -i start.mkv -an -c:v libx264 -preset veryfast -crf 17  -vf "fieldmatch" Fieldmatch.mkv
ffmpeg version 2.0.2 Copyright (c) 2000-2013 the FFmpeg developers
  built on Nov  6 2013 20:33:17 with gcc 4.7.3 (Gentoo Hardened 4.7.3-r1 p1.3, pie-0.5.5)
  configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --enable-shared --cc=x86_64-pc-linux-gnu-gcc --cxx=x86_64-pc-linux-gnu-g++ --ar=x86_64-pc-linux-gnu-ar --optflags='-O2 -pipe -march=native -fomit-frame-pointer' --extra-cflags='-O2 -pipe -march=native -fomit-frame-pointer' --extra-cxxflags='-O2 -pipe -march=native -fomit-frame-pointer' --disable-static --enable-gpl --enable-postproc --enable-avfilter --enable-avresample --disable-stripping --enable-nonfree --disable-indev=v4l2 --disable-outdev=v4l2 --disable-indev=alsa --disable-indev=oss --disable-indev=jack --disable-outdev=alsa --disable-outdev=oss --disable-outdev=sdl --enable-bzlib --disable-runtime-cpudetect --disable-debug --disable-doc --disable-gnutls --enable-hardcoded-tables --enable-iconv --enable-network --disable-openssl --disable-ffplay --disable-vaapi --disable-vdpau --enable-zlib --disable-libvo-aacenc --disable-libvo-amrwbenc
 --enable-libmp3lame --disable-libfdk-aac --disable-libaacplus --enable  libavutil      52. 38.100 / 52. 38.100
  libavcodec     55. 18.102 / 55. 18.102
  libavformat    55. 12.100 / 55. 12.100
  libavdevice    55.  3.100 / 55.  3.100
  libavfilter     3. 79.101 /  3. 79.101
  libavresample   1.  1.  0 /  1.  1.  0
  libswscale      2.  3.100 /  2.  3.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  3.100 / 52.  3.100
[mpeg2video @ 0x5950de2c60] Warning: not compiled with thread support, using thread emulation
[ac3 @ 0x5950de3320] Warning: not compiled with thread support, using thread emulation
Input #0, matroska,webm, from 'start.mkv':
  Metadata:
    creation_time   : 2013-11-07 01:06:12
  Duration: 00:01:00.22, start: 0.000000, bitrate: 6419 kb/s
    Chapter #0.0: start 0.000000, end 60.224000
    Metadata:
      title           : Chapter 01
    Stream #0:0(eng): Video: mpeg2video (Main), yuv420p, 720x480 [SAR 32:27 DAR 16:9], SAR 186:157 DAR 279:157, 59.94 fps, 59.94 tbr, 1k tbn, 59.94 tbc (default)
    Stream #0:1(eng): Audio: ac3, 48000 Hz, 5.1(side), fltp, 448 kb/s (default)
[libx264 @ 0x5950de7b10] Warning: not compiled with thread support, using thread emulation
[libx264 @ 0x5950de7b10] using SAR=186/157
[libx264 @ 0x5950de7b10] using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64
[libx264 @ 0x5950de7b10] profile High, level 3.1
[libx264 @ 0x5950de7b10] 264 - core 120 - H.264/MPEG-4 AVC codec - Copyleft 2003-2011 - http://www.videolan.org/x264.html - options: cabac=1 ref=1 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=2 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=3 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=1 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=10 rc=crf mbtree=1 crf=17.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[mpeg2video @ 0x5950de2c60] Warning: not compiled with thread support, using thread emulation
Output #0, matroska, to 'Fieldmatch.mkv':
  Metadata:
    encoder         : Lavf55.12.100
    Chapter #0.0: start 0.000000, end 60.224000
    Metadata:
      title           : Chapter 01
    Stream #0:0(eng): Video: h264 (libx264) (H264 / 0x34363248), yuv420p, 720x480 [SAR 186:157 DAR 279:157], q=-1--1, 1k tbn, 59.94 tbc (default)
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg2video -> libx264)
Press [q] to stop, [?] for help
frame= 1803 fps= 44 q=-1.0 Lsize=   19217kB time=00:01:00.07 bitrate=2620.4kbits/s    
video:19203kB audio:0kB subtitle:0 global headers:0kB muxing overhead 0.072102%
[libx264 @ 0x5950de7b10] frame I:10    Avg QP:12.82  size: 45254
[libx264 @ 0x5950de7b10] frame P:731   Avg QP:17.75  size: 21549
[libx264 @ 0x5950de7b10] frame B:1062  Avg QP:19.95  size:  3256
[libx264 @ 0x5950de7b10] consecutive B-frames: 13.9% 17.6% 15.5% 53.0%
[libx264 @ 0x5950de7b10] mb I  I16..4: 20.5% 19.3% 60.2%
[libx264 @ 0x5950de7b10] mb P  I16..4:  2.7%  3.8%  1.8%  P16..4: 41.3% 19.7% 23.3%  0.0%  0.0%    skip: 7.4%
[libx264 @ 0x5950de7b10] mb B  I16..4:  0.3%  0.3%  0.0%  B16..8: 19.9%  5.9%  1.5%  direct:14.8%  skip:57.4%  L0:27.4% L1:42.5% BI:30.1%
[libx264 @ 0x5950de7b10] 8x8 transform intra:42.7% inter:44.9%
[libx264 @ 0x5950de7b10] coded y,uvDC,uvAC intra: 77.1% 36.8% 12.4% inter: 31.5% 17.3% 0.4%
[libx264 @ 0x5950de7b10] i16 v,h,dc,p: 35% 13% 47%  5%
[libx264 @ 0x5950de7b10] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 15% 10% 57%  3%  3%  3%  2%  3%  3%
[libx264 @ 0x5950de7b10] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 18% 10% 26%  9%  9%  9%  6%  8%  6%
[libx264 @ 0x5950de7b10] i8c dc,h,v,p: 73% 11% 13%  3%
[libx264 @ 0x5950de7b10] Weighted P-Frames: Y:12.7% UV:3.1%
[libx264 @ 0x5950de7b10] kb/s:2614.77



Inspecting this file shows that every 5th frame appears to be a duplicate. So I should add "decimate" right?

$ ffmpeg -i start.mkv -an -c:v libx264 -preset veryfast -crf 17  -vf "fieldmatch, decimate" Fieldmatch-Decimate.mkv
ffmpeg version 2.0.2 Copyright (c) 2000-2013 the FFmpeg developers
  built on Nov  6 2013 20:33:17 with gcc 4.7.3 (Gentoo Hardened 4.7.3-r1 p1.3, pie-0.5.5)
  configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --enable-shared --cc=x86_64-pc-linux-gnu-gcc --cxx=x86_64-pc-linux-gnu-g++ --ar=x86_64-pc-linux-gnu-ar --optflags='-O2 -pipe -march=native -fomit-frame-pointer' --extra-cflags='-O2 -pipe -march=native -fomit-frame-pointer' --extra-cxxflags='-O2 -pipe -march=native -fomit-frame-pointer' --disable-static --enable-gpl --enable-postproc --enable-avfilter --enable-avresample --disable-stripping --enable-nonfree --disable-indev=v4l2 --disable-outdev=v4l2 --disable-indev=alsa --disable-indev=oss --disable-indev=jack --disable-outdev=alsa --disable-outdev=oss --disable-outdev=sdl --enable-bzlib --disable-runtime-cpudetect --disable-debug --disable-doc --disable-gnutls --enable-hardcoded-tables --enable-iconv --enable-network --disable-openssl --disable-ffplay --disable-vaapi --disable-vdpau --enable-zlib --disable-libvo-aacenc --disable-libvo-amrwbenc
 --enable-libmp3lame --disable-libfdk-aac --disable-libaacplus --enable  libavutil      52. 38.100 / 52. 38.100
  libavcodec     55. 18.102 / 55. 18.102
  libavformat    55. 12.100 / 55. 12.100
  libavdevice    55.  3.100 / 55.  3.100
  libavfilter     3. 79.101 /  3. 79.101
  libavresample   1.  1.  0 /  1.  1.  0
  libswscale      2.  3.100 /  2.  3.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  3.100 / 52.  3.100
[mpeg2video @ 0x4212da6d80] Warning: not compiled with thread support, using thread emulation
[ac3 @ 0x4212da7440] Warning: not compiled with thread support, using thread emulation
Input #0, matroska,webm, from 'start.mkv':
  Metadata:
    creation_time   : 2013-11-07 01:06:12
  Duration: 00:01:00.22, start: 0.000000, bitrate: 6419 kb/s
    Chapter #0.0: start 0.000000, end 60.224000
    Metadata:
      title           : Chapter 01
    Stream #0:0(eng): Video: mpeg2video (Main), yuv420p, 720x480 [SAR 32:27 DAR 16:9], SAR 186:157 DAR 279:157, 59.94 fps, 59.94 tbr, 1k tbn, 59.94 tbc (default)
    Stream #0:1(eng): Audio: ac3, 48000 Hz, 5.1(side), fltp, 448 kb/s (default)
[libx264 @ 0x4212dabc30] Warning: not compiled with thread support, using thread emulation
[libx264 @ 0x4212dabc30] using SAR=186/157
[libx264 @ 0x4212dabc30] using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64
[libx264 @ 0x4212dabc30] profile High, level 3.1
[libx264 @ 0x4212dabc30] 264 - core 120 - H.264/MPEG-4 AVC codec - Copyleft 2003-2011 - http://www.videolan.org/x264.html - options: cabac=1 ref=1 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=2 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=3 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=1 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=10 rc=crf mbtree=1 crf=17.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[mpeg2video @ 0x4212da6d80] Warning: not compiled with thread support, using thread emulation
Output #0, matroska, to 'Fieldmatch-Decimate.mkv':
  Metadata:
    encoder         : Lavf55.12.100
    Chapter #0.0: start 0.000000, end 60.224000
    Metadata:
      title           : Chapter 01
    Stream #0:0(eng): Video: h264 (libx264) (H264 / 0x34363248), yuv420p, 720x480 [SAR 186:157 DAR 279:157], q=-1--1, 1k tbn, 47.95 tbc (default)
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg2video -> libx264)
Press [q] to stop, [?] for help
frame= 1443 fps= 36 q=-1.0 Lsize=   12738kB time=00:00:30.05 bitrate=3472.5kbits/s    
video:12727kB audio:0kB subtitle:0 global headers:0kB muxing overhead 0.086967%
[libx264 @ 0x4212dabc30] frame I:8     Avg QP:14.09  size: 31459
[libx264 @ 0x4212dabc30] frame P:598   Avg QP:19.68  size: 16868
[libx264 @ 0x4212dabc30] frame B:837   Avg QP:21.98  size:  3217
[libx264 @ 0x4212dabc30] consecutive B-frames: 12.5% 20.9% 28.9% 37.7%
[libx264 @ 0x4212dabc30] mb I  I16..4: 25.1% 28.3% 46.6%
[libx264 @ 0x4212dabc30] mb P  I16..4:  3.5%  4.6%  1.8%  P16..4: 42.1% 20.3% 20.7%  0.0%  0.0%    skip: 7.0%
[libx264 @ 0x4212dabc30] mb B  I16..4:  0.3%  0.3%  0.0%  B16..8: 19.3%  6.3%  1.8%  direct:12.1%  skip:60.0%  L0:25.1% L1:41.1% BI:33.8%
[libx264 @ 0x4212dabc30] 8x8 transform intra:44.3% inter:43.5%
[libx264 @ 0x4212dabc30] coded y,uvDC,uvAC intra: 72.4% 33.6% 6.1% inter: 28.3% 14.2% 0.2%
[libx264 @ 0x4212dabc30] i16 v,h,dc,p: 34% 14% 46%  6%
[libx264 @ 0x4212dabc30] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 15% 10% 55%  3%  3%  4%  3%  4%  4%
[libx264 @ 0x4212dabc30] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 17% 10% 28%  8%  9%  8%  6%  8%  6%
[libx264 @ 0x4212dabc30] i8c dc,h,v,p: 72% 12% 14%  2%
[libx264 @ 0x4212dabc30] Weighted P-Frames: Y:14.0% UV:4.7%
[libx264 @ 0x4212dabc30] kb/s:3464.46

Now the video is half as long? It has the right number of frames, 4/5 of the original amount but now it is half as long. When played with vlc of mplayer it plays in 30s rather than the minute. The audio plays at the normal rate (I removed the audio from these examples, since the audio was making the files [not the video tracks] look the same length.)

What am I doing wrong? How do I fix this?

Here is what ffprobe has to say about the two output files.

$ ffprobe Fieldmatch.mkv 
ffprobe version 2.0.2 Copyright (c) 2007-2013 the FFmpeg developers
  built on Nov  6 2013 20:33:17 with gcc 4.7.3 (Gentoo Hardened 4.7.3-r1 p1.3, pie-0.5.5)
 
 configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 
--mandir=/usr/share/man --enable-shared --cc=x86_64-pc-linux-gnu-gcc 
--cxx=x86_64-pc-linux-gnu-g++ --ar=x86_64-pc-linux-gnu-ar 
--optflags='-O2 -pipe -march=native -fomit-frame-pointer' 
--extra-cflags='-O2 -pipe -march=native -fomit-frame-pointer' 
--extra-cxxflags='-O2 -pipe -march=native -fomit-frame-pointer' 
--disable-static --enable-gpl --enable-postproc --enable-avfilter 
--enable-avresample --disable-stripping --enable-nonfree 
--disable-indev=v4l2 --disable-outdev=v4l2 --disable-indev=alsa 
--disable-indev=oss --disable-indev=jack --disable-outdev=alsa 
--disable-outdev=oss --disable-outdev=sdl --enable-bzlib 
--disable-runtime-cpudetect --disable-debug --disable-doc 
--disable-gnutls --enable-hardcoded-tables --enable-iconv 
--enable-network --disable-openssl --disable-ffplay --disable-vaapi 
--disable-vdpau --enable-zlib --disable-libvo-aacenc 
--disable-libvo-amrwbenc --enable-libmp3lame --disable-libfdk-aac 
--disable-libaacplus --enable  libavutil      52. 38.100 / 52. 38.100
  libavcodec     55. 18.102 / 55. 18.102
  libavformat    55. 12.100 / 55. 12.100
  libavdevice    55.  3.100 / 55.  3.100
  libavfilter     3. 79.101 /  3. 79.101
  libavresample   1.  1.  0 /  1.  1.  0
  libswscale      2.  3.100 /  2.  3.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  3.100 / 52.  3.100
[h264 @ 0x3c521310c0] Warning: not compiled with thread support, using thread emulation
Input #0, matroska,webm, from 'Fieldmatch.mkv':
  Metadata:
    ENCODER         : Lavf55.12.100
  Duration: 00:01:00.21, start: 0.000000, bitrate: 2614 kb/s
    Chapter #0.0: start 0.000000, end 60.224000
    Metadata:
      title           : Chapter 01
   
 Stream #0:0(eng): Video: h264 (High), yuv420p, 720x480 [SAR 186:157 DAR
 279:157], 59.94 fps, 59.94 tbr, 1k tbn, 119.88 tbc (default)
[h264 @ 0x3c521310c0] Warning: not compiled with thread support, using thread emulation

$ ffprobe Fieldmatch-Decimate.mkv 
ffprobe version 2.0.2 Copyright (c) 2007-2013 the FFmpeg developers
  built on Nov  6 2013 20:33:17 with gcc 4.7.3 (Gentoo Hardened 4.7.3-r1 p1.3, pie-0.5.5)
  configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --enable-shared --cc=x86_64-pc-linux-gnu-gcc --cxx=x86_64-pc-linux-gnu-g++ --ar=x86_64-pc-linux-gnu-ar --optflags='-O2 -pipe -march=native -fomit-frame-pointer' --extra-cflags='-O2 -pipe -march=native -fomit-frame-pointer' --extra-cxxflags='-O2 -pipe -march=native -fomit-frame-pointer' --disable-static --enable-gpl --enable-postproc --enable-avfilter --enable-avresample --disable-stripping --enable-nonfree --disable-indev=v4l2 --disable-outdev=v4l2 --disable-indev=alsa --disable-indev=oss --disable-indev=jack --disable-outdev=alsa --disable-outdev=oss --disable-outdev=sdl --enable-bzlib --disable-runtime-cpudetect --disable-debug --disable-doc --disable-gnutls --enable-hardcoded-tables --enable-iconv --enable-network --disable-openssl --disable-ffplay --disable-vaapi --disable-vdpau --enable-zlib --disable-libvo-aacenc --disable-libvo-amrwbenc
 --enable-libmp3lame --disable-libfdk-aac --disable-libaacplus --enable  libavutil      52. 38.100 / 52. 38.100
  libavcodec     55. 18.102 / 55. 18.102
  libavformat    55. 12.100 / 55. 12.100
  libavdevice    55.  3.100 / 55.  3.100
  libavfilter     3. 79.101 /  3. 79.101
  libavresample   1.  1.  0 /  1.  1.  0
  libswscale      2.  3.100 /  2.  3.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  3.100 / 52.  3.100
[h264 @ 0x16fdffa1c0] Warning: not compiled with thread support, using thread emulation
Input #0, matroska,webm, from 'Fieldmatch-Decimate.mkv':
  Metadata:
    ENCODER         : Lavf55.12.100
  Duration: 00:00:30.14, start: 0.000000, bitrate: 3462 kb/s
    Chapter #0.0: start 0.000000, end 60.224000
    Metadata:
      title           : Chapter 01
    Stream #0:0(eng): Video: h264 (High), yuv420p, 720x480 [SAR 186:157 DAR 279:157], 47.95 fps, 47.95 tbr, 1k tbn, 95.90 tbc (default)
[h264 @ 0x16fdffa1c0] Warning: not compiled with thread support, using thread emulation


More information about the ffmpeg-user mailing list