English 中文(简体)
• 在码头档案中使用网络
原标题:use webcam /dev/vdeio0 inside of the docker file
FROM alpine:edge AS build
RUN echo http://nl.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories
RUN apk add --no-cache gst-rtsp-server-dev
RUN apk add --no-cache libtool
RUN apk add --no-cache gcc
RUN apk add --no-cache musl-dev
RUN apk add --no-cache pkgconf 
COPY src/gst-rtsp-launch.c gst-rtsp-launch.c
RUN libtool --mode=link 
 gcc `pkg-config --cflags --libs gstreamer-1.0` 
 -L/usr/lib/x86_64-linux-gnu -lgstrtspserver-1.0 
 -o gst-rtsp-launch gst-rtsp-launch.c

FROM alpine:edge
RUN echo http://nl.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories
RUN apk add --no-cache gst-rtsp-server
RUN apk add --no-cache gst-plugins-base
RUN apk add --no-cache gst-plugins-ugly
RUN apk add --no-cache gst-plugins-good
RUN apk add --no-cache gst-plugins-bad
RUN apk add --no-cache gst-libav
RUN apk add --no-cache v4l-utils

COPY --from=build gst-rtsp-launch /usr/bin/gst-rtsp-launch

# Grant necessary privileges to access /dev/video0
RUN addgroup -S mygroup && adduser -S myuser -G mygroup
RUN chown myuser:mygroup -R /dev
USER myuser

EXPOSE 8554

ENTRYPOINT ["/usr/bin/gst-rtsp-launch"]
CMD ["v4l2src device=/dev/video0 ! videoconvert ! queue ! x264enc ! video/x-h264, alignment=au, stream-format=byte-stream, profile=main ! h264parse ! rtph264pay name=pay0 pt=96"]

I build following Dockerfile and initiate the rtsp server
and used this command to run docker

docker run --rm -it 
  --privileged 
  --volume=/dev:/dev 
  -p 8554:8554 
  test_base:latest
  1. 那么,当目录启动时,cker子能够使用吗?

  2. I m 要求这样做是因为出现错误

    0:00:04.069205726 1 0x7f0769c994e0 ERROR rtspient rtsp-client.c:3412:handle_dereg_request: Counsellor 0x7f0769c9b860: no media

这意味着没有资源

更 正

