47

Why am I getting this warning and how to fix it? Essentially, I want to convert a video to a jpg every 4th frame with the same resolution as original video.

[jalal@goku vid2]$ ffmpeg -i debate_vid2.mov -r 0.25 images_%08d.jpg
ffmpeg version 2.6.8 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-4)
  configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic' --enable-bzlib --disable-crystalhd --enable-gnutls --enable-ladspa --enable-libass --enable-libcdio --enable-libdc1394 --enable-libfaac --enable-nonfree --enable-libfdk-aac --enable-nonfree --disable-indev=jack --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-openal --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libx264 --enable-libx265 --enable-libxvid --enable-x11grab --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-runtime-cpudetect
  libavutil      54. 20.100 / 54. 20.100
  libavcodec     56. 26.100 / 56. 26.100
  libavformat    56. 25.101 / 56. 25.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 11.102 /  5. 11.102
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'debate_vid2.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 0
    compatible_brands: qt  
    creation_time   : 2017-03-10 02:45:46
  Duration: 01:36:50.03, start: 0.000000, bitrate: 785 kb/s
    Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 95 kb/s (default)
    Metadata:
      creation_time   : 2017-03-10 02:45:46
      handler_name    : Core Media Data Handler
    Stream #0:1(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 334x360 [SAR 1:1 DAR 167:180], 685 kb/s, 30 fps, 30 tbr, 600 tbn, 1200 tbc (default)
    Metadata:
      creation_time   : 2017-03-10 02:45:46
      handler_name    : Core Media Data Handler
      encoder         : H.264
[swscaler @ 0x1bb4240] deprecated pixel format used, make sure you did set range correctly
Output #0, image2, to 'images_%08d.jpg':
  Metadata:
    major_brand     : qt  
    minor_version   : 0
    compatible_brands: qt  
    encoder         : Lavf56.25.101
    Stream #0:0(und): Video: mjpeg, yuvj420p(pc), 334x360 [SAR 1:1 DAR 167:180], q=2-31, 200 kb/s, 0.25 fps, 0.25 tbn, 0.25 tbc (default)
    Metadata:
      creation_time   : 2017-03-10 02:45:46
      handler_name    : Core Media Data Handler
      encoder         : Lavc56.26.100 mjpeg
Stream mapping:
  Stream #0:1 -> #0:0 (h264 (native) -> mjpeg (native))
Press [q] to stop, [?] for help
frame= 1454 fps= 25 q=1.6 Lsize=N/A time=01:36:56.00 bitrate=N/A dup=0 drop=172847    
video:28470kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[jalal@goku vid2]$ 

2 Answers2

52

If you are just converting videos using ffmpeg, this is just a warning, not an error, and nothing to worry about.

You can safely ignore the message when using ffmpeg from the command-line, and you don't have to fix anything.

Background:

The warning occurs when converting from a yuv420p source to JPEG, which makes ffmpeg choose yuvj420p as output format. That format is required for writing files with the mjpeg encoder.

These two pixel formats have different color ranges: yuv420p is from 16–235, which is "limited range" (also called "MPEG" range); yuvj420p defaults to 0–255, which is "full range".

This difference in color formats (which were selected automatically) makes ffmpeg trigger that specific warning message, telling you to make sure you set the color range correctly.

The warning is primarly meant for developers who use FFmpeg as a library in their own code (like here). See also the comments on this question. The specific deprecation is listed here:

planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting color_range

slhck
  • 228,104
  • same issue. and for me ffmpeg -version ffmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers – ses Aug 29 '21 at 03:53
  • 13
    Ignoring a warning isn't a fix – Konrad Nov 23 '21 at 19:23
  • 1
    @KonradLinkowski What are you suggesting? As an end user, it won't have any effect. If you think the message can be improved in terms of clarity, please send a patch to ffmpeg-devel. As far as I can tell it was introduced to fix a different bug 8 years ago and hasn't been touched since. – slhck Nov 24 '21 at 11:00
  • 3
    @KonradLinkowski FWIW I proposed a patch: https://patchwork.ffmpeg.org/project/ffmpeg/patch/20211124115738.84650-1-werner.robitza@gmail.com/ – slhck Nov 24 '21 at 12:09
  • @slhck Thanks for submitting the patch. Is this now integrated into the latest versions of FFmpeg? – Hashim Aziz Feb 10 '22 at 18:19
  • @HashimAziz No, I never got feedback on it. – slhck Feb 10 '22 at 19:49
  • @slhck That's annoying, I assumed because the checks had passed it would be a done deal, there's no real reason why this shouldn't go ahead. I can't program well enough to directly contribute but if I can otherwise help in getting the patch applied, let me know. – Hashim Aziz Feb 10 '22 at 20:27
  • 2
    @HashimAziz You're right. It's not a technical issue, more of an organizational one. There's probably not much you can do other than reply to the thread on ffmpeg-devel and ask what's up with the patch. – slhck Feb 11 '22 at 15:51
  • The warning was introduced here actually. And AFAICT and AFAIU the plan was always more or less to have the JPEG formats removed. It's just that you need manpower for that, and fix all the other "surrounding" bugs. – mirh Mar 30 '22 at 11:55
  • Just a note saying this is still not 'fixed', 5 years later... – Julius Jul 05 '22 at 19:32
  • @slhck hi, by saying the former is from 16–235, the former is yuv420p, the latter is yuvj420p right? – http8086 Nov 24 '22 at 07:20
3

As explained in the accepted answer, it's just a warning which can be ignored.

If processing many files, you can reduce the output of ffmpeg using the -loglevel option described here. Setting it to -loglevel error will suppress these and other warnings.

So, using your example, something like this:

ffmpeg -loglevel error -i debate_vid2.mov -r 0.25 images_%08d.jpg
mivk
  • 3,726