Opened 5 months ago

Last modified 7 weeks ago

#7639 new defect

Unable to do 'rtsp stream' when 'rtsp_flags listen'

Reported by: dinesh.gupta01 Owned by:
Priority: normal Component: undetermined
Version: git-master Keywords: rtsp
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:

FFmpeg will not streaming a RSTP stream. I want to FFmpeg work as server and stream desktop. Also, I am generating '.sdp' file so that client may connect. But '.sdp' file not being generated.
It hangs and must be terminated with Ctrl+C(press twice).

After issuing a Ctrl+C twice, it displays the error: Could not write header for output file #0 (incorrect codec parameters ?): Immediate exit requested
Error initializing output stream 0:0 --

How to reproduce:

D:\small\ffmpeg-4.1-win32-shared\bin>ffmpeg -sdp_file stream1.sdp -f gdigrab -i desktop -rtsp_flags listen -f rtsp rtsp://100.64.129.179:15450

ffmpeg version 4.1 Copyright (c) 2000-2018 the FFmpeg developers

built with gcc 8.2.1 (GCC) 20181017
configuration: --disable-static --enable-shared --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
libpostproc 55. 3.100 / 55. 3.100

[gdigrab @ 05aed680] Capturing whole desktop as 1366x768x32 at (0,0)
[gdigrab @ 05aed680] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, gdigrab, from 'desktop':

Duration: N/A, start: 1545836929.667861, bitrate: 1006131 kb/s

Stream #0:0: Video: bmp, bgra, 1366x768, 1006131 kb/s, 29.97 fps, 1000k tbr, 1000k tbn, 1000k tbc

Stream mapping:

Stream #0:0 -> #0:0 (bmp (native) -> mpeg4 (native))

Press [q] to stop, ? for help
Could not write header for output file #0 (incorrect codec parameters ?): Immediate exit requested
Error initializing output stream 0:0 --
Exiting normally, received signal 2.

Change History (4)

comment:1 Changed 5 months ago by cehoyos

  • Component changed from ffmpeg to undetermined
  • Keywords rtsp added

Is the issue reproducible with current FFmpeg git head? Please test an artificial video source like testsrc2 unless you want to report an issue with screen grabbing. And please move sdp_file behind the input stream.

comment:2 Changed 5 months ago by dinesh.gupta01

yes It is reproducible with current git head.

I followed your suggestion but getting the same result as previous. I placed the

sdp_file

after the input and not getting the desire result.

comment:3 Changed 5 months ago by dinesh.gupta01

I downloaded latest nightly build run the below command

C:\ffmpeg_latest>ffmpeg -loglevel trace -f gdigrab -i desktop -sdp_file stream1.sdp -rtsp_flags listen -f rtsp rtsp://10.0.0.30:15450
ffmpeg version N-92833-gfccba32b4c Copyright (c) 2000-2018 the FFmpeg developers

built with gcc 8.2.1 (GCC) 20181201
configuration: --disable-static --enable-shared --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
libavutil 56. 25.100 / 56. 25.100
libavcodec 58. 42.104 / 58. 42.104
libavformat 58. 25.100 / 58. 25.100
libavdevice 58. 6.101 / 58. 6.101
libavfilter 7. 46.101 / 7. 46.101
libswscale 5. 4.100 / 5. 4.100
libswresample 3. 4.100 / 3. 4.100
libpostproc 55. 4.100 / 55. 4.100

Splitting the commandline.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'trace'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'gdigrab'.
Reading option '-i' ... matched as input url with argument 'desktop'.
Reading option '-sdp_file' ... matched as option 'sdp_file' (specify a file in which to print sdp information) with argument 'stream1.sdp'.
Reading option '-rtsp_flags' ... matched as AVOption 'rtsp_flags' with argument 'listen'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'rtsp'.
Reading option 'rtsp://10.0.0.30:15450' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument trace.
Applying option sdp_file (specify a file in which to print sdp information) with argument stream1.sdp.
Successfully parsed a group of options.
Parsing a group of options: input url desktop.
Applying option f (force format) with argument gdigrab.
Successfully parsed a group of options.
Opening an input file: desktop.
[gdigrab @ 0437db40] Capturing whole desktop as 1366x768x32 at (0,0)
[gdigrab @ 0437db40] Cursor pos (1363,51) -> (1363,51)