00:09.947254945     1 0x7f59f2efc4e0 INFO         GST_REFCOUNTING gstelement.c:3470:gst_element_finalize:<rtpbin0> 0x7f59f2828ae0 finalize
0:00:09.947263927     1 0x7f59f2efc4e0 INFO         GST_REFCOUNTING gstelement.c:3475:gst_element_finalize:<rtpbin0> 0x7f59f2828ae0 finalize parent
0:00:09.947273407     1 0x7f59f2efc4e0 DEBUG              rtspmedia rtsp-media.c:2809:gst_rtsp_media_set_status: setting new status to 0
0:00:09.947283034     1 0x7f59f2efc4e0 DEBUG              rtspmedia rtsp-media.c:4078:finish_unprepare: removing bus watch
0:00:09.947293657     1 0x7f59f2efc4e0 DEBUG                GST_BUS gstelement.c:3543:gst_element_get_bus:<media-pipeline> got bus <bus2>
0:00:09.947301723     1 0x7f59f2efc4e0 DEBUG              rtspmedia rtsp-media.c:3421:watch_destroyed:<GstRTSPMedia@0x7f59f3103410> source destroyed
0:00:09.947309835     1 0x7f59f2efc4e0 DEBUG              rtspmedia rtsp-media.c:4083:finish_unprepare: destroy source
0:00:09.947316839     1 0x7f59f2efc4e0 DEBUG                GST_BUS gstbus.c:846:gst_bus_source_dispose:<bus2> disposing source 0x7f59f29bb990
0:00:09.947325059     1 0x7f59f2efc4e0 DEBUG              rtspmedia rtsp-media.c:4089:finish_unprepare: stop thread
0:00:09.947332501     1 0x7f59f2efc4e0 DEBUG                default rtsp-thread-pool.c:178:gst_rtsp_thread_stop: stop thread 0x7f59f29b7bd0
0:00:09.947339272     1 0x7f59f2efc4e0 DEBUG                default rtsp-thread-pool.c:181:gst_rtsp_thread_stop: add idle source to quit mainloop of thread 0x7f59f29b7bd0
0:00:09.947350667     1 0x7f59f2efc4e0 ERROR             rtspclient rtsp-client.c:1115:find_media: client 0x7f59f2efe870: can t prepare media
0:00:09.947359058     1 0x7f59f29b88d0 DEBUG                default rtsp-thread-pool.c:159:do_quit: stop mainloop of thread 0x7f59f29b7bd0
0:00:09.947374070     1 0x7f59f29b88d0 INFO          rtspthreadpool rtsp-thread-pool.c:331:do_loop: exit mainloop of thread 0x7f59f29b7bd0
0:00:09.947383985     1 0x7f59f29b88d0 DEBUG                default rtsp-thread-pool.c:74:_gst_rtsp_thread_free: free thread 0x7f59f29b7bd0
0:00:09.947397351     1 0x7f59f2efc4e0 INFO               rtspmedia rtsp-media.c:530:gst_rtsp_media_finalize: finalize media 0x7f59f3103410
0:00:09.947408315     1 0x7f59f2efc4e0 DEBUG             rtspstream rtsp-stream.c:390:gst_rtsp_stream_finalize: finalize stream 0x7f59f2f1b980
0:00:09.947418939     1 0x7f59f2efc4e0 DEBUG        GST_REFCOUNTING gstpipeline.c:258:gst_pipeline_dispose:<media-pipeline> 0x7f59f31034f0 dispose
0:00:09.947429915     1 0x7f59f2efc4e0 DEBUG        GST_REFCOUNTING gstbin.c:517:gst_bin_dispose:<media-pipeline> 0x7f59f31034f0 dispose
0:00:09.947440879     1 0x7f59f2efc4e0 DEBUG          GST_PARENTAGE gstbin.c:1864:gst_bin_remove: removing element bin0 from bin media-pipeline
0:00:09.947451496     1 0x7f59f2efc4e0 DEBUG                    bin gstbin.c:1563:gst_bin_remove_func:<media-pipeline> element :bin0
0:00:09.947460258     1 0x7f59f2efc4e0 DEBUG                    bin gstbin.c:1650:gst_bin_remove_func:<media-pipeline> we removed the last source
0:00:09.947468917     1 0x7f59f2efc4e0 DEBUG                    bin gstbin.c:1762:gst_bin_remove_func:<media-pipeline> recalc state preroll: 0, other async: 0, this async 0
0:00:09.947475785     1 0x7f59f2efc4e0 DEBUG          GST_PARENTAGE gstelement.c:3488:gst_element_set_bus_func:<bin0> setting bus to 0
0:00:09.947485640     1 0x7f59f2efc4e0 DEBUG              GST_CLOCK gstelement.c:443:gst_element_set_clock:<bin0> setting clock 0
0:00:09.947494788     1 0x7f59f2efc4e0 DEBUG              GST_CLOCK gstelement.c:443:gst_element_set_clock:<capsfilter0> setting clock 0
0:00:09.947503819     1 0x7f59f2efc4e0 DEBUG              GST_CLOCK gstelement.c:443:gst_element_set_clock:<pay0> setting clock 0
0:00:09.947512433     1 0x7f59f2efc4e0 DEBUG              GST_CLOCK gstelement.c:443:gst_element_set_clock:<h264parse0> setting clock 0
0:00:09.947522651     1 0x7f59f2efc4e0 DEBUG              GST_CLOCK gstelement.c:443:gst_element_set_clock:<x264enc0> setting clock 0



