Opened 20 months ago

Closed 20 months ago

Last modified 20 months ago

#9169 closed defect (invalid)

RTSP stream with UDP are use TCP

Reported by: VidarHUN Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords: rtsp
Cc: ricsi19981007@gmail.com Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
How to reproduce:

ffmpeg -loglevel repeat+level+trace -re -i input.mp3 -f rtsp -rtsp_transport udp rtsp://localhost:8554/live

The error message:

[tcp @ 0x561618cb8b00] [debug] No default whitelist set
[tcp @ 0x561618cb8b00] [debug] Original list of addresses:
[tcp @ 0x561618cb8b00] [debug] Address 127.0.0.1 port 8554
[tcp @ 0x561618cb8b00] [debug] Interleaved list of addresses:
[tcp @ 0x561618cb8b00] [debug] Address 127.0.0.1 port 8554
[tcp @ 0x561618cb8b00] [verbose] Starting connection attempt to 127.0.0.1 port 8554
[tcp @ 0x561618cb8b00] [verbose] Connection attempt to 127.0.0.1 port 8554 failed: Connection refused
[tcp @ 0x561618cb8b00] [error] Connection to tcp://localhost:8554?timeout=0 failed: Connection refused
[error] Could not write header for output file #0 (incorrect codec parameters ?): Connection refused
[error] Error initializing output stream 0:0 -- 

I think this should work with UDP and there is a related ticket already #6807.

Change History (9)

comment:1 by Carl Eugen Hoyos, 20 months ago

Component: ffmpegundetermined
Keywords: udp tcp stream removed
Priority: importantnormal
Version: 4.2.4unspecified

Please test current FFmpeg git head and provide the command line you tested together with the complete, uncut console output to make this a valid ticket.

comment:2 by Andriy Gelman, 20 months ago

Looks that you just don't have an rtsp server listening on localhost:8554

comment:3 by VidarHUN, 20 months ago

