Quantcast

Scaling legal video levels

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Scaling legal video levels

spookybathtub
I am trying to convert a single-frame H.264 MKV to a JPEG image.  Unfortunately the output is always clipped at 235.  The source video is full-range, and I want to keep it full-range.  Sample attached to this email.  The clipping can be seen quite obviously with this test pattern.
If I instead rewrap from MKV to MOV with “vcodec copy”, it works correctly.  It seems like ffmpeg is treating the source as legal range, so I need to force it to treat the input as full range?

$ ffmpeg -i title01.mkv -q:v 1 title01.jpg
ffmpeg version 3.0.git Copyright (c) 2000-2016 the FFmpeg developers
  built with Apple LLVM version 7.0.2 (clang-700.1.81)
  configuration: --prefix=/opt/local --enable-swscale --enable-avfilter --enable-avresample --enable-libmp3lame --enable-libvorbis --enable-libopus --enable-libtheora --enable-libschroedinger --enable-libopenjpeg --enable-libmodplug --enable-libvpx --enable-libsoxr --enable-libspeex --enable-libass --enable-libbluray --enable-lzma --enable-gnutls --enable-fontconfig --enable-libfreetype --enable-libfribidi --disable-indev=jack --disable-outdev=xv --mandir=/opt/local/share/man --enable-shared --enable-pthreads --cc=/usr/bin/clang --enable-vda --enable-audiotoolbox --enable-videotoolbox --arch=x86_64 --enable-yasm --enable-gpl --enable-postproc --enable-libx264 --enable-libxvid --enable-nonfree --enable-libfdk-aac --enable-libfaac
  libavutil      55. 28.100 / 55. 28.100
  libavcodec     57. 51.100 / 57. 51.100
  libavformat    57. 46.100 / 57. 46.100
  libavdevice    57.  0.102 / 57.  0.102
  libavfilter     6. 50.100 /  6. 50.100
  libavresample   3.  0.  0 /  3.  0.  0
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
  libpostproc    54.  0.100 / 54.  0.100
[h264 @ 0x7feb34804600] sps_id 1 out of range
[matroska,webm @ 0x7feb35000000] decoding for stream 0 failed
Input #0, matroska,webm, from 'title01.mkv':
  Metadata:
    encoder         : libmakemkv v1.10.4 (1.3.3/1.4.4) win(x64-release)
    creation_time   : 2017-02-17 04:27:15
  Duration: 00:00:00.04, bitrate: 9301 kb/s
    Stream #0:0(eng): Video: h264 (High), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc
    Metadata:
      stereo_mode     : block_lr
      BPS-eng         : 8681560
      DURATION-eng    : 00:00:00.041708333
      NUMBER_OF_FRAMES-eng: 1
      NUMBER_OF_BYTES-eng: 44493
      SOURCE_ID-eng   : 001011
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.10.4 win(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2017-02-17 04:27:15
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
    Side data:
      stereo3d: frame alternate
[swscaler @ 0x7feb35009000] deprecated pixel format used, make sure you did set range correctly
[image2 @ 0x7feb34006400] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Output #0, image2, to 'title01.jpg':
  Metadata:
    encoder         : Lavf57.46.100
    Stream #0:0(eng): Video: mjpeg, yuvj420p(pc), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 23.98 fps, 23.98 tbn, 23.98 tbc
    Metadata:
      stereo_mode     : block_lr
      BPS-eng         : 8681560
      DURATION-eng    : 00:00:00.041708333
      NUMBER_OF_FRAMES-eng: 1
      NUMBER_OF_BYTES-eng: 44493
      SOURCE_ID-eng   : 001011
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.10.4 win(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2017-02-17 04:27:15
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
      encoder         : Lavc57.51.100 mjpeg
    Side data:
      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> mjpeg (native))
Press [q] to stop, [?] for help
[h264 @ 0x7feb3380d200] sps_id 1 out of range
frame=    1 fps=0.0 q=1.0 Lsize=N/A time=00:00:00.04 bitrate=N/A speed= 1.8x    
video:90kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown




_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".

title01.mkv (63K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Scaling legal video levels

Carl Eugen Hoyos-2
2017-02-17 2:39 GMT+01:00 Elliott Balsley <[hidden email]>:
> I am trying to convert a single-frame H.264 MKV to a JPEG image.
> Unfortunately the output is always clipped at 235.

> The source video is full-range

FFmpeg does not detect full-range video (video_signal_type_present_flag
is 0, the default is limited-range), both FFmpeg and the reference
decoder report a broken h264 frame (different warnings are shown).

Which encoder created the frame and which decoder shows
full-range?

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Scaling legal video levels

spookybathtub
The source was ripped from a BluRay using MakeMKV, which does not re-encode, it just rewraps the stream. I don't know how the BluRay was originally encoded.
If I convert this MKV to MOV using ffmpeg (without re-encoding), I can then open it in DaVinci Resolve and measure the levels as full range.

> On Feb 17, 2017, at 01:08, Carl Eugen Hoyos <[hidden email]> wrote:
>
> 2017-02-17 2:39 GMT+01:00 Elliott Balsley <[hidden email]>:
>> I am trying to convert a single-frame H.264 MKV to a JPEG image.
>> Unfortunately the output is always clipped at 235.
>
>> The source video is full-range
>
> FFmpeg does not detect full-range video (video_signal_type_present_flag
> is 0, the default is limited-range), both FFmpeg and the reference
> decoder report a broken h264 frame (different warnings are shown).
>
> Which encoder created the frame and which decoder shows
> full-range?
>
> Carl Eugen
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Scaling legal video levels

Andy Furniss-2
In reply to this post by spookybathtub
Elliott Balsley wrote:
> I am trying to convert a single-frame H.264 MKV to a JPEG image.
> Unfortunately the output is always clipped at 235.  The source video
> is full-range, and I want to keep it full-range.  Sample attached to
> this email.  The clipping can be seen quite obviously with this test
> pattern. If I instead rewrap from MKV to MOV with “vcodec copy”, it
> works correctly.  It seems like ffmpeg is treating the source as
> legal range, so I need to force it to treat the input as full range?

-vf scale=in_range=full

Works on this sample. Also be aware that ffmpeg when doing CSC defaults
to Rec.601 which would need tweaking if the output were eg. png.

https://www.ffmpeg.org/ffmpeg-filters.html#scale-1

If input is 709 but "unflagged" you should also be looking to set trc.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Loading...