.943327607     1 0x7f59f29b88d0 WARN               structure gststructure.c:2093:priv_gst_structure_append_to_gstring: No value transform to serialize field  gerror  of type  GError 
0:00:09.943335854     1 0x7f59f2efc4e0 DEBUG                    bin gstbin.c:2576:gst_bin_element_set_state:<media-pipeline> setting element rtpbin0 to NULL, base_time 0:00:00.000000000
0:00:09.943351708     1 0x7f59f29b88d0 DEBUG                GST_BUS gstbus.c:818:gst_bus_source_dispatch:<bus2> source 0x7f59f29bb990 calling dispatch with error message: 0x7f59f2779f40, time 99:99:99.999999999, seq-num 47, element  v4l2src0 , GstMessageError, gerror=(GError)NULL, debug=(string)"../sys/v4l2/v4l2_calls.c(626): gst_v4l2_open (): /GstPipeline:media-pipeline/GstBin:bin0/GstV4l2Src:v4l2src0:12system error: Permission denied";
0:00:09.943353650     1 0x7f59f2efc4e0 DEBUG             GST_STATES gstelement.c:2967:gst_element_set_state_func:<rtpbin0> set_state to NULL
0:00:09.943367975     1 0x7f59f29b88d0 WARN               rtspmedia rtsp-media.c:3306:default_handle_message: 0x7f59f3103410: got error Could not open device  /dev/video0  for reading and writing. (../sys/v4l2/v4l2_calls.c(626): gst_v4l2_open (): /GstPipeline:media-pipeline/GstBin:bin0/GstV4l2Src:v4l2src0:
system error: Permission denied)
问题回答

NB: This is a partial answer; it corrects several issues in your question, but at least on my system results in a new error. Despite that I think it may still be useful.


对您的问题发表若干评论:

  • 如果您使用-privileged 页: 1 在发生违约时披露整个东道方的<代码>。

  • 事实上,你可能不需要<代码>-privileged;你可以使用<代码>-device的旗帜将单个装置暴露在集装箱内。

  • When installing packages, it is always a better idea to install multiple packages in a single apk command line, rather than calling apk add multiple times -- this means apk only needs to compute dependencies once, instead of multiple times, so your image will build faster.

  • 页: 1 Dockerfile, 您可以安装gstreamer-tools


我的系统把所有这些内容加在一起,是一次网络运动。 如果我使用<代码>Dockerfile:

FROM alpine:edge
RUN echo http://nl.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories
RUN apk add gst-rtsp-server 
    gst-plugins-base 
    gst-plugins-ugly 
    gst-plugins-good 
    gst-plugins-bad 
    gst-libav 
    v4l-utils 
    gstreamer-tools

CMD ["sh", "-c", "gst-launch-1.0 v4l2src device=${VIDEODEVICE:-/dev/video0} videoconvert ! queue ! x264enc ! video/x-h264, alignment=au, stream-format=byte-stream, profile=main ! h264parse ! rtph264pay name=pay0 pt=96"]

建立:

docker build -t gsttest .

And run it like this:

docker run -it --rm -e VIDEODEVICE=/dev/video1 --device /dev/video1  gsttest

它运行并能够成功打开照相机:

Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock

不幸的是,它经历了大约第二次失败:

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-linked (-1)
Execution ended after 0:00:01.974160448
Setting pipeline to NULL ...
Freeing pipeline ...




相关问题
Unable to connect to docker container inside windows server

As title. I am developing a system with many docker images with ASP.Net MVC core projects. I am publishing these docker images into a docker engine installed on Windows Server OS, and I found that I ...

Only can see postgreSQL as an admin

After installed Wsl and Docker, can t access PSQL and other things. I was studying Docker, and installed the latest version. So far so good, I received an error about the WSL version, saw some ...

make docker-compose block until healthy without `depends_on`

I am working with a team that uses docker-compose to start a set of helper services, but does not use docker when the code is being developed. Here, docker-compose is just a convenient way to run the ...

change grafana port using docker host network

I am trying to spin up a grafana container in docker, however my setup in docker does not allow ipv4 forwarding and thus I cannot use the default bridge network in docker. All I can use is the host ...

Pip instalation for Python 3.11 in docker

I have Dockerfile to build image for Django project that uses Python 3.11 and runs in poetry environment (see content below). Problem is when I try to donwload get-pip.py file and run it using Python, ...

在 Dockerfile 中运行 composer install

我正在尝试将我的Laravel应用程序进行Docker化。 该应用程序已经构建并在Git中,但我将vendor文件夹添加到了.gitignore中。 我添加了一个Dockerfile,看起来像这样: FROM php:7.1-fpm-alpine RUN apk update ...

热门标签