0

I need to make this chain: JVC HM650--UDP-->localhost-->ffmpeg(copy stream)-->nginx-rtmp

On input I have UDP stream from camera (udp://@:35501) and I need it to publish to rtmp server (nginx with rtmp module). Apart everything works - I can play input on VLC, I can stream from FMLE to nginx etc. Except, this is my first time with ffmpeg and I can't get it work. So:

This is best i have got:

C:\ffmpeg\bin>ffmpeg -re -i udp://@:35501 -f flv "rtmp://192.168.1.17/live/live" -loglevel debug
ffmpeg version N-69972-g6c91afe Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.9.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnu
tls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-
libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-l
ibrtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --
enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --ena
ble-libxvid --enable-lzma --enable-decklink --enable-zlib
  libavutil      54. 19.100 / 54. 19.100
  libavcodec     56. 25.100 / 56. 25.100
  libavformat    56. 23.100 / 56. 23.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 11.100 /  5. 11.100
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Splitting the commandline.
Reading option '-re' ... matched as option 're' (read input at native frame rate) with argument '1'.
Reading option '-i' ... matched as input file with argument 'udp://@:35501'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'flv'.
Reading option 'rtmp://192.168.1.17/live/live' ... matched as output file.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument debug.
Successfully parsed a group of options.
Parsing a group of options: input file udp://@:35501.
Applying option re (read input at native frame rate) with argument 1.
Successfully parsed a group of options.
Opening an input file: udp://@:35501.
[udp @ 0000000002c30760] end receive buffer size reported is 65536
[AVIOContext @ 0000000002c513c0] Statistics: 0 bytes read, 0 seeks
udp://@:35501: Immediate exit requested
Received signal 2: terminating.

C:\ffmpeg\bin>

What is wrong with ffmpeg configuration?

SOLUTION:

The ffmpeg was listening on wrong version of UDP protocol:

Even IPv6 is disabled on network cards, internally in system, using @ allowed ffmpeg listen at UDPv6.

By using 127.0.0.1 tells ffmpeg to use clean UDP.

Thanks, @thomas to make me think differently!

Pilskalns
  • 350
  • 1
  • 2
  • 15

1 Answers1

1

It seems that your ffmpeg command is right, it works for me. For information here is the output resulting in a well configured udp connection :

...
Opening an input file: udp://@:35501.
[udp @ 0x2058c80] end receive buffer size reported is 131072
[flv @ 0x20631a0] Format flv probed with size=2048 and score=100
[flv @ 0x20631a0] Before avformat_find_stream_info() pos: 13 bytes read:2099 seeks:0
[flv @ 0x20631a0] max_analyze_duration 5000000 reached at 5016000 microseconds
rfps: 29.916667 0.015099
rfps: 30.000000 0.000067
    Last message repeated 1 times
rfps: 60.000000 0.000267
    Last message repeated 1 times
rfps: 120.000000 0.001067
    Last message repeated 1 times
rfps: 240.000000 0.004267
rfps: 29.970030 0.002007
rfps: 59.940060 0.008027
[flv @ 0x20631a0] After avformat_find_stream_info() pos: 12110 bytes read:12110 seeks:0 frames:154
Input #0, flv, from 'udp://@:35501':
  Metadata:
    AspectRatioX    : 1
    AspectRatioY    : 1
    metadatacreator : GStreamer FLV muxer
    creationdate    : Mon Feb 23 6:51:54 2015
  Duration: N/A, start: 0.002000, bitrate: N/A
    Stream #0:0, 154, 1/1000: Video: h264 (High), yuv420p, 320x240 [SAR 1:1 DAR 4:3], 1/60, 30.30 fps, 30 tbr, 1k tbn, 60 tbc
Successfully opened the file.
Parsing a group of options: output file rtmp://192.168.0.20/live/live.
Applying option f (force format) with argument flv.
Successfully parsed a group of options.
Opening an output file: rtmp://192.168.0.20/live/live.
...

It means that your incoming stream is not well configured. Are you sure that your camera is streaming to the right protocol (udp), address (ip of the ffmpeg host) and port (35501)? Maybe if you don't have it I have found the manual of your camera here : http://pro.jvc.com/pro/attributes/CAMERA/manual/GY-HM650U_V2.pdf (live streaming p.166)

I hope it will help!

thomas
  • 526
  • 3
  • 10
  • Hi, @thomas. I am confident that camera is correctly configured as I see it in VLC and we have used this camera in streaming mode for some time, even over 4G (LTE) connection and it works fine. Except, as receiving piece we use VLC, but I wan't to get rid of it and create automated and reliable workflow which doesn't include manual launch on server side. I even tried record with ffmpeg into file, but output is always unplayable 1kb file. Is there some library or windows dependencies required by ffmpeg? – Pilskalns Feb 23 '15 at 10:38
  • I have seen that sometimes ffmpeg block on the "end receive buffer size reported is 65536" step. Have you tried to : - stop streaming from the camera - restart your ffmpeg command - and then start streaming from the camera again? What type of connection do you use to stream into VLC? – thomas Feb 23 '15 at 12:13
  • Maybe I'm wrong but to be sure that you are really streaming to the udp port 35501 please stop ffmpeg and run the following python script in the command line tool : [udpserver.py](http://jammetthomas.free.fr/udpserver.py). And then start streaming from your camera. If I am right the script will wait infinitly on the line "waiting on port: 35501". – thomas Feb 23 '15 at 12:43
  • 1
    I found out solution differently, as I don't have setup Py, I am too rusty with it, haven't written any line in Py for years :) So, the thing which was confusing, that `ffmpeg` was listening to UDPv6 not simple UDP. I noticed it into TcpView (from [Sysinternals](https://technet.microsoft.com/en-us/sysinternals/bb897437)) that ffmpeg is listening to UDPv6. To correct it I just changed command from `@` to `127.0.0.1`. I got next error, but `there is no place like 127.0.0.1`, you know... – Pilskalns Feb 23 '15 at 14:13
  • Ohh, strange.. By default for me it's listening on udp v4. Well done so! What's your new error? If you are looking for a tiny server that support rtmp and rtmfp you can try [MonaServer](http://www.monaserver.ovh/) – thomas Feb 23 '15 at 14:43
  • For server I nginx-rtmp, even it is meant for Unix systems, I love experience with it on Windows and adding new module is new options on existing skills. This application won't be client network-heavy. Time ago, found good instructional tutorials on [helping-squad](helping-squad.com) site. Here's [screenshot](http://oi62.tinypic.com/2rn92m0.jpg) Errors on bottom are restarted UDP. When stop->changed bitrate inside camera->start, ffmpeg got weird output, ffmpeg restart fixes it. I want make ffmpeg parse stream settings on restart. – Pilskalns Feb 23 '15 at 16:23
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/71512/discussion-between-thomas-and-pilskalns). – thomas Feb 23 '15 at 16:40