Opened 4 years ago

Closed 4 years ago

#4812 closed defect (fixed)

scale filter does not apply pure range change

Reported by: rmk Owned by:
Priority: normal Component: avfilter
Version: git-master Keywords: scale
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

It appears the scale filter (or libswscale underneath) does not scale the input if only the range (tv vs. pc) has to be changed.

Steps to reproduce:

1) Produce a file that contains tv range (16-235) luma values

ffmpeg -i ~/tmp/colortest/gradient-broadcast-range.mov -vf scale=in_range=tv:out_range=pc -c:v ffv1 ~/tmp/colortest/tv-to-full.mov
ffmpeg version N-74650-ga16251a Copyright (c) 2000-2015 the FFmpeg developers
  built with Apple LLVM version 6.1.0 (clang-602.0.49) (based on LLVM 3.6.0svn)
  configuration: --enable-gpl
  libavutil      54. 31.100 / 54. 31.100
  libavcodec     56. 58.100 / 56. 58.100
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 37.100 /  5. 37.100
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc    53.  3.100 / 53.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/krueger/tmp/colortest/gradient-broadcast-range.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 512
    compatible_brands: qt  
    encoder         : Lavf56.40.101
  Duration: 00:00:00.04, start: 0.000000, bitrate: 2628 kb/s
    Stream #0:0(eng): Video: ffv1 (FFV1 / 0x31564646), yuv420p, 256x256, 2483 kb/s, 25 fps, 25 tbr, 12800 tbn, 12800 tbc (default)
    Metadata:
      handler_name    : DataHandler
      encoder         : Lavc56.58.100 ffv1
[mov @ 0x7fea32013200] Using MS style video codec tag, the file may be unplayable!
Output #0, mov, to '/Users/krueger/tmp/colortest/tv-to-full.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 512
    compatible_brands: qt  
    encoder         : Lavf56.40.101
    Stream #0:0(eng): Video: ffv1, yuv420p, 256x256, q=2-31, 200 kb/s, 25 fps, 12800 tbn, 25 tbc (default)
    Metadata:
      handler_name    : DataHandler
      encoder         : Lavc56.58.100 ffv1
Stream mapping:
  Stream #0:0 -> #0:0 (ffv1 (native) -> ffv1 (native))
Press [q] to stop, [?] for help
frame=    1 fps=0.0 q=-0.0 Lsize=      13kB time=00:00:00.04 bitrate=2628.6kbits/s    
video:12kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 5.846823%

2) Verify the range is correct

ffprobe  -f lavfi movie=/Users/krueger/tmp/colortest/gradient-broadcast-range.mov,signalstats -show_entries frame_tags=lavfi.signalstats.YMAX,lavfi.signalstats.YMIN
ffprobe version N-74650-ga16251a Copyright (c) 2007-2015 the FFmpeg developers
  built with Apple LLVM version 6.1.0 (clang-602.0.49) (based on LLVM 3.6.0svn)
  configuration: --enable-gpl
  libavutil      54. 31.100 / 54. 31.100
  libavcodec     56. 58.100 / 56. 58.100
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 37.100 /  5. 37.100
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc    53.  3.100 / 53.  3.100
Input #0, lavfi, from 'movie=/Users/krueger/tmp/colortest/gradient-broadcast-range.mov,signalstats':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 256x256 [SAR 1:1 DAR 1:1], 12800 tbr, 12800 tbn, 12800 tbc
[FRAME]
TAG:lavfi.signalstats.YMIN=16
TAG:lavfi.signalstats.YMAX=235
[/FRAME]

3) Attempt to scale this to full range

ffmpeg -i ~/tmp/colortest/gradient-broadcast-range.mov -vf scale=in_range=tv:out_range=pc -c:v ffv1 -y ~/tmp/colortest/tv-to-full.mov
ffmpeg version N-74650-ga16251a Copyright (c) 2000-2015 the FFmpeg developers
  built with Apple LLVM version 6.1.0 (clang-602.0.49) (based on LLVM 3.6.0svn)
  configuration: --enable-gpl
  libavutil      54. 31.100 / 54. 31.100
  libavcodec     56. 58.100 / 56. 58.100
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 37.100 /  5. 37.100
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc    53.  3.100 / 53.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/krueger/tmp/colortest/gradient-broadcast-range.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 512
    compatible_brands: qt  
    encoder         : Lavf56.40.101
  Duration: 00:00:00.04, start: 0.000000, bitrate: 190 kb/s
    Stream #0:0(eng): Video: ffv1 (FFV1 / 0x31564646), yuv420p, 256x256, 45 kb/s, 25 fps, 25 tbr, 12800 tbn, 12800 tbc (default)
    Metadata:
      handler_name    : DataHandler
      encoder         : Lavc56.58.100 ffv1
