So I simply try out to get the stream and convert it into a rawvideo and create a new webcam with v4l2.
ffmpeg -i "rtmp://XX.XX.XXX.XXX/XXXXXXXXXXXX/test" -vcodec rawvideo -y -f v4l2 /dev/video2
It is working a long time and then I got this:
ffmpeg version 2.7.1 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 5.1.0 (GCC)
configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gnutls --enable-gpl --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-shared --enable-version3 --enable-x11grab
libavutil 54. 27.100 / 54. 27.100
libavcodec 56. 41.100 / 56. 41.100
libavformat 56. 36.100 / 56. 36.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 16.101 / 5. 16.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.100 / 1. 2.100
libpostproc 53. 3.100 / 53. 3.100
Input #0, flv, from 'rtmp://XX.XX.XXX.XXX/XXXXXXXXXXXX/test':
Metadata:
fileSize : 0
audiochannels : 2
encoder : obs-output module (libobs version 0.10.1-67-g94edb7f)
Duration: 00:00:00.00, start: 1774.608000, bitrate: N/A
Stream #0:0: Video: h264 (High), yuv420p(tv, bt709), 1920x1080, 2560 kb/s, 30.30 fps, 30 tbr, 1k tbn, 60 tbc
Stream #0:1: Audio: aac (LC), 44100 Hz, stereo, fltp, 196 kb/s
[v4l2 @ 0x7f7326cb4480] Unable to open V4L2 device '/dev/video2'
Output #0, v4l2, to '/dev/video2':
Metadata:
fileSize : 0
audiochannels : 2
encoder : Lavf56.36.100
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1920x1080, q=2-31, 200 kb/s, 30 fps, 30 tbn, 30 tbc
Metadata:
encoder : Lavc56.41.100 rawvideo
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> rawvideo (native))
Could not write header for output file #0 (incorrect codec parameters ?): No such file or directory
To create virtual video devices you need to install and enable v4l2loopback. The "No such file or directory" message means you didn't enable the device.
sudo modprobe v4l2loopback video_nr=2
This will create the /dev/video2
device.
Update: in response to umläute's comment make sure the v4l2loopback module is persistent, just in case your server reboots. Uptime can be very long.
Example for CentOS: Persistent Module Loading