So I cloned the repo and I will show every steps what I am done.

  • create a file rtsp-simple-server.yml with this content: protocols: [udp]
  • start the server:
    docker run --rm -it -v $PWD/rtsp-simple-server.yml:/rtsp-simple-server.yml -p 8554:8554/udp aler9/rtsp-simple-server
    
  • start the rtsp stream:
    ./FFmpeg/ffmpeg -loglevel repeat+level+trace -re -i input.mp3 -f rtsp -rtsp_transport udp rtsp://localhost:8554/live
    
    [info] ffmpeg version N-101778-g84ac35ecb8 Copyright (c) 2000-2021 the FFmpeg developers
    [info]   built with gcc 9 (Ubuntu 9.3.0-17ubuntu1~20.04)
    [info]   configuration: 
    [info]   libavutil      56. 72.100 / 56. 72.100
    [info]   libavcodec     58.135.100 / 58.135.100
    [info]   libavformat    58. 77.100 / 58. 77.100
    [info]   libavdevice    58. 14.100 / 58. 14.100
    [info]   libavfilter     7.111.100 /  7.111.100
    [info]   libswscale      5. 10.100 /  5. 10.100
    [info]   libswresample   3. 10.100 /  3. 10.100
    [debug] Splitting the commandline.
    [debug] Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'repeat+level+trace'.
    [debug] Reading option '-re' ... matched as option 're' (read input at native frame rate) with argument '1'.
    [debug] Reading option '-i' ... matched as input url with argument 'input.mp3'.
    [debug] Reading option '-f' ... matched as option 'f' (force format) with argument 'rtsp'.
    [debug] Reading option '-rtsp_transport' ... matched as AVOption 'rtsp_transport' with argument 'udp'.
    [debug] Reading option 'rtsp://localhost:8554/live' ... matched as output url.
    [debug] Finished splitting the commandline.
    [debug] Parsing a group of options: global .
    [debug] Applying option loglevel (set logging level) with argument repeat+level+trace.
    [debug] Successfully parsed a group of options.
    [debug] Parsing a group of options: input url input.mp3.
    [debug] Applying option re (read input at native frame rate) with argument 1.
    [debug] Successfully parsed a group of options.
    [debug] Opening an input file: input.mp3.
    [NULL @ 0x5632f9e257c0] [debug] Opening 'input.mp3' for reading
    [file @ 0x5632f9e26440] [debug] Setting default whitelist 'file,crypto,data'
    [trace] Probing mp3 score:51 size:2003
    [mp3 @ 0x5632f9e257c0] [debug] Format mp3 probed with size=2048 and score=51
    [debug] id3v2 ver:4 flags:00 len:35
    [mp3 @ 0x5632f9e257c0] [debug] pad 576 1501
    [mp3 @ 0x5632f9e257c0] [verbose] Skipping 0 bytes of junk at 237.
    [mp3 @ 0x5632f9e257c0] [debug] Before avformat_find_stream_info() pos: 237 bytes read:32768 seeks:0 nb_streams:1
    [mp3 @ 0x5632f9e257c0] [debug] demuxer injecting skip 1105 / discard 0
    [mp3float @ 0x5632f9e27840] [debug] skip 1105 / discard 0 samples due to side data
    [mp3float @ 0x5632f9e27840] [debug] skip 1105/1152 samples
    [mp3 @ 0x5632f9e257c0] [debug] All info found
    [mp3 @ 0x5632f9e257c0] [trace] stream 0: start_time: 0.0230208 duration: 257.808
    [mp3 @ 0x5632f9e257c0] [trace] format: start_time: 0.023021 duration: 257.808 (estimate from stream) bitrate=64 kb/s
    [mp3 @ 0x5632f9e257c0] [debug] After avformat_find_stream_info() pos: 10477 bytes read:32768 seeks:0 frames:50
    [info] Input #0, mp3, from 'input.mp3':
    [info]   Metadata:
    [info]     encoder         : Lavf58.29.100
    [info]   Duration: 00:04:17.81, start: 0.023021, bitrate: 64 kb/s
    [info]   Stream #0:0, 50, 1/14112000: Audio: mp3, 48000 Hz, stereo, fltp, 64 kb/s
    [info]     Metadata:
    [info]       encoder         : Lavc58.54
    [debug] Successfully opened the file.
    [debug] Parsing a group of options: output url rtsp://localhost:8554/live.
    [debug] Applying option f (force format) with argument rtsp.
    [debug] Successfully parsed a group of options.
    [debug] Opening an output file: rtsp://localhost:8554/live.
    [debug] Successfully opened the file.
    [info] Stream mapping:
    [info]   Stream #0:0 -> #0:0 (mp3 (mp3float) -> aac (native))
    [info] Press [q] to stop, [?] for help
    [debug] cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
    [mp3float @ 0x5632f9e2b140] [debug] skip 1105 / discard 0 samples due to side data
    [mp3float @ 0x5632f9e2b140] [debug] skip 1105/1152 samples
    [debug] detected 4 logical cores
    [graph_0_in_0_0 @ 0x5632f9e3db80] [debug] Setting 'time_base' to value '1/48000'
    [graph_0_in_0_0 @ 0x5632f9e3db80] [debug] Setting 'sample_rate' to value '48000'
    [graph_0_in_0_0 @ 0x5632f9e3db80] [debug] Setting 'sample_fmt' to value 'fltp'
    [graph_0_in_0_0 @ 0x5632f9e3db80] [debug] Setting 'channel_layout' to value '0x3'
    [graph_0_in_0_0 @ 0x5632f9e3db80] [verbose] tb:1/48000 samplefmt:fltp samplerate:48000 chlayout:0x3
    [format_out_0_0 @ 0x5632f9e3e100] [debug] Setting 'sample_fmts' to value 'fltp'
    [format_out_0_0 @ 0x5632f9e3e100] [debug] Setting 'sample_rates' to value '96000|88200|64000|48000|44100|32000|24000|22050|16000|12000|11025|8000|7350'
    [AVFilterGraph @ 0x5632f9e28ec0] [debug] query_formats: 4 queried, 9 merged, 0 already done, 0 delayed
    [tcp @ 0x5632f9e51780] [debug] No default whitelist set
    [tcp @ 0x5632f9e51780] [debug] Original list of addresses:
    [tcp @ 0x5632f9e51780] [debug] Address 127.0.0.1 port 8554
    [tcp @ 0x5632f9e51780] [debug] Interleaved list of addresses:
    [tcp @ 0x5632f9e51780] [debug] Address 127.0.0.1 port 8554
    [tcp @ 0x5632f9e51780] [verbose] Starting connection attempt to 127.0.0.1 port 8554
    [tcp @ 0x5632f9e51780] [verbose] Connection attempt to 127.0.0.1 port 8554 failed: Connection refused
    [tcp @ 0x5632f9e51780] [error] Connection to tcp://localhost:8554?timeout=0 failed: Connection refused
    [error] Could not write header for output file #0 (incorrect codec parameters ?): Connection refused
    [error] Error initializing output stream 0:0 -- 
    [aac @ 0x5632f9e2cb80] [info] Qavg: -nan
    [AVIOContext @ 0x5632f9e2e880] [verbose] Statistics: 32768 bytes read, 0 seeks
    [info] Conversion failed!
    

comment:4 by Andriy Gelman, 20 months ago

in your docker run can you try replacing:
-p 8554:8554/udp
by
-p 8554:8554

comment:5 by VidarHUN, 20 months ago

Yes, I can do this, but I want to generate UDP traffic, not TCP.

comment:6 by Andriy Gelman, 20 months ago

The lower transport will still use udp as you've setup in your .yml configuration file. But the tcp connection is needed for the rtsp setup. It's what they call handshake in rtsp-simpler-server.yml.

You can always use wireshark to check.

(Initially when testing it may be easier to use --network=host, and after you are convinced that everything is working switch to port forwarding to the docker container)

Last edited 20 months ago by Andriy Gelman (previous) (diff)

comment:7 by VidarHUN, 20 months ago

Thank you very much, using the --network=host solve the problem.

comment:8 by Andriy Gelman, 20 months ago

Resolution: invalid
Status: newclosed

in reply to:  7 comment:9 by Andriy Gelman, 20 months ago

Replying to VidarHUN:

Thank you very much, using the --network=host solve the problem.

welcome, good luck.
I've closed the ticket.

Note: See TracTickets for help on using tickets.