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
那么,当目录启动时,cker子能够使用吗?
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)