I know that there are several posts about FFMpeg not working on QuickPlayer (and OpenCV) and other players supporting only YUV planar color space, but NONE of the solutions I've found worked for me.
I need it to run on OpenCV, but as far as I found, it will never run on OpenCV if it is not running on QuickPlayer, so, I think I might start fixing the QuickPlayer issue. The generated video is a screen record, and it works perfectly on VLC.
Configurations used:
MacOs High Sierra
ffmpeg version 4.0 (installed with: --with-opus --with-libvpx )
opencv version 3.4.1_4
Homebrew 1.6.2 (used to install ffmpeg and opencv)
Command used to record the video:
ffmpeg -f avfoundation -video_size 1980x1140 -framerate 30 -i '1'
-vcodec libx264 -preset ultrafast -an -qp 0 -pix_fmt yuv444p video.mkv -y
Note1: I already tried to change -pix_fmt
to yuv420p
Note2: I already tried to add -vf scale=640:-2,format=yuv420p
Note3: I already tried to re-install OpenCV --with-ffmpeg
Note4: I tried mkv
, mp4
, avi
. I really don't care about the extension, I just need it to work.
Note5: I need it to be a cross-plataform solution, as far as I read ffmpeg should work in all OS, but first I am trying to fix on mac and then I will check others...
Any ideas? Maybe a missing flag? A missing library?
@Gyan suggested me to change the qp flag to a number higher than 0, I did it
ffmpeg -f avfoundation -video_size 1980x1140 -framerate 30 -i '1' -vcodec libx264 -preset ultrafast -an -qp 2 -pix_fmt yuv444p video_test.mp4 -y
This is my output:
ffmpeg version 4.0 Copyright (c) 2000-2018 the FFmpeg developers
built with Apple LLVM version 9.0.0 (clang-900.0.39.2)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.0 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-ffplay --enable-frei0r --enable-libass --enable-libfdk-aac --enable-libfontconfig --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-librtmp --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma --enable-libopenjpeg --disable-decoder=jpeg2000 --extra-cflags=-I/usr/local/Cellar/openjpeg/2.3.0/include/openjpeg-2.3 --enable-nonfree
libavutil 56. 14.100 / 56. 14.100
libavcodec 58. 18.100 / 58. 18.100
libavformat 58. 12.100 / 58. 12.100
libavdevice 58. 3.100 / 58. 3.100
libavfilter 7. 16.100 / 7. 16.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 1.100 / 5. 1.100
libswresample 3. 1.100 / 3. 1.100
libpostproc 55. 1.100 / 55. 1.100
[avfoundation @ 0x7fbb8f80ee00] Selected pixel format (yuv420p) is not supported by the input device.
[avfoundation @ 0x7fbb8f80ee00] Supported pixel formats:
[avfoundation @ 0x7fbb8f80ee00] uyvy422
[avfoundation @ 0x7fbb8f80ee00] yuyv422
[avfoundation @ 0x7fbb8f80ee00] nv12
[avfoundation @ 0x7fbb8f80ee00] 0rgb
[avfoundation @ 0x7fbb8f80ee00] bgr0
[avfoundation @ 0x7fbb8f80ee00] Overriding selected pixel format to use uyvy422 instead.
[avfoundation @ 0x7fbb8f80ee00] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, avfoundation, from '1':
Duration: N/A, start: 118955.291667, bitrate: N/A
Stream #0:0: Video: rawvideo (UYVY / 0x59565955), uyvy422, 1440x900, 1000k tbr, 1000k tbn, 1000k tbc
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[mp4 @ 0x7fbb8f87d200] Frame rate very high for a muxer not efficiently supporting it.
Please consider specifying a lower framerate, a different muxer or -vsync 2
[libx264 @ 0x7fbb8f87f600] MB rate (5130000000) > level limit (16711680)
[libx264 @ 0x7fbb8f87f600] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x7fbb8f87f600] profile High 4:4:4 Predictive, level 6.2, 4:4:4 8-bit
[libx264 @ 0x7fbb8f87f600] 264 - core 152 r2854 e9a5903 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=6 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=25 scenecut=0 intra_refresh=0 rc=cqp mbtree=0 qp=2 ip_ratio=1.40 aq=0
Output #0, mp4, to 'video_test.mp4':
Metadata:
encoder : Lavf58.12.100
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv444p, 1440x900, q=-1--1, 1000k fps, 1000k tbn, 1000k tbc
Metadata:
encoder : Lavc58.18.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1