Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SRT support for gstreamer #54380

Merged
merged 2 commits into from Feb 5, 2019
Merged

SRT support for gstreamer #54380

merged 2 commits into from Feb 5, 2019

Conversation

nh2
Copy link
Contributor

@nh2 nh2 commented Jan 20, 2019

Motivation for this change

SRT support for gstreamer. See:

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@nh2 nh2 mentioned this pull request Jan 21, 2019
17 tasks
@nh2 nh2 changed the title SRT support for gstreamer. See: SRT support for gstreamer Jan 21, 2019
@nh2
Copy link
Contributor Author

nh2 commented Jan 21, 2019

For my records: With the upgrade to gstreamer-1.15.1 in #54398, running the example

gst-launch-1.0 v4l2src ! video/x-raw, height=1080, width=1920 ! videoconvert ! x264enc tune=zerolatency ! video/x-h264, profile=high ! mpegtsmux ! srtserversink uri=srt://:8888/

now results in:

Setting pipeline to PAUSED ...
Caught SIGSEGV
Spinning.  Please run 'gdb gst-launch-1.0 17122' to continue debugging, Ctrl-C to quit, or Ctrl-\ to dump core.

sudo gdb /nix/store/nqclksqfvhy4w9pkd6c5dw6283rrsisl-gstreamer-1.15.1-dev/bin/.gst-launch-1.0-wrapped 17122 shows:

(gdb) bt
#0  0x00007f7fc24db318 in nanosleep () from /nix/store/fivq0nbggp4y8mhy3ixprqd7qyn1hy2j-glibc-2.27/lib/libpthread.so.0
#1  0x00007f7fc29d47af in g_usleep () from /nix/store/8q73aw4x32izb0gvzadjvj3a298bbwyy-glib-2.58.2/lib/libglib-2.0.so.0
#2  0x0000000000405592 in fault_handler_sighandler ()
#3  <signal handler called>
#4  0x00007f7fc2266e98 in __strchr_avx2 () from /nix/store/fivq0nbggp4y8mhy3ixprqd7qyn1hy2j-glibc-2.27/lib/libc.so.6
#5  0x00007f7fbea205c7 in g_inet_socket_address_new_from_string () from /nix/store/8q73aw4x32izb0gvzadjvj3a298bbwyy-glib-2.58.2/lib/libgio-2.0.so.0
#6  0x00007f7fbc285516 in gst_srt_object_open_full () from /nix/store/k3qilja4304q8s5xv6qp2bsvclhnjnbs-gst-plugins-bad-1.15.1/lib/gstreamer-1.0/libgstsrt.so
#7  0x00007f7fbc287958 in gst_srt_sink_start () from /nix/store/k3qilja4304q8s5xv6qp2bsvclhnjnbs-gst-plugins-bad-1.15.1/lib/gstreamer-1.0/libgstsrt.so
#8  0x00007f7fbfb444c5 in gst_base_sink_change_state () from /nix/store/jbp0y7lgx3h711hg6py979q35sygqa8k-gstreamer-1.15.1/lib/libgstbase-1.0.so.0
#9  0x00007f7fc2cf05ae in gst_element_change_state () from /nix/store/jbp0y7lgx3h711hg6py979q35sygqa8k-gstreamer-1.15.1/lib/libgstreamer-1.0.so.0
#10 0x00007f7fc2cf0ce9 in gst_element_set_state_func () from /nix/store/jbp0y7lgx3h711hg6py979q35sygqa8k-gstreamer-1.15.1/lib/libgstreamer-1.0.so.0
#11 0x00007f7fc2ccc572 in gst_bin_change_state_func () from /nix/store/jbp0y7lgx3h711hg6py979q35sygqa8k-gstreamer-1.15.1/lib/libgstreamer-1.0.so.0
#12 0x00007f7fc2cf05ae in gst_element_change_state () from /nix/store/jbp0y7lgx3h711hg6py979q35sygqa8k-gstreamer-1.15.1/lib/libgstreamer-1.0.so.0
#13 0x00007f7fc2cf0ce9 in gst_element_set_state_func () from /nix/store/jbp0y7lgx3h711hg6py979q35sygqa8k-gstreamer-1.15.1/lib/libgstreamer-1.0.so.0
#14 0x0000000000404289 in main ()

Probably not a packaging problem though.

@jtojnar
Copy link
Contributor

