teltek / gst-plugin-ndi

GStreamer NDI Plugin for Linux
GNU Lesser General Public License v2.1
154 stars 27 forks source link

Can't get Interlaced NDI from Interlaced SDI #114

Closed dmitrysdm closed 11 months ago

dmitrysdm commented 1 year ago

I have follow signal from SDI:

# mwcap-info -i /dev/video1

Input specific
  Signal status .......................... Valid
  Type ................................... HD
  Scanning type .......................... Interlaced
  Color depth ............................ 10 Bits
  Sampling struct ........................ Y/Cb/Cr, 4:2:2
  ST352 payloadID ........................ 16778629

and option for get signal via v4l2 plugin

# gst-launch-1.0 --gst-debug=v4l2src:5 v4l2src device=/dev/video1 ! fakesink 2>&1 | sed -une '/caps of src/ s/[:;] /\n/gp'

...
video/x-raw, format=(string)I420, width=(int)[ 48, 2048 ], height=(int)[ 32, 2160 ], framerate=(fraction)[ 1/1, 5000000/83333 ]
video/x-raw(format:Interlaced), format=(string)I420, width=(int)[ 48, 2048 ], height=(int)[ 32, 2160 ], framerate=(fraction)[ 1/1, 5000000/83333 ], interlace-mode=(string)alternate
...

I use follow command for get NDI from SDI:

gst-launch-1.0 -e v4l2src device="/dev/video1" do-timestamp=true pixel-aspect-ratio=1 ! video/x-raw, format=I420, width=1920, height=1080, framerate=50/1, **interlace-mode=interlaced** ! queue ! ndisinkcombiner name=combiner alsasrc device="hw:CARD=SDI_1,DEV=0" do-timestamp=true ! audio/x-raw, rate=96000, channels=2 ! queue ! audioconvert ! combiner.audio combiner. ! ndisink ndi-name="video1"