Last message repeated 1 times

[gdigrab @ 0437db40] Probe buffer size limit of 5000000 bytes reached
[gdigrab @ 0437db40] Stream #0: not enough frames to estimate rate; consider increasing probesize
[gdigrab @ 0437db40] stream 0: start_time: 1546151393.403 duration: -9223372036854.775
[gdigrab @ 0437db40] format: start_time: 1546151393.403 duration: -9223372036854.775 bitrate=1006131 kb/s
Input #0, gdigrab, from 'desktop':

Duration: N/A, start: 1546151393.403101, bitrate: 1006131 kb/s

Stream #0:0, 2, 1/1000000: Video: bmp, 1 reference frame, bgra, 1366x768, 0/1, 1006131 kb/s, 29.97 fps, 1000k tbr, 1000k tbn, 1000k tbc

Successfully opened the file.
Parsing a group of options: output url rtsp://10.0.0.30:15450.
Applying option f (force format) with argument rtsp.
Successfully parsed a group of options.
Opening an output file: rtsp://10.0.0.30:15450.
Successfully opened the file.
Stream mapping:

Stream #0:0 -> #0:0 (bmp (native) -> mpeg4 (native))

Press [q] to stop, ? for help
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
detected 4 logical cores
[graph 0 input from stream 0:0 @ 0428b480] Setting 'video_size' to value '1366x768'
[graph 0 input from stream 0:0 @ 0428b480] Setting 'pix_fmt' to value '28'
[graph 0 input from stream 0:0 @ 0428b480] Setting 'time_base' to value '1/1000000'
[graph 0 input from stream 0:0 @ 0428b480] Setting 'pixel_aspect' to value '0/1'
[graph 0 input from stream 0:0 @ 0428b480] Setting 'sws_param' to value 'flags=2'
[graph 0 input from stream 0:0 @ 0428b480] Setting 'frame_rate' to value '30000/1001'
[graph 0 input from stream 0:0 @ 0428b480] w:1366 h:768 pixfmt:bgra tb:1/1000000 fr:30000/1001 sar:0/1 sws_param:flags=2
[format @ 0428b9c0] Setting 'pix_fmts' to value 'yuv420p'
[auto_scaler_0 @ 0428be80] Setting 'flags' to value 'bicubic'
[auto_scaler_0 @ 0428be80] w:iw h:ih flags:'bicubic' interl:0
[format @ 0428b9c0] auto-inserting filter 'auto_scaler_0' between the filter 'Parsed_null_0' and the filter 'format'
[AVFilterGraph @ 04277200] query_formats: 4 queried, 2 merged, 1 already done, 0 delayed
[auto_scaler_0 @ 0428be80] w:1366 h:768 fmt:bgra sar:0/1 -> w:1366 h:768 fmt:yuv420p sar:0/1 flags:0x4
[mpeg4 @ 04285e00] intra_quant_bias = 0 inter_quant_bias = -64
[tcp @ 042a9940] No default whitelist set
[tcp @ 042a9940] Original list of addresses:
[tcp @ 042a9940] Address 10.0.0.30 port 15450
[tcp @ 042a9940] Interleaved list of addresses:
[tcp @ 042a9940] Address 10.0.0.30 port 15450
[tcp @ 042a9940] Starting connection attempt to 10.0.0.30 port 15450


And tried to connect from VLC player then received error:

VLC is unable to open the MRL 'rtsp://10.0.0.30/15450'

So basically it is not waiting for client to connect the ffmepg rtsp.

comment:4 Changed 7 weeks ago by Jun

try this,
terminal one: ./ffplay -rtsp_flags listen rtsp://localhost:15450
terminal two: ./ffmpeg -f gdigrab -i desktop -f rtsp rtsp://localhost:15450

rtsp client(ffmpeg here) send Announce->Setup->Record request to listener(ffplay here), and then send packets through RTP.

So you can use ffplay as a server to listen, and ffmpeg as client to push from your local camera to server. I tried on my mac and works find. here is my cmd :
terminal one : sudo ./ffplay -rtsp_flags listen rtsp://localhost:554
terminal two: ffmpeg -f avfoundation -video_size 320x240 -framerate 30 -pixel_format bgr0 -i "FaceTime? HD Camera" -f rtsp rtsp://localhost:554

Note: See TracTickets for help on using tickets.