[mov @ 0x7fed4080fc00] Using MS style video codec tag, the file may be unplayable!
Output #0, mov, to '/Users/krueger/tmp/colortest/tv-to-full.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 512
    compatible_brands: qt  
    encoder         : Lavf56.40.101
    Stream #0:0(eng): Video: ffv1, yuv420p, 256x256, q=2-31, 200 kb/s, 25 fps, 12800 tbn, 25 tbc (default)
    Metadata:
      handler_name    : DataHandler
      encoder         : Lavc56.58.100 ffv1
Stream mapping:
  Stream #0:0 -> #0:0 (ffv1 (native) -> ffv1 (native))
Press [q] to stop, [?] for help
frame=    1 fps=0.0 q=-0.0 Lsize=       1kB time=00:00:00.04 bitrate= 190.2kbits/s    
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 322.666656%

4) Check actual range of output file

ffprobe  -f lavfi movie=/Users/krueger/tmp/colortest/tv-to-full.mov,signalstats -show_entries frame_tags=lavfi.signalstats.YMAX,lavfi.signalstats.YMIN
ffprobe version N-74650-ga16251a Copyright (c) 2007-2015 the FFmpeg developers
  built with Apple LLVM version 6.1.0 (clang-602.0.49) (based on LLVM 3.6.0svn)
  configuration: --enable-gpl
  libavutil      54. 31.100 / 54. 31.100
  libavcodec     56. 58.100 / 56. 58.100
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 37.100 /  5. 37.100
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc    53.  3.100 / 53.  3.100
Input #0, lavfi, from 'movie=/Users/krueger/tmp/colortest/tv-to-full.mov,signalstats':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 256x256 [SAR 1:1 DAR 1:1], 12800 tbr, 12800 tbn, 12800 tbc
[FRAME]
TAG:lavfi.signalstats.YMIN=16
TAG:lavfi.signalstats.YMAX=235
[/FRAME]

Related discussion on the mailing list:
http://thread.gmane.org/gmane.comp.video.ffmpeg.user/57005/focus=57093

Attachments (1)

patchscale.diff (626 bytes) - added by cehoyos 4 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 Changed 4 years ago by cehoyos

Is there really a difference to ticket #4805?
(Can one ticket be fixed without the other?)

comment:2 Changed 4 years ago by cehoyos

  • Component changed from undetermined to swscale
  • Reproduced by developer set
  • Status changed from new to open
  • Version changed from unspecified to git-master

This is still reproducible with 1acd6311a100859f3ef4119790da9d5cb5546979 afaict.

comment:3 Changed 4 years ago by rmk

I just noticed, I made a copy & paste error in the ticket. The first step (generating the broadcast range file) should be this instead:

ffmpeg -f lavfi -i nullsrc=s=256x256 -vf geq='16+220*(X/W):128:128' -pix_fmt yuv420p -vframes 1 -c:v ffv1 -y ~/tmp/colortest/gradient-broadcast-range.mov

comment:4 Changed 4 years ago by rmk

Yes, it's still there. Checked with current head (d5911e6963c0a50cd0ae8d964b08eb128d27b860).

Changed 4 years ago by cehoyos

comment:5 Changed 4 years ago by cehoyos

Does attached patch make a difference for you?

comment:6 Changed 4 years ago by rmk

Yes, looks good now:

[FRAME]
TAG:lavfi.signalstats.YMIN=0
TAG:lavfi.signalstats.YMAX=255
[/FRAME]

comment:7 Changed 4 years ago by cehoyos

  • Component changed from swscale to avfilter
  • Keywords scale added
  • Resolution set to fixed
  • Status changed from open to closed
Note: See TracTickets for help on using tickets.