Den 07.05.2025 01:04, skrev Andrew Randrianasulu:


ср, 7 мая 2025 г., 01:58 Terje J. Hanssen <terjejhans...@gmail.com>:



    Den 06.05.2025 22:54, skrev Andrew Randrianasulu:


    вт, 6 мая 2025 г., 23:49 Terje J. Hanssen <terjejhans...@gmail.com>:



        Den 05.05.2025 16:05, skrev Andrew Randrianasulu:


        пн, 5 мая 2025 г., 17:00 Andrew Randrianasulu
        <randrianas...@gmail.com>:



            пн, 5 мая 2025 г., 16:26 Terje J. Hanssen via Cin
            <cin@lists.cinelerra-gg.org>:

                I consider to make a second preservation backup for
                archiving my Analog S-video and HDV footages on
                tapes to lossless compressed FFV1.MKV files stored
                on large USB3 expansion disks. Also ffv1 HW (vulkan)
                decoding (next and encoding (later?) are of interest
                in this context.

                Related previous threads
                
https://www.mail-archive.com/cin@lists.cinelerra-gg.org/msg05547.html
                
https://www.mail-archive.com/cin@lists.cinelerra-gg.org/msg03791.html
                
https://www.mail-archive.com/cin@lists.cinelerra-gg.org/msg05547.html

                I adapt simply the last ffmpeg mpeg-2 code line to a
                first ffv1, version 3 test, 10 sec file

                ffmpeg -hide_banner -f v4l2 -input_format yuyv422
                -video_size 720x576 -framerate 50 -i /dev/video0 -f
                alsa -ac 2 -i hw:CARD=UHD,DEV=0 -c:v ffv1 -level 3
                -c:a pcm_s16le -t 10
                720x576_50fps+alsa_ms2130_ffv1-3+pcm.mkv

                    Input #0, video4linux2,v4l2, from '/dev/video0':
                      Duration: N/A, start: 351.803278, bitrate:
                    331776 kb/s
                      Stream #0:0: Video: rawvideo (YUY2 /
                    0x32595559), yuyv422, 720x576, 331776 kb/s, 50
                    fps, 50 tbr, 1000k tbn
                    [aist#1:0/pcm_s16le @ 0x555a99736cc0] Guessed
                    Channel Layout: stereo
                    Input #1, alsa, from 'hw:CARD=UHD,DEV=0':
                      Duration: N/A, start: 1746445045.742179,
                    bitrate: 1536 kb/s
                      Stream #1:0: Audio: pcm_s16le, 48000 Hz,
                    stereo, s16, 1536 kb/s
                    Stream mapping:
                      Stream #0:0 -> #0:0 (rawvideo (native) -> ffv1
                    (native))
                      Stream #1:0 -> #0:1 (pcm_s16le (native) ->
                    pcm_s16le (native))
                    Press [q] to stop, [?] for help
                    Output #0, matroska, to
                    '720x576_50fps+alsa_ms2130_ffv1-3+pcm.mkv':
                      Metadata:
                        encoder         : Lavf61.7.100
                      Stream #0:0: Video: ffv1 (FFV1 / 0x31564646),
                    yuv422p(tv, progressive), 720x576, q=2-31, 200
                    kb/s, 50 fps, 1k tbn
                          Metadata:
                    encoder         : Lavc61.19.101 ffv1
                      Stream #0:1: Audio: pcm_s16le ([1][0][0][0] /
                    0x0001), 48000 Hz, stereo, s16, 1536 kb/s
                          Metadata:
                    encoder         : Lavc61.19.101 pcm_s16le
                    [out#0/matroska @ 0x555a99736f40] video:57467KiB
                    audio:1875KiB subtitle:0KiB other streams:0KiB
                    global headers:0KiB muxing overhead: 0.069226%
                    frame=  500 fps= 50 q=-0.0 Lsize= 59383KiB
                    time=00:00:10.00 bitrate=48646.9kbits/s
                    speed=0.998x


                ----------

                du -sh *
                58M 720x576_50fps+alsa_ms2130_ffv1-3+pcm.mkv

                ----------

                ffprobe -hide_banner
                720x576_50fps+alsa_ms2130_ffv1-3+pcm.mkv

                    Input #0, matroska,webm, from
                    '720x576_50fps+alsa_ms2130_ffv1-3+pcm.mkv':
                      Metadata:
                        ENCODER         : Lavf61.7.100
                      Duration: 00:00:10.00, start: 0.000000,
                    bitrate: 48646 kb/s
                      Stream #0:0: Video: ffv1 (FFV1 / 0x31564646),
                    yuv422p(tv, progressive), 720x576, 50 fps, 50
                    tbr, 1k tbn
                          Metadata:
                    ENCODER         : Lavc61.19.101 ffv1
                    DURATION        : 00:00:10.000000000
                      Stream #0:1: Audio: pcm_s16le, 48000 Hz, 2
                    channels, s16, 1536 kb/s
                          Metadata:
                    ENCODER         : Lavc61.19.101 pcm_s16le
                    DURATION        : 00:00:10.000000000


                ------------

                mediainfo 720x576_50fps+alsa_ms2130_ffv1-3+pcm.mkv

                    General
                    Unique ID :
                    158479793538002634101121179263279280827
                    (0x773A19163BEA6038DF448CE1529BB2BB)
                    Complete name :
                    720x576_50fps+alsa_ms2130_ffv1-3+pcm.mkv
                    Format                                   : Matroska
                    Format version : Version 4
                    File size : 58.0 MiB
                    Duration                                 : 10 s 0 ms
                    Overall bit rate mode : Variable
                    Overall bit rate : 48.6 Mb/s
                    Frame rate : 50.000 FPS
                    Writing application : Lavf61.7.100
                    Writing library : Lavf61.7.100
                    ErrorDetectionType                       : Per
                    level 1

                    Video
                    ID                                       : 1
                    Format                                   : FFV1
                    Format version : Version 3.4
                    Format settings, Slice count             : 4
                    slices per frame
                    Codec ID : V_MS/VFW/FOURCC / FFV1
                    Duration                                 : 10 s 0 ms
                    Bit rate mode : Variable
                    Bit rate : 46.1 Mb/s
                    Width                                    : 720
                    pixels
                    Height                                   : 576
                    pixels
                    Display aspect ratio : 5:4
                    Frame rate mode : Constant
                    Frame rate : 50.000 FPS
                    Color space : YUV
                    Chroma subsampling : 4:2:2
                    Bit depth : 8 bits
                    Scan type : Progressive
                    Compression mode : Lossless
                    Bits/(Pixel*Frame)                       : 2.225
                    Stream size : 55.0 MiB (95%)
                    Writing library : Lavc61.19.101 ffv1
                    Default                                  : No
                    Forced                                   : No
                    Color range : Limited
                    coder_type                               :
                    Golomb Rice
                    ErrorDetectionType                       : Per slice

                    Audio
                    ID                                       : 2
                    Format                                   : PCM
                    Format settings : Little / Signed
                    Codec ID : A_PCM/INT/LIT
                    Duration                                 : 10 s 0 ms
                    Bit rate mode : Constant
                    Bit rate : 1 536 kb/s
                    Channel(s)                               : 2
                    channels
                    Sampling rate : 48.0 kHz
                    Bit depth : 16 bits
                    Stream size : 1.83 MiB (3%)
                    Writing library : Lavc61.19.101 pcm_s16le
                    Default                                  : No
                    Forced                                   : No

                ---------------------------------

                As seen above the "default" Chroma subsampling  is
                yuv422p or 4:2:2 with Bit depth: 8 bits

                As ffv1 seemingly also does support yuv422p10le
                ffmpeg, I wonder if yuv422p is limited by the input
                from HDMI capture/AV converter?
                Can possibly yuv422p10le possibly be achieved by
                adding -pix_fmt 10 og similar syntax to the ffmpeg line?


            you can try different -input_format, but I suspect 10bit
            video over v4l2 at best uncommon ... While hdmi itself
            supports 10bit digital signal, I suspect non-pro capture
            devices usually limited to 8bit?


        
https://git.ffmpeg.org/gitweb/ffmpeg.git/blob/HEAD:/libavdevice/v4l2-common.c

        I can't see 10bit yuy2 format listed here, so probably even
        if hw/driver support it ffmpeg will not ...

        Yes, It seems this also is the case.
        Even I got a few 10-bits "-input_format" y210 and p210
        accepted by ffmpeg, in both cases the output format
        "defaulted" to the same 'yuv422p'.
        What also surprised me, the filesizes at the same time also
        was reduced to 77%

        du -sh *
        45M 720x576_50fps_p210+alsa_ms2130_ffv1-3+pcm.mkv
        45M 720x576_50fps_y210+alsa_ms2130_ffv1-3+pcm.mkv
        58M 720x576_50fps_yuyv422+alsa_ms2130_ffv1-3+pcm.mkv


    I guess they 10 bit but 4:2:0 subsampling?

    Noop, according to mediainfo all have

    Color space                              : YUV
    Chroma subsampling                       : 4:2:2
    Bit depth                                : 8 bits


But this is *after* they left ffmpeg ;)