i think that something wrong with interlace-mode= option, because my tests results is follow:

  1. without option interlace-mode= - NDI Studio Monitor shown - 1080 50p

  2. interlace-mode=Interlaced / interlace-mode=interlaced - NDI Studio Monitor shown - 1080 50p

  3. interlace-mode=alternate - ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Invalid caps Additional debug info: ../sys/v4l2/gstv4l2object.c(4078): gst_v4l2_object_set_format_full (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Can't parse caps video/x-raw, format=(string)I420, width=(int)1920, height=(int)1080, framerate=(fraction)50/1, interlace-mode=(string)alternate, pixel-aspect-ratio=(fraction)1/1 ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data stream error.

  4. interlace-mode=interleaved - ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Device '/dev/video1' has no supported format

I have found this link: https://gstreamer.freedesktop.org/documentation/additional/design/mediatype-video-raw.html?gi-language=c#raw-video-media-types with options: [progressive, interleaved, mixed, fields, alternate] and this link: https://gstreamer.freedesktop.org/documentation/deinterlace/index.html?gi-language=c#GstDeinterlaceModes with options: [auto, interlaced, disabled, auto-strict]

I can watch progressive mode in NDI Studio Monitor, but i need same signal in Interlaced mode. Which one i need to use in for parse caps? Maybe i need to use escape symbols for correct parse video/x-raw(format:Interlaced) ?

I have try to run this via bash with special symbols unsuccessfully: video/x-raw(format:Interlaced) 'video/x-raw(format:Interlaced)' - ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data stream error.

Problem, that i split signat to NDI and RTSP and final stream - rtsp://...:8554/video1 shown 50 fps progressive, but i need 25 fps progressive (via deinterlace plugin) for get less redundancy

ffprobe.exe rtsp://*.*.*.*:8554/video1 Input #0, rtsp, from 'rtsp://...:8554/video1': Metadata: title : Stream Duration: N/A, start: 0.101708, bitrate: N/A Stream #0:0: Audio: opus, 48000 Hz, stereo, fltp Stream #0:1: Video: h264 (High), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 50 fps, 50 tbr, 90k tbn

I created a similar issue in the gstreamer branch gitlab.freedesktop.org , because it's looks like gstreamer v4l2 plugin (that works with the capture card) documentation omission, but I think that additional documentation also needed on gst-plugin-ndi page, becuse transform signal from SDI to NDI is base functionality for gst-plugin-ndi plugin

dmitrysdm commented 1 year ago

I have foiund follow link: https://xilinx-wiki.atlassian.net with example for interlaced signal:

gst-launch-1.0 v4l2src io-mode=4 ! video/x-raw\(format:Interlaced\),interlace-mode=alternate,format=NV16_10LE32,width=1920,height=1080,framerate=30/1 ! omxh265enc qp-mode=auto gop-mode=basic gop-length=60 b-frames=0 target-bitrate=10000 num-slices=8 control-rate=constant prefetch-buffer=true low-bandwidth=false filler-data=true cpb-size=1000 initial-delay=500 ! omxh265dec ! queue max-size-bytes=-1 ! kmssink bus-id=amba_pl@0:drm-pl-disp-drvsdi_tx_output_v_smpte_uhdsdi_tx_ss connector-properties="props,sdi_mode=0,sdi_data_stream=2,is_frac=0" show-preroll-frame=false

main difference that in example used symbols escape for bash: video/x-raw(format:Interlaced),interlace-mode=alternate,

and try this option for formats YUYV, UYVY with follow results:

YUYV

format=YUYV, video/x-raw(format:Interlaced),interlace-mode= * - always message - WARNING: erroneous pipeline: could not link v4l2src0 to queue0, v4l2src0 can't handle caps video/x-raw(format:Interlaced), format=(string)YUYV, width=(int)1920, height=(int)1080, framerate=(fraction)50/1, interlace-mode=(string)alternate

UYVY

format=UYVY, video/x-raw(format:Interlaced),interlace-mode= progressive- WARNING: erroneous pipeline: could not link v4l2src0 to queue0, v4l2src0 can't handle caps video/x-raw(format:Interlaced), interlace-mode=(string)progressive, format=(string)UYVY, width=(int)1920, height=(int)1080, framerate=(fraction)50/1

format=UYVY, video/x-raw(format:Interlaced),interlace-mode= interlaced - WARNING: erroneous pipeline: could not link v4l2src0 to queue0, v4l2src0 can't handle caps video/x-raw(format:Interlaced), interlace-mode=(string)interlaced, format=(string)UYVY, width=(int)1920, height=(int)1080, framerate=(fraction)50/1

format=UYVY, video/x-raw(format:Interlaced),interlace-mode= alternate - New clock: GstAudioSrcClock ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data stream error. Additional debug info: ../libs/gst/base/gstbasesrc.c(3132): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: streaming stopped, reason not-negotiated (-4)

alternate option seems more useful and equal example from link, but still not successful :disappointed: at same time format UYVY more useful for my case because progressive mode is working for UYVY: video/x-raw, format=UYVY, interlace-mode=progressive and is not working for YUYV: video/x-raw, format=YUYV, interlace-mode=progressive

full command that i use almost the same: gst-launch-1.0 -e v4l2src device="/dev/video1" do-timestamp=true pixel-aspect-ratio=1 ! video/x-raw\(format:Interlaced\), format=UYVY, width=1920, height=1080, framerate=50/1, interlace-mode=alternate ! queue ! ndisinkcombiner name=combiner alsasrc device="hw:CARD=SDI_1,DEV=0" do-timestamp=true ! audio/x-raw, rate=96000, channels=2 ! queue ! audioconvert ! combiner.audio combiner. ! ndisink ndi-name="video1"

dmitrysdm commented 11 months ago

Now i have recommendation from magewell support to use video/x-raw instead video/x-raw(format:Interlaced), it is not related with opts that i found (gstreamer opts is correct), but it is sufficient for my case.