Search code examples
videoffmpegh.264video-processingvideo-encoding

Using ffmpeg results in undesirable motion blur


I am trying to convert a video with the best quality possible. The problem is, no matter which command arguments I use, a motion blur appears (the first image is converted, the second is the original):

Converted Original

The ffprobe's output of the original video:

ffmpeg version 4.2.2-1ubuntu1 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 9 (Ubuntu 9.3.0-3ubuntu1)
configuration: --prefix=/usr --extra-version=1ubuntu1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil      56. 31.100 / 56. 31.100
libavcodec     58. 54.100 / 58. 54.100
libavformat    58. 29.100 / 58. 29.100
libavdevice    58.  8.100 / 58.  8.100
libavfilter     7. 57.100 /  7. 57.100
libavresample   4.  0.  0 /  4.  0.  0
libswscale      5.  5.100 /  5.  5.100
libswresample   3.  5.100 /  3.  5.100
libpostproc    55.  5.100 / 55.  5.100
Input #0, mpegts, from 'input.ts':
Duration: 00:00:30.24, start: 1.400000, bitrate: 26265 kb/s
Program 1
    Metadata:
    service_name    : Service01
    service_provider: FFmpeg
    Stream #0:0[0x100]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, top first), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x101](ita): Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, 5.1(side), fltp, 448 kb/s (clean effects)

I've tried different combinations of the following arguments:

ffmpeg \
-i input.ts \
-c:v libx264 \
-preset veryslow \
-qp 0 \
-minrate 25165824 \
-b:v 25165824 \
-r 25 \
-s 1920x1080 \
-aspect 16:9 \
-g 25 \
-crf 7 \
output.ts

None of these settings helped. Please, could you tell me how to remove this motion blur?

EDIT: to be more specific, I leave a link to a shorten video (~10 seconds). If you manage to convert it to hls (h.264 & .m3u8) without motion blur and with preserving the overall quality, it will be equivalent to the answer.


Solution

  • I think your problem is related to interlacing so you need to de-interlace the video.

    Looking at FFprobe's output of yuv420p(tv, top first), this is a clue that your video (per frame) is indeed interlaced and with top-field first then bottom-field second.

    Possible solution:

    a) try using BWdif:

    ffmpeg -i input.ts -vf bwdif -c:v libx264 -preset slow -crf 19 -pix_fmt yuv420p -c:a copy output.ts
    

    b) try using W3Fdif:

    ffmpeg -i input.ts -vf setfield=tff,w3fdif -c:v libx264 -preset slow -crf 19 -pix_fmt yuv420p -c:a copy output2.ts
    

    Let me know if it helps.