All those auto-inserting filters may cut input stream according to that user specified, and then expand it back, but with less info, so lossless file will be smaller ....

just idea, not proven.

=================

I continue testing now with my Sony HDR-FX7E HDV 1080i50 camcorder, currently using only the camera Enhanced Image processor (EIP) via HDMI out.
That is not HDV tape (MPEG-2) playback yet as mentioned above.

v4l2-ctl -V
Format Video Capture:
    Width/Height      : 1920/1080
    Pixel Format      : 'YUYV' (YUYV 4:2:2)
    Field             : None
    Bytes per Line    : 3840
    Size Image        : 4147200
    Colorspace        : sRGB
    Transfer Function : Rec. 709
    YCbCr/HSV Encoding: ITU-R 601
    Quantization      : Default (maps to Limited Range)
    Flags             :

NB! v4l2 discovers the camcorder FX7 EIP's (Enhanced Imaging Processor) FHD capability

 ------------

ffmpeg -hide_banner -f v4l2 -list_formats all -i /dev/video0

[video4linux2,v4l2 @ 0x561a655c36c0] Raw       :     yuyv422 :           YUYV 4:2:2 : 1920x1080 1600x1200 1360x768 1280x1024 1280x960 1280x720 1024x768 800x600 720x576 720x480 640x480
[in#0 @ 0x561a655c3400] Error opening input: Immediate exit requested
Error opening input file /dev/video0.

1) First encoding test:
-----------------------------------
ffmpeg -hide_banner -f v4l2 -input_format yuyv422 -video_size 1920x1080 -framerate 50 -i /dev/video0 -f alsa -ac 2 -i hw:CARD=UHD,DEV=0 -c:v ffv1 -level 3 -c:a pcm_s16le -t 10 1920x1080_50fps_yuvy422+alsa_pcm_ffv1-3.mkv

