2
1
I am an Software Engineering trainee and I need to make a video stream that continuously streams several videos on repeat.
I have made an rtmp server using nginx and their rtmp module and as streaming software I am trying to use ffmpeg
Thus far I am able to screen capture the whole screen of the server and I can stream 1 single video.
I need to stream several videos, probably with several lengths on repeat 24/7. I found some tips on the internet and it bought me to this command:
sudo ffmpeg -re -f concat -safe 0 -stream_loop -1 -i ./root.txt -an -c:v libx264 -preset veryfast -maxrate 6000k -bufsize 100000k -pix_fmt yuv420p -g 50 -fflags +genpts -f flv rtmp://ip-adress/application/key
the root.txt file contains the lines:
file 'nested.txt'
file 'nested.txt'
the file nested.txt contains:
ffconcat version 1.0
file 'earth.mp4'
file 'rabbit.mp4'
The problem I have is that when ffmpeg tries to stream the second video(rabbit.mp4) then it gets stuck and just streams the same frame. Also the client(VLC) just stops.
frame= 875 fps= 26 q=29.0 size= 2363kB time=00:00:28.70 bitrate= 674.5kbits/
frame= 888 fps= 26 q=29.0 size= 2388kB time=00:00:29.13 bitrate= 671.5kbits/
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x5634606e1cc0] Auto-inserting h264_mp4toannexb bitstream filter
frame= 900 fps= 26 q=29.0 size= 2413kB time=00:00:29.53 bitrate= 669.3kbits/
frame= 900 fps= 26 q=29.0 size= 2413kB time=00:00:29.53 bitrate= 669.3kbits/
frame= 900 fps= 25 q=29.0 size= 2413kB time=00:00:29.53 bitrate= 669.3kbits/
How can I fix this problem that the stream gets stuck when he switches between videos?
My internet searches have not found a solution.
edit:
the output of
ffmpeg -i earth.mp4 -i rabbit.mp4
ffmpeg version 4.2-0york0~18.04 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 7 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
configuration: --prefix=/usr --extra-version='0york0~18.04' --
toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-nonfree --enable-libfdk-aac --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'earth.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42mp41isomavc1
creation_time : 2015-08-07T09:13:36.000000Z
Duration: 00:00:30.53, start: 0.000000, bitrate: 4675 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 4486 kb/s, 30 fps, 30 tbr, 30 tbn, 60 tbc (default)
Metadata:
creation_time : 2015-08-07T09:13:36.000000Z
handler_name : L-SMASH Video Handler
encoder : AVC Coding
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 256 kb/s (default)
Metadata:
creation_time : 2015-08-07T09:13:36.000000Z
handler_name : L-SMASH Audio Handler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'rabbit.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
creation_time : 1970-01-01T00:00:00.000000Z
encoder : Lavf53.24.2
Duration: 00:02:50.86, start: 0.000000, bitrate: 1474 kb/s
Stream #1:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 1086 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
creation_time : 1970-01-01T00:00:00.000000Z
handler_name : VideoHandler
Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 383 kb/s (default)
Metadata:
creation_time : 1970-01-01T00:00:00.000000Z
handler_name : SoundHandler
edit nr 2: Thanks to Gyan i figured it out.
my two files had indeed not the same codecs.
so I just encoded the files again with
ffmpeg -i file.mp4 -c:v libx264 outputFile.mp4
And now the stream works. i can even change the playlist and as long as the files have the same codec, the files will be streamed.
Thnak you again !
1Share the output of
ffmpeg -i earth.mp4 -i rabbit.mp4
– Gyan – 2019-09-10T16:02:59.637