jtojnar commented Jan 21, 2019

  • 6 MB closure increase; should be fine

  • I cannot reproduce the pipeline crash on account of not having a webcam on this device:

    $ nix-shell -I nixpkgs=$PWD -p gst_all_1.gstreamer gst_all_1.gst-plugins-base gst_all_1.gst-plugins-good gst_all_1.gst-plugins-bad gst_all_1.gst-plugins-ugly --run "gst-launch-1.0 v4l2src ! video/x-raw, height=1080, width=1920 ! videoconvert ! x264enc tune=zerolatency ! video/x-h264, profile=high ! mpegtsmux ! srtserversink uri=srt://:8888/"
    Setting pipeline to PAUSED ...
    ERROR: Pipeline doesn't want to pause.
    ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Cannot identify device '/dev/video0'.
    Additional debug info:
    ../sys/v4l2/v4l2_calls.c(609): gst_v4l2_open (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
    system error: No such file or directory
    Setting pipeline to NULL ...
    Freeing pipeline ...
  • I also tried nix-shell -I nixpkgs=$PWD -p gst_all_1.gstreamer gst_all_1.gst-plugins-base gst_all_1.gst-plugins-good gst_all_1.gst-plugins-bad gst_all_1.gst-plugins-ugly --run "gst-launch-1.0 videotestsrc ! video/x-raw, height=1080, width=1920 ! videoconvert ! x264enc tune=zerolatency ! video/x-h264, profile=high ! mpegtsmux ! srtserversink uri=srt://:8888/"

    which did not fail but I was not able to play it:

    $ nix-shell -I nixpkgs=$PWD -p gst_all_1.gstreamer gst_all_1.gst-plugins-base gst_all_1.gst-plugins-good gst_all_1.gst-plugins-bad gst_all_1.gst-plugins-ugly --run "gst-launch-1.0 srtclientsrc uri=srt://127.0.0.1:8888/ ! autovideosink"
    Setting pipeline to PAUSED ...
    Pipeline is live and does not need PREROLL ...
    Setting pipeline to PLAYING ...
    New clock: GstSystemClock
    ERROR: from element /GstPipeline:pipeline0/GstAutoVideoSink:autovideosink0/GstXvImageSink:autovideosink0-actual-sink-xvimage: Internal error: can't allocate images
    Additional debug info:
    ../sys/xvimage/xvimagesink.c(997): gst_xv_image_sink_show_frame (): /GstPipeline:pipeline0/GstAutoVideoSink:autovideosink0/GstXvImageSink:autovideosink0-actual-sink-xvimage:
    We don't have a bufferpool negotiated
    Execution ended after 0:00:00.144943384
    Setting pipeline to PAUSED ...
    Setting pipeline to READY ...
    Setting pipeline to NULL ...
    Freeing pipeline ...

    maybe there is someone more familiar with GStreamer that could devise a method to test this.

@nh2
Copy link
Contributor Author

nh2 commented Jan 21, 2019

* I cannot reproduce the pipeline crash on account of not having a webcam on this device:

@jtojnar Reproducing the crash requires running the code from #54398; I have debugged that and filed problem and solution upstream: https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/874

* which did not fail but I was not able to play it:

I too haven't figured out how to actually run this thing yet; I'll post here once I have.

@nh2
Copy link
Contributor Author

nh2 commented Jan 23, 2019

I cannot reproduce the pipeline crash on account of not having a webcam on this device:

Reproducing the crash requires running the code from #54398

@jtojnar I realise I didn't actually address the key thing you mentioned: That you can't test it because of lack of webcam.

Here is how you can test it with a fake video source, videotestsrc:

  • In terminal 1:
    • gst-launch-1.0 videotestsrc ! x264enc bitrate=8000 tune=zerolatency key-int-max=15 ! video/x-h264, profile=baseline ! mpegtsmux ! srtserversink uri=srt://0.0.0.0:5000/
  • In terminal 2:
    • gst-launch-1.0 srtclientsrc uri=srt://127.0.0.1:5000 ! decodebin ! autovideosink

Note that this is for the version of gstreamer 1.14 on which this PR is based. These commands will change slightly for 1.16, says upstream.

I too haven't figured out how to actually run this thing yet; I'll post here once I have.

I have now successfully tested this stuff and the basic functionality works.


Ready to merge from my side.

@jtojnar
Copy link
Contributor

jtojnar commented Jan 23, 2019

Hmm, I cannot seem to find the decode plug-in:

$ nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/31981d2cd9ae4eb3bf77e3fb904f0e8b45ea828d.tar.gz --pure -p gst_all_1.gstreamer gst_all_1.gst-plugins-base gst_all_1.gst-plugins-good gst_all_1.gst-plugins-bad gst_all_1.gst-plugins-ugly --run "gst-launch-1.0 srtclientsrc uri=srt://127.0.0.1:5000 ! decodebin ! autovideosink"
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Missing element: H.264 decoder
ERROR: from element /GstPipeline:pipeline0/GstDecodeBin:decodebin0: Your GStreamer installation is missing a plug-in.
Additional debug info:
../gst/playback/gstdecodebin2.c(4640): gst_decode_bin_expose (): /GstPipeline:pipeline0/GstDecodeBin:decodebin0:
no suitable plugins found:
Missing decoder: H.264 (video/x-h264, stream-format=(string)byte-stream, alignment=(string)nal, parsed=(boolean)true)

Execution ended after 0:00:00.154163330
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...

The server side seems to run without a hitch.

@nh2
Copy link
Contributor Author

nh2 commented Feb 5, 2019

Hmm, I cannot seem to find the decode plug-in:

I think that's because you'll have to run with the #54398 I mentioned, because (unrelated to SRT) nixpkgs current gstreamer modules are built without support for libav based h264 decoding.

@jtojnar jtojnar merged commit f40412e into NixOS:master Feb 5, 2019
@jtojnar
Copy link
Contributor

jtojnar commented Feb 5, 2019

Thank you.

@nh2 nh2 mentioned this pull request Jun 27, 2020
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants