12

FFmpeg knows about duplicate frames in the input video stream as it outputs a message like this:

More than 1000 frames duplicated

Is there some way to tell it: "Not include duplicates into the output stream, please?"

EDIT (ADDED):

I tried this command (thanks to Mulvya):

ffmpeg -i scene.mkv -profile:v baseline -level 3.1 -vsync 0 -map 0:v  scene.mp4

and obtained the target video scene.mp4 with the same duration and (almost) identical in playback with original.

The command with full output of it is here:

>ffmpeg -i scene.mkv -profile:v baseline -level 3.1 -vsync 0 -map 0:v  scene.mp4
ffmpeg version N-83585-ga5c1c7a Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 5.4.0 (GCC)
  configuration: --enable-gpl --enable-version3 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nv
enc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libblur
ay --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-
libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-lib
rtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amr
wbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enabl
e-libxvid --enable-libzimg --enable-lzma --enable-zlib
  libavutil      55. 47.100 / 55. 47.100
  libavcodec     57. 80.101 / 57. 80.101
  libavformat    57. 66.102 / 57. 66.102
  libavdevice    57.  2.100 / 57.  2.100
  libavfilter     6. 73.100 /  6. 73.100
  libswscale      4.  3.101 /  4.  3.101
  libswresample   2.  4.100 /  2.  4.100
  libpostproc    54.  2.100 / 54.  2.100
Input #0, matroska,webm, from 'scene.mkv':
  Metadata:
    encoder         : libmkv 0.6.5
    TITLE           : New Project
    DIRECTOR        : Big Mac
    COMPOSER        : Big Mac
    DESCRIPTION     : This video is about New Project
  Duration: 00:03:11.93, start: 0.000000, bitrate: 1025 kb/s
    Stream #0:0(eng): Video: h264 (High), yuv420p(tv, smpte170m/smpte170m/bt709, progressive), 640x480 [SAR 1:1 DAR 4:3], 30 fps, 30 tbr
, 1k tbn, 180k tbc (default)
    Stream #0:1(eng): Audio: aac (LC), 48000 Hz, stereo, fltp (default)
    Stream #0:2(eng): Audio: ac3, 48000 Hz, stereo, fltp, 224 kb/s
[libx264 @ 00000000005c6c40] using SAR=1/1
[libx264 @ 00000000005c6c40] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 00000000005c6c40] profile Constrained Baseline, level 3.1
[libx264 @ 00000000005c6c40] 264 - core 148 r2762 90a61ec - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.h
tml - options: cabac=0 ref=3 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 t
rellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 i
nterlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 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 'scene.mp4':
  Metadata:
    DESCRIPTION     : This video is about New Project
    TITLE           : New Project
    DIRECTOR        : Big Mac
    COMPOSER        : Big Mac
    encoder         : Lavf57.66.102
    Stream #0:0(eng): Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 640x480 [SAR 1:1 DAR 4:3], q=-1--1, 30 fps, 15360 tbn, 30
 tbc (default)
    Metadata:
      encoder         : Lavc57.80.101 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Press [q] to stop, [?] for help
frame= 4602 fps=185 q=-1.0 Lsize=   10688kB time=00:03:11.90 bitrate= 456.3kbits/s speed= 7.7x
video:10651kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.349428%
[libx264 @ 00000000005c6c40] frame I:24    Avg QP:20.07  size: 27706
[libx264 @ 00000000005c6c40] frame P:4578  Avg QP:21.30  size:  2237
[libx264 @ 00000000005c6c40] mb I  I16..4: 20.4%  0.0% 79.6%
[libx264 @ 00000000005c6c40] mb P  I16..4:  2.0%  0.0%  2.4%  P16..4: 22.9%  4.2%  1.3%  0.0%  0.0%    skip:67.3%
[libx264 @ 00000000005c6c40] coded y,uvDC,uvAC intra: 47.9% 84.7% 30.2% inter: 4.5% 23.4% 0.6%
[libx264 @ 00000000005c6c40] i16 v,h,dc,p: 36% 26% 11% 26%
[libx264 @ 00000000005c6c40] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 31% 23% 13%  5%  7%  8%  5%  5%  3%
[libx264 @ 00000000005c6c40] i8c dc,h,v,p: 39% 26% 27%  8%
[libx264 @ 00000000005c6c40] ref P L0: 82.8% 10.5%  6.7%
[libx264 @ 00000000005c6c40] kb/s:454.58
7
  • Without any details, my guess would be to add -vsync 0 as an output option.
    – Gyan
    Mar 18, 2017 at 12:43
  • @Mulvya - Thanks - by your answer it seems that I misunderstood the cited message. It probably says about duplicated time stamps and not about identical frames - which is my problem. I have many groups of identical frames and my goal is to put only 1 exemplar of successive identical frames into the output stream.
    – MarianD
    Mar 18, 2017 at 16:19
  • @Mulvya - To be honest I don't know if I really have groups of identical frames - I deducted it only from playback of the video. Your -vsync 0 didn't help.
    – MarianD
    Mar 18, 2017 at 16:30
  • Need to see command and full console log.
    – Gyan
    Mar 18, 2017 at 16:44
  • @Mulvya - Thank for your goodwill, I added them into my question.
    – MarianD
    Mar 18, 2017 at 18:56

1 Answer 1

15

Don't see any frames duplicated. The message you quoted - More than 1000 frames duplicated - is not ffmpeg's analysis of the input. FFmpeg duplicates or drops frames when the input and output framerates differ. You need to use the mpdecimate filter to remove duplicates in the input:

ffmpeg -i input.mp4 -vf mpdecimate,setpts=N/FRAME_RATE/TB out.mp4
4
  • I used above command but voice and video are not sinked Apr 27, 2019 at 12:03
  • 4
    Use ffmpeg -i input.mp4 -vf mpdecimate -c:a copy -vsync vfr out.mp4. The duration will be the same but the duplicate frames will be gone.
    – Gyan
    Apr 28, 2019 at 4:51
  • did not work I have a bad problem with DVB mpg recorded files. FFMPG can not edit these files. ![enter image description here](i.stack.imgur.com/f12Qf.jpg) I've used above command then video has converted but sound and video not sink Apr 28, 2019 at 6:04
  • I tried the solution here and none of them seem to work when you need to trim the video and keep the audio. I found a solution I explained here
    – Human
    Apr 29, 2021 at 17:50

Not the answer you're looking for? Browse other questions tagged or ask your own question.