1

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
Gabrielle
  • 812
  • 2
  • 7
  • 28
  • `-qp 0` will generate a a H264 stream with `Hi444P` profile. Many players don't support that. Try with `-qp 1` or greater value. And `yuv420p` pix_fmt. – Gyan May 02 '18 at 17:12
  • @Gyan didn't work either :( – Gabrielle May 02 '18 at 19:23
  • @zindarod I tried to run the command and it returned NO to me, but when I check the info from brew it gives me: ==> Dependencies Build: cmake ✔, pkg-config ✔ Required: eigen ✔, ffmpeg ✔, jpeg ✔, libpng ✔, libtiff ✔, openexr ✔, python ✔, python@2 ✔, numpy ✔, tbb ✔ Do you know if this is the same? Just a note, I tried to install brew install opencv --with-ffmpeg but brew would not recognize this option – Gabrielle May 02 '18 at 20:03
  • @zindarod According to brew docs, now they build opencv with ffmpeg by default... I jut don't know why your command still returns NO :( – Gabrielle May 02 '18 at 20:18
  • @zindarod I was able to turn `NO` into `YES` with `brew install opencv --with-ffmpeg -v` and `brew link --overwrite opencv` but this did not make the video to work :( even also applying the changes proposed by @Gyan – Gabrielle May 02 '18 at 20:27
  • The other part of the answer is: `DEV.LS h264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (encoders: libx264 libx264rgb h264_videotoolbox ) D.A.L. avc On2 Audio for Video Codec (decoders: on2avc )` – Gabrielle May 02 '18 at 20:30
  • Hummm no, `Failed to open file '/video_1524082532.mp4' or configure filtergraph`, is the absolute path, I just replaced here, and yes, the file exists.. the file was generated by ffmpeg – Gabrielle May 02 '18 at 20:32
  • Did the new ffmpeg command have an error, or did the new video just not play in QuickTime? Show your new command and the complete console output. – llogan May 02 '18 at 22:16
  • @LordNeckbeard I've updated my question. One thing that zindarod pointed is that the video does not play in the ffmpeg alone... The video is generated, it can be played by VLC, but QuickPlayer says "QuickTime Player can't open "video_test.mp4"." – Gabrielle May 02 '18 at 23:41
  • I was able to make the ffmpeg play the mkv alone... not the mp4 – Gabrielle May 02 '18 at 23:47
  • As Gyan mentioned many players won't play yuv444p. Change it to yuv420p. – llogan May 03 '18 at 01:18
  • @LordNeckbeard I receive this error: Selected pixel format (yuv420p) is not supported by the input device. – Gabrielle May 03 '18 at 14:53
  • It's an output option so placement matters: `ffmpeg -y -f avfoundation -video_size 1980x1140 -framerate 30 -i '1' -vcodec libx264 -preset ultrafast -an -qp 2 -pix_fmt yuv420p video_test.mp4` – llogan May 03 '18 at 18:08

1 Answers1

0

I was able to make it work on OpenCV (not QuickPlayer).

This helped me a lot because my OpenCV was installed wrongly (not linked with ffmpeg). I had to brew install opencv --with-ffmpeg -v and brew link --overwrite opencv.

I changed the qp to 2 and also rebuilt ffmpeg from source.

Thanks to @zindarod and @Gyan

Gabrielle
  • 812
  • 2
  • 7
  • 28