resulted i output file with 8-bit yuv422p as previously


2) Second encoding test:
----------------------------------------
I specified 'y210' as both input format and as output pixel format.
ffprobe below show this interestingly created a 10-bit "yuv422p10le" output file as I wanted, and with a bit larger file size than first test without output pixel_format filter!

I wonder if this is better or a "fake" 10-bit color format?
and wants comments to what really happends here:

Is input via v4l2 a "raw camcorder video stream" that will be (re-)encoded to a ffv1.mkv video file format? And does specifying -vf format=pix_fmts='y210' cause some extra re-encoding than without specifying this output filter in this case?


ffmpeg -hide_banner -f v4l2 -input_format y210 -video_size 1920x1080 -framerate 50 -i /dev/video0 -f alsa -ac 2 -i hw:CARD=UHD,DEV=0 -c:v ffv1 -level 3 -vf format=pix_fmts='y210' -c:a pcm_s16le -t 10 1920x1080_50fps_y210+alsa_pcm_ffv1-3.mkv

   Input #0, video4linux2,v4l2, from '/dev/video0':
      Duration: N/A, start: 337.518694, bitrate: 1658880 kb/s
      Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422,
   1920x1080, 1658880 kb/s, 50 fps, 50 tbr, 1000k tbn
   [aist#1:0/pcm_s16le @ 0x559f06e972c0] Guessed Channel Layout: stereo
   Input #1, alsa, from 'hw:CARD=UHD,DEV=0':
      Duration: N/A, start: 1746635575.463474, bitrate: 1536 kb/s
      Stream #1:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
   Stream mapping:
      Stream #0:0 -> #0:0 (rawvideo (native) -> ffv1 (native))
      Stream #1:0 -> #0:1 (pcm_s16le (native) -> pcm_s16le (native))
   Press [q] to stop, [?] for help
   [ffv1 @ 0x559f06e7e280] bits_per_raw_sample > 8, forcing range coder
   Output #0, matroska, to '1920x1080_50fps_y210+alsa_pcm_ffv1-3.mkv':
      Metadata:
        encoder         : Lavf61.7.100
      Stream #0:0: Video: ffv1 (FFV1 / 0x31564646), yuv422p10le(tv,
   progressive), 1920x1080, q=2-31, 200 kb/s, 50 fps, 1k tbn
          Metadata:
            encoder         : Lavc61.19.101 ffv1
      Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz,
   stereo, s16, 1536 kb/s
          Metadata:
            encoder         : Lavc61.19.101 pcm_s16le
   [out#0/matroska @ 0x559f06e97500] video:383046KiB audio:1875KiB
   subtitle:0KiB other streams:0KiB global headers:0KiB muxing
   overhead: 0.010893%
   frame=  500 fps= 50 q=-0.0 Lsize=  384963KiB time=00:00:10.00
   bitrate=315361.7kbits/s speed=0.999x


---------------

du -sh *.mkv

   376M    1920x1080_50fps_y210+alsa_pcm_ffv1-3.mkv
   374M    1920x1080_50fps_yuvy422+alsa_pcm_ffv1-3.mkv
   -----
   45M    720x576_50fps_p210+alsa_ms2130_ffv1-3+pcm.mkv
   45M    720x576_50fps_y210+alsa_ms2130_ffv1-3+pcm.mkv
   58M    720x576_50fps_yuyv422+alsa_ms2130_ffv1-3+pcm.mkv


--------------------

ffprobe -hide_banner 1920x1080_50fps_y210+alsa_pcm_ffv1-3.mkv

Input #0, matroska,webm, from '1920x1080_50fps_y210+alsa_pcm_ffv1-3.mkv':
  Metadata:
    ENCODER         : Lavf61.7.100
  Duration: 00:00:10.00, start: 0.000000, bitrate: 315361 kb/s
  Stream #0:0: Video: ffv1 (FFV1 / 0x31564646), yuv422p10le(tv, progressive), 1920x1080, 50 fps, 50 tbr, 1k tbn
      Metadata:
        ENCODER         : Lavc61.19.101 ffv1
        DURATION        : 00:00:10.000000000
  Stream #0:1: Audio: pcm_s16le, 48000 Hz, 2 channels, s16, 1536 kb/s
      Metadata:
        ENCODER         : Lavc61.19.101 pcm_s16le
        DURATION        : 00:00:10.000000000


============================




    By the way, I acknowledge this limit at the hand.
    10-Bit Video is recommended for Analog Tape Transfer due to color
    shades and branding
    https://www.archivalworks.com/blog/10-bit-video-transfer

    But I expect also 8-bit 422 transfer to FFV1 opt for some better
    quality than the current 8-bit 420 DV25 files (converted from PAL
    S-video) and the HDV.m2t backup files.
    IMO direct playback of S-vdeo tapes has visual better brightness
    than the converted DV files.
    It remains also to verify if playing 1080i50 HDV tapes via HDMI
    will be up-scaled to 422 and 720p, according to Steve Mullen' FX7
    handbook.

    To continue I copy with from my old, initial post at
    https://www.mail-archive.com/cin@lists.cinelerra-gg.org/msg05547.html


    Does all FFV1 level 3 versions work with lossless compression for
    422 video?

    I have not yet found a definitiv ffmpeg FFV1 v 3 syntax guide for
    SD and HDV capturing and hope for suggestions and comments
    regarding the examples below:

    3.1 FFmpeg recipe (PAL) ffmpeg -i VIDEO_IN \ -c:v ffv1 -level 3
    -coder 1 -context 0 -slices 24 -slicecrc 1 \ -color_primaries
    bt470bg \ -color_trc bt709 \ -colorspace bt470bg \ -color_range
    mpeg \ -map 0 \ -top 1 \ -c:a copy \ -g 1 -pix_fmt + \
    VIDEO_OUT.mkv 3.2 Reference Example
    https://trac.ffmpeg.org/wiki/Encode/FFV1#Examples     Copy audio
    "as-is" and use FFV1.3 as video codec.

        Parameters are 8 threads, coder=1, context=1, GOP-size=1, 24
    slices and slice-CRC on:

        ffmpeg -i <input_video>     \         -acodec   copy         
    \         -vcodec   ffv1 -level 3 \         -threads 
    8             \         -coder    1             \        
    -context  1             \         -g        1             \
            -slices  24             \         -slicecrc 1            
    \         <output_video> 3.3 Various Encoding examples for Video
    capture from USB camera /dev/video0:

    ffmpeg -f v4l2 -framerate 25 -video_size 720x576 -i /dev/video0
    output_data.mkv ffmpeg -f v4l2 -framerate 25 -video_size 720x576
    -i /dev/video0 -codec:v ffv1 -codec:a pcm_s16le \
        -f matroska  output_video.mkv


    Check that video is captured properly using ffplay:

    ffmpeg -ar 44100 -thread_queue_size 1024 -f alsa -i $AUDIO \   
     -r 25 -thread_queue_size 1024 -i $VIDEO \     -codec copy -f
    matroska  - | ffplay


    - Check the overall flow using ffplay before capturing:

    ffmpeg -ar 44100 -thread_queue_size 1024 -f alsa -i $AUDIO \   
     -itsoffset -0.5 -r 25 -thread_queue_size 1024 -i $VIDEO \
        -filter_complex 'channelmap=FL-0' -filter_complex
    'crop=w=700:h=556:x=8:y=0' \
        -map 1:v  -map 0:a -codec:v ffv1 -codec:a pcm_s16le \     -f
    matroska  - | ffplay -




    why we can't have both ;) I mean, it all depend on hw, and now
    board wired ... If there was relatively popular capture board I
    am sure someone tried to push core linux kernel bits upstream ...


    but hw design is harder than it looks.






            But of course you better to doublecheck what v4l2 tools
            says ...


        So far no other  pixel formats found:

        v4l2-ctl -V
        Format Video Capture:
            Width/Height      : 720/576
            Pixel Format      : 'YUYV' (YUYV 4:2:2)
            Field             : None
            Bytes per Line    : 1440
            Size Image        : 829440
            Colorspace        : sRGB
            Transfer Function : Rec. 709
            YCbCr/HSV Encoding: ITU-R 601
            Quantization      : Default (maps to Limited Range)
            Flags             :




            Sorry for "too generic" answer, few years ago I/we
            looked into "direct RF capture" and there getting 10bit
            signal was possible, with custom hardware, slow offline
            processing and invasive hoockup to VCR's internals.


        Similar I bought and captured a few ProRes422 HQ few files in
        2016 with Blackmagic Design's HyperDeck Shuttle+AD
        miniconverter+SSD recorder.
        But some years later, BMD's fw support became EOL, and the
        devices became non-working :(











-- Cin mailing list
                Cin@lists.cinelerra-gg.org
                https://lists.cinelerra-gg.org/mailman/listinfo/cin



-- 
Cin mailing list
Cin@lists.cinelerra-gg.org
https://lists.cinelerra-gg.org/mailman/listinfo/cin

Reply via email to