VideoHelp Forum
+ Reply to Thread
Results 1 to 5 of 5
Thread
  1. Hello!

    I am trying to generate a raw video stream with luma only (monochrome, YUV400) 8bit pixel data using the following command:

    Code:
    ffmpeg -i input.mp4 -vcodec rawvideo -pix_fmt raw.yuv
    I also tried to use the following filter to extract only the luma channel. The end result was the same.

    Code:
    ffmpeg -i input.mp4 -vcodec rawvideo -pix_fmt gray -filter_complex 'extractplanes=y[y]' -map '[y]' raw.yuv
    After that I tried to h.264 encode the raw stream with the profiles that support monochrome pixel data (eg: high)

    Code:
    ffmpeg -f rawvideo -vcodec rawvideo -pix_fmt gray -s 640x512 -r 60 -i raw.yuv -codec:v libx264 -profile:v high -c:a copy out.mp4
    However, I always get the following error, which indicates that the raw stream is not in the monochrome format that I would have expected:

    Code:
    x264 [error]: high profile doesn't support 4:4:4
    I am new to ffmpeg and video formats in general. Can somebody please point out what I am missing?

    Thank you!
    Quote Quote  
  2. Member
    Join Date
    Aug 2013
    Location
    Central Germany
    Search PM
    On one hand, you may omit -profile:v high if you don't need it with a good reason, giving x264 a chance to automatically select the required option.

    On the other, you may be able to tweak the expectations of the x264 encoder with parameters like input-csp / output-csp if it was a separate encoder, but I am not sure how to handle that with x264 as an encoder library inside ffmpeg, sorry... maybe any other user here is more knowledgeable in this topic.

    As you apparently have a raw YUV source, I would recommend using x264 separately here, without ffmpeg wrapped around.

    One more suggestion: Instead of creating a headerless YUV file, try Y4M (YUV4MPEG), its header contains the video frame dimensions and the pixel format identifier, so you can care less about a few parameters.
    Last edited by LigH.de; 4th Jun 2020 at 07:08.
    Quote Quote  
  3. First of all, thank you very much for your quick reply.

    Regarding the -profile:v high parameter. I need to compare the performance of a software and hardware codec. Both need to run with the same profile.

    Thank you for your hint regarding the input-csp / output-csp options. I will look into that.
    Quote Quote  
  4. Your ffmpeg command lines worked for me. Starting with an AviSynth script that created a short 640x512 YV12 video:

    Code:
    ColorBars(width=640, height=512, pixel_type="YV12")
    Trim(0,99)
    saving as raw Y8:

    Code:
    ffmpeg -y -i cb.avs -vcodec rawvideo -pix_fmt gray raw.yuv
    then:

    Code:
    ffmpeg -y -f rawvideo -vcodec rawvideo -pix_fmt gray -s 640x512 -r 60 -i raw.yuv -codec:v libx264 -profile:v high -c:a copy out.mp4
    gave:

    Code:
    General
    Complete name                            : C:\Users\John\Desktop\out.mp4
    Format                                   : MPEG-4
    Format profile                           : Base Media
    Codec ID                                 : isom (isom/iso2/avc1/mp41)
    File size                                : 5.25 KiB
    Duration                                 : 1 s 667 ms
    Overall bit rate                         : 25.8 kb/s
    Writing application                      : Lavf58.29.100
    
    Video
    ID                                       : 1
    Format                                   : AVC
    Format/Info                              : Advanced Video Codec
    Format profile                           : High@L3.1
    Format settings                          : CABAC / 4 Ref Frames
    Format settings, CABAC                   : Yes
    Format settings, Reference frames        : 4 frames
    Codec ID                                 : avc1
    Codec ID/Info                            : Advanced Video Coding
    Duration                                 : 1 s 667 ms
    Bit rate                                 : 16.1 kb/s
    Width                                    : 640 pixels
    Height                                   : 512 pixels
    Display aspect ratio                     : 5:4
    Frame rate mode                          : Constant
    Frame rate                               : 60.000 FPS
    Color space                              : Y
    Bit depth                                : 8 bits
    Scan type                                : Progressive
    Bits/(Pixel*Frame)                       : 0.001
    Stream size                              : 3.27 KiB (62%)
    Writing library                          : x264 core 159
    Encoding settings                        : cabac=1 / ref=3 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=0 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=16 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=crf / mbtree=1 / crf=23.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
    Codec configuration box                  : avcC
    Image Attached Files
    Last edited by jagabo; 4th Jun 2020 at 08:34.
    Quote Quote  
  5. Thank you very much!

    I tried it on Windows and it worked fine too.
    Finally figured out that the version installed on linux was quite old (ffmpeg 3.4.7). After installing 4.2.3 everything worked fine
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!