FFMPEG shows bitrate=N/A and doesn't send anything - ffmpeg

I am trying to relay an stream from one rtsp url to another without recoding using this command:
ffmpeg
-rtsp_transport tcp
-fflags nobuffer
-re
-i rtsp://xxx.xxx.xxx.xxx:554/[stream_name]
-vcodec copy
-an
-f rtsp rtsp://yyy.yyy.yyy.yyy/[new_stream_name]
But FFMPEG doesn't stream anything and stats shows bitrate=N/A
This is the exact output that i get:
ffmpeg version 4.1.3-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-6 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-gray --enable-libfribidi --enable-libass --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libxml2 --enable-libxvid --enable-libzimg
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
Input #0, rtsp, from
'rtsp://xxx.xxx.xxx.xxx:554/[stream_name]':
Metadata:
title : RTSP Session
Duration: N/A, start: 0.318111, bitrate: N/A
Stream #0:0: Video: h264 (High), yuv420p(progressive), 944x1080, 22 fps, 22 tbr, 90k tbn, 180k tbc
Output #0, rtsp, to
'rtsp://yyy.yyy.yyy.yyy/[new_stream_name]':
Metadata:
title : RTSP Session
encoder : Lavf58.20.100
Stream #0:0: Video: h264 (High), yuv420p(progressive), 944x1080, q=2-31, 22 fps, 22 tbr, 90k tbn, 90k tbc
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame= 113 fps= 32 q=-1.0 Lsize=N/A time=00:00:06.77 bitrate=N/A speed=1.92x
Although when i change output stream container to 'flv' and protocol to 'rtmp' it works.
Any help will be appreciated.

To have stream accessible you need to publish it to a streaming server that supports RTSP input (like Wowza SE) and that usually also involves publishing credentials like:
rtsp://user:password#yyy.yyy.yyy.yyy/[new_stream_name]
You can test re-streaming with this tool https://videonow.live/broadcast-ip-camera-or-stream/ that can also publish it in a HTML5 accessible format like HLS.

Related

How to generate m3u8 file and list of TS segment files using ffmpeg for wmv and avi video files

I am able to generate m3u8 and list of segment(.ts) files from mp4 video file using following ffmpeg command
ffmpeg -i Bee_Free.mp4 -codec copy -vbsf h264_mp4toannexb -map 0 -f segment -segment_list free.m3u8 -segment_time 10 free%03d.ts
I am using the same command to generate m3u8 and ts files from .wmv and .avi files
command for .avi file
ffmpeg -i PalivalaBadraVatakam.avi -codec copy -vbsf h264_mp4toannexb -map 0 -f segment -segment_list palivaala.m3u8 -segment_time 10 palivaala%03d.ts
Error
ffmpeg version N-89041-g91a565e20f Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 7.2.0 (GCC)
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-
libbluray --enable-libfreetype --enable-libmp3lame --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-cuda --enable-cuvid --enable-d3d11va --enable-nvenc --enable-dxva2 --enable-avisynth --enable-libmfx
libavutil 56. 0.100 / 56. 0.100
libavcodec 58. 3.101 / 58. 3.101
libavformat 58. 2.100 / 58. 2.100
libavdevice 58. 0.100 / 58. 0.100
libavfilter 7. 0.101 / 7. 0.101
libswscale 5. 0.101 / 5. 0.101
libswresample 3. 0.101 / 3. 0.101
libpostproc 55. 0.100 / 55. 0.100
Guessed Channel Layout for Input Stream #0.1 : stereo
Input #0, avi, from 'PalivalaBadraVatakam.avi':
Metadata:
date : 2018-04-24T17:08:40+05:30
encoder : Adobe Premiere Pro CC 2018.1 (Windows)
Duration: 00:00:53.19, start: 0.000000, bitrate: 30317 kb/s
Stream #0:0: Video: dvvideo (dvsd / 0x64737664), yuv411p, 720x480 [SAR 8:9 DAR 4:3], 28789 kb/s, 29.97 fps, 29.97 tbr, 29.97 tbn, 29.97 tbc
Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, stereo, s16, 1536 kb/s
[AVBSFContext # 000001e976f84080] Codec 'dvvideo' (24) is not supported by the bitstream filter 'h264_mp4toannexb'. Supported codecs are: h264 (27)
Error initializing bitstream filter: h264_mp4toannexb
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Last message repeated 1 times
Command for .wmv file
ffmpeg -i Palivaalaa.wmv -codec copy -vbsf h264_mp4toannexb -map 0 -f segment -segment_list palivaalaa.m3u8 -segment_time 10 palivaalaa%03d.ts
Error
ffmpeg version N-89041-g91a565e20f Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 7.2.0 (GCC)
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-
libbluray --enable-libfreetype --enable-libmp3lame --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-cuda --enable-cuvid --enable-d3d11va --enable-nvenc --enable-dxva2 --enable-avisynth --enable-libmfx
libavutil 56. 0.100 / 56. 0.100
libavcodec 58. 3.101 / 58. 3.101
libavformat 58. 2.100 / 58. 2.100
libavdevice 58. 0.100 / 58. 0.100
libavfilter 7. 0.101 / 7. 0.101
libswscale 5. 0.101 / 5. 0.101
libswresample 3. 0.101 / 3. 0.101
libpostproc 55. 0.100 / 55. 0.100
[wmv3 # 0000024020a04a40] Extra data: 8 bits left, value: 20
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, asf, from 'Palivaalaa.wmv':
Metadata:
Application : Windows Movie Maker 2.6.4037.0
WMFSDKVersion : 12.0.16299.248
WMFSDKNeeded : 0.0.0.0000
artist : Sathish
IsVBR : 0
DeviceConformanceTemplate: MP#ML
Duration: 00:01:00.10, start: 0.000000, bitrate: 571 kb/s
Stream #0:0(eng): Audio: wmav2 (a[1][0][0] / 0x0161), 44100 Hz, stereo, fltp, 96 kb/s
Stream #0:1(eng): Video: wmv3 (Main) (WMV3 / 0x33564D57), yuv420p, 640x480, 768 kb/s, SAR 1:1 DAR 4:3, 25 fps, 25 tbr, 1k tbn, 1k tbc
[AVBSFContext # 0000024020a9b420] Codec 'wmv3' (71) is not supported by the bitstream filter 'h264_mp4toannexb'. Supported codecs are: h264 (27)
Error initializing bitstream filter: h264_mp4toannexb
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Last message repeated 1 times
HLS with TS files only supports h.264 video codec and aac or mp3 audio. Hence -codec copy will not work. Just remove that, and ffmpeg should choose libx264 automatically.
This file formats support by the TS muxer are listed here https://github.com/FFmpeg/FFmpeg/blob/master/libavformat/mpegts.h#L45-L64
In summary they are:
VIDEO_MPEG1
VIDEO_MPEG2
AUDIO_MPEG1
AUDIO_MPEG2
AUDIO_AAC
AAC_LATM
VIDEO_MPEG4
METADATA
VIDEO_H264
VIDEO_HEVC
VIDEO_CAVS
VIDEO_VC1
VIDEO_DIRAC
AUDIO_AC3
AUDIO_DTS
AUDIO_TRUEHD
AUDIO_EAC3
None of the codecs you are trying are listed. And as it has in it's name the -vbsf h264_mp4toannexb and the error message Codec 'wmv3' (71) is not supported by the bitstream filter 'h264_mp4toannexb'. Supported codecs are: h264 (27), the h264_mp4toannexb filter only supports h264

Use ffmpeg for incoming youtube HLS live stream and output to rtmp

I can't get ffmpeg to work with live streams from youtube. Normal non-live videos work just fine. But with live streams ffmpeg seems like it doesn't make enough requests for new segments. It basically downloads, say a 3 second segment, then nothing happens for 10 seconds or so, then it downloads a new segment, repeat...
ffmpeg -i '$(./youtube-dl -f best -g https://www.youtube.com/watch?v=emGI3UrzIMc)' -f flv rtmp://192.168.0.11/myapp/mystream
So what's the automagic command?
ffmpeg version:
ffmpeg version 3.4.2 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 7.3.0 (Rev1, Built by MSYS2 project)
configuration: --prefix=/mingw64 --target-os=mingw32 --arch=x86_64 --disable-debug --disable-static --enable-avresample --enable-dxva2 --enable-d3d11va --enable-fontconfig --enable-gnutls --enable-gpl --enable-libass --enable-libbluray --enable-libcaca --enable-libcelt --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libx265 --enable-libxvid --enable-libvpx --enable-libwebp --enable-openal --enable-libwavpack --enable-pic --enable-postproc --enable-runtime-cpudetect --enable-shared --enable-static --enable-swresample --enable-version3 --enable-zlib --disable-doc
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libavresample 3. 7. 0 / 3. 7. 0
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
youtube-dl version: 2018.03.14
Following is the output of the command above. The <MY NOTE #> is added by me for description purposes.
At start execution goes smoothly. It then freezes for 10 or 15 sec at <MY NOTE 1>. It then downloads the part of the stream - <MY NOTE 2>, plays is, then freezes again for some seconds. Then downloads the next part - <MY NOTE 3>, plays it, freezes, and so on...
$ ffmpeg -i '$(./youtube-dl -f best -g https://www.youtube.com/watch?v=emGI3UrzIMc)' -f flv rtmp://192.168.0.11/myapp/mystream
ffmpeg version 3.4.2 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 7.3.0 (Rev1, Built by MSYS2 project)
configuration: --prefix=/mingw64 --target-os=mingw32 --arch=x86_64 --disable-debug --disable-static --enable-avresample --enable-dxva2 --enable-d3d11va --enable-fontconfig --enable-gnutls --enable-gpl --enable-libass --enable-libbluray --enable-libcaca --enable-libcelt --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libx265 --enable-libxvid --enable-libvpx --enable-libwebp --enable-openal --enable-libwavpack --enable-pic --enable-postproc --enable-runtime-cpudetect --enable-shared --enable-static --enable-swresample --enable-version3 --enable-zlib --disable-doc
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libavresample 3. 7. 0 / 3. 7. 0
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
[hls,applehttp # 00000287da404cc0] Opening 'https://r4---sn-cap1vv-nv4l.googlevideo.com/videoplayback/id/emGI3UrzIMc.0/itag/95/source/yt_live_broadcast/requiressl/yes/ratebypass/yes/live/1/cmbypass/yes/goi/160/sgoap/gir%3Dyes%3Bitag%3D140/sgovp/gir%3Dyes%3Bitag%3D136/hls_chunk_host/r4---sn-cap1vv-nv4l.googlevideo.com/ei/6jiqWt7SIJKD8gPimZTACA/playlist_type/DVR/gcr/bg/initcwndbps/10410/mm/32/mn/sn-cap1vv-nv4l/ms/lv/mv/m/pcm2cms/yes/pl/16/keepalive/yes/mt/1521105015/ip/130.204.135.162/ipbits/0/expire/1521126730/sparams/ip,ipbits,expire,id,itag,source,requiressl,ratebypass,live,cmbypass,goi,sgoap,sgovp,hls_chunk_host,ei,playlist_type,gcr,initcwndbps,mm,mn,ms,mv,pcm2cms,pl/signature/503304477BD05CCC71061344F8BB23195E152A32.512A84732C501AF08AC9340181A75D34C5B2FF77/key/dg_yt0/playlist/index.m3u8/sq/1308292/goap/clen%3D48852%3Blmt%3D1520930742662673/govp/clen%3D347004%3Blmt%3D1520930742662679/dur/2.000/file/seg.ts' for reading
Input #0, hls,applehttp, from 'https://manifest.googlevideo.com/api/manifest/hls_playlist/id/emGI3UrzIMc.0/itag/95/source/yt_live_broadcast/requiressl/yes/ratebypass/yes/live/1/cmbypass/yes/goi/160/sgoap/gir%3Dyes%3Bitag%3D140/sgovp/gir%3Dyes%3Bitag%3D136/hls_chunk_host/r4---sn-cap1vv-nv4l.googlevideo.com/ei/6jiqWt7SIJKD8gPimZTACA/playlist_type/DVR/gcr/bg/initcwndbps/10410/mm/32/mn/sn-cap1vv-nv4l/ms/lv/mv/m/pcm2cms/yes/pl/16/dover/10/keepalive/yes/mt/1521105015/ip/130.204.135.162/ipbits/0/expire/1521126730/sparams/ip,ipbits,expire,id,itag,source,requiressl,ratebypass,live,cmbypass,goi,sgoap,sgovp,hls_chunk_host,ei,playlist_type,gcr,initcwndbps,mm,mn,ms,mv,pcm2cms,pl/signature/503304477BD05CCC71061344F8BB23195E152A32.512A84732C501AF08AC9340181A75D34C5B2FF77/key/dg_yt0/playlist/index.m3u8':
Duration: N/A, start: 39603.798400, bitrate: N/A
Program 0
Metadata:
variant_bitrate : 0
Stream #0:0: Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp
Metadata:
variant_bitrate : 0
Stream #0:1: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 30 fps, 30 tbr, 90k tbn, 60 tbc
Metadata:
variant_bitrate : 0
Stream mapping:
Stream #0:1 -> #0:0 (h264 (native) -> flv1 (flv))
Stream #0:0 -> #0:1 (aac (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
Output #0, flv, to 'rtmp://192.168.0.11/myapp/mystream':
Metadata:
encoder : Lavf57.83.100
Stream #0:0: Video: flv1 (flv) ([2][0][0][0] / 0x0002), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 30 fps, 1k tbn, 30 tbc
Metadata:
variant_bitrate : 0
encoder : Lavc57.107.100 flv
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
Stream #0:1: Audio: mp3 (libmp3lame) ([2][0][0][0] / 0x0002), 48000 Hz, stereo, fltp
Metadata:
variant_bitrate : 0
<MY NOTE 1>encoder : Lavc57.107.100 libmp3lame
<MY NOTE 2>[hls,applehttp # 00000287da404cc0] Opening 'https://r4---sn-cap1vv-nv4l.googlevideo.com/videoplayback/id/emGI3UrzIMc.0/itag/95/source/yt_live_broadcast/requiressl/yes/ratebypass/yes/live/1/cmbypass/yes/goi/160/sgoap/gir%3Dyes%3Bitag%3D140/sgovp/gir%3Dyes%3Bitag%3D136/hls_chunk_host/r4---sn-cap1vv-nv4l.googlevideo.com/ei/6jiqWt7SIJKD8gPimZTACA/playlist_type/DVR/gcr/bg/initcwndbps/10410/mm/32/mn/sn-cap1vv-nv4l/ms/lv/mv/m/pcm2cms/yes/pl/16/keepalive/yes/mt/1521105015/ip/130.204.135.162/ipbits/0/expire/1521126730/sparams/ip,ipbits,expire,id,itag,source,requiressl,ratebypass,live,cmbypass,goi,sgoap,sgovp,hls_chunk_host,ei,playlist_type,gcr,initcwndbps,mm,mn,ms,mv,pcm2cms,pl/signature/503304477BD05CCC71061344F8BB23195E152A32.512A84732C501AF08AC9340181A75D34C5B2FF77/key/dg_yt0/playlist/index.m3u8/sq/1308293/goap/clen%3D48853%3Blmt%3D1520930742662680/govp/clen%3D404944%3Blmt%3D1520930742662686/dur/2.000/file/seg.ts' for reading
<MY NOTE 3>[hls,applehttp # 00000287da404cc0] Opening 'https://r4---sn-cap1vv-nv4l.googlevideo.com/videoplayback/id/emGI3UrzIMc.0/itag/95/source/yt_live_broadcast/requiressl/yes/ratebypass/yes/live/1/cmbypass/yes/goi/160/sgoap/gir%3Dyes%3Bitag%3D140/sgovp/gir%3Dyes%3Bitag%3D136/hls_chunk_host/r4---sn-cap1vv-nv4l.googlevideo.com/ei/6jiqWt7SIJKD8gPimZTACA/playlist_type/DVR/gcr/bg/initcwndbps/10410/mm/32/mn/sn-cap1vv-nv4l/ms/lv/mv/m/pcm2cms/yes/pl/16/keepalive/yes/mt/1521105015/ip/130.204.135.162/ipbits/0/expire/1521126730/sparams/ip,ipbits,expire,id,itag,source,requiressl,ratebypass,live,cmbypass,goi,sgoap,sgovp,hls_chunk_host,ei,playlist_type,gcr,initcwndbps,mm,mn,ms,mv,pcm2cms,pl/signature/503304477BD05CCC71061344F8BB23195E152A32.512A84732C501AF08AC9340181A75D34C5B2FF77/key/dg_yt0/playlist/index.m3u8/sq/1308294/goap/clen%3D48852%3Blmt%3D1520930742662688/govp/clen%3D403294%3Blmt%3D1520930742662693/dur/2.000/file/seg.ts' for reading
[hls,applehttp # 00000287da404cc0] Opening 'https://r4---sn-cap1vv-nv4l.googlevideo.com/videoplayback/id/emGI3UrzIMc.0/itag/95/source/yt_live_broadcast/requiressl/yes/ratebypass/yes/live/1/cmbypass/yes/goi/160/sgoap/gir%3Dyes%3Bitag%3D140/sgovp/gir%3Dyes%3Bitag%3D136/hls_chunk_host/r4---sn-cap1vv-nv4l.googlevideo.com/ei/6jiqWt7SIJKD8gPimZTACA/playlist_type/DVR/gcr/bg/initcwndbps/10410/mm/32/mn/sn-cap1vv-nv4l/ms/lv/mv/m/pcm2cms/yes/pl/16/keepalive/yes/mt/1521105015/ip/130.204.135.162/ipbits/0/expire/1521126730/sparams/ip,ipbits,expire,id,itag,source,requiressl,ratebypass,live,cmbypass,goi,sgoap,sgovp,hls_chunk_host,ei,playlist_type,gcr,initcwndbps,mm,mn,ms,mv,pcm2cms,pl/signature/503304477BD05CCC71061344F8BB23195E152A32.512A84732C501AF08AC9340181A75D34C5B2FF77/key/dg_yt0/playlist/index.m3u8/sq/1308295/goap/clen%3D48355%3Blmt%3D1520930742662695/govp/clen%3D358330%3Blmt%3D1520930742662700/dur/2.000/file/seg.ts' for reading
[hls,applehttp # 00000287da404cc0] Opening 'https://r4---sn-cap1vv-nv4l.googlevideo.com/videoplayback/id/emGI3UrzIMc.0/itag/95/source/yt_live_broadcast/requiressl/yes/ratebypass/yes/live/1/cmbypass/yes/goi/160/sgoap/gir%3Dyes%3Bitag%3D140/sgovp/gir%3Dyes%3Bitag%3D136/hls_chunk_host/r4---sn-cap1vv-nv4l.googlevideo.com/ei/6jiqWt7SIJKD8gPimZTACA/playlist_type/DVR/gcr/bg/initcwndbps/10410/mm/32/mn/sn-cap1vv-nv4l/ms/lv/mv/m/pcm2cms/yes/pl/16/keepalive/yes/mt/1521105015/ip/130.204.135.162/ipbits/0/expire/1521126730/sparams/ip,ipbits,expire,id,itag,source,requiressl,ratebypass,live,cmbypass,goi,sgoap,sgovp,hls_chunk_host,ei,playlist_type,gcr,initcwndbps,mm,mn,ms,mv,pcm2cms,pl/signature/503304477BD05CCC71061344F8BB23195E152A32.512A84732C501AF08AC9340181A75D34C5B2FF77/key/dg_yt0/playlist/index.m3u8/sq/1308296/goap/clen%3D48852%3Blmt%3D1520930742662701/govp/clen%3D347658%3Blmt%3D1520930742662707/dur/2.000/file/seg.ts' for reading
frame= 225 fps=1.8 q=31.0 size= 947kB time=00:00:07.92 bitrate= 979.2kbits/s speed=0.0625x
And you don't have to output to a rtmp. Can be a local file - behavior is the same.
Try using the hls prefix. Example:
ffmpeg -i "hls+$(./youtube-dl -f best -g https://www.youtube.com/watch?v=emGI3UrzIMc)" -f flv rtmp://192.168.0.11/myapp/mystream

Error recording an RTSP stream without transcoding

I'm trying to use FFmpeg to record RTSP streams from several security cameras. I have been successfully transcoding each stream for months now, but since this requires considerable CPU power, I'd like to simply copy each stream to disk in it's original H.264 format.
Whenever I try this, I receive and error similar to this (the "current" value varies):
Non-monotonous DTS in output stream 0:0; previous: 0, current: -62743;
I've stripped most of the options I was using, although I really do want to keep -xerror so that FFmpeg quits when it encounters an error:
ffmpeg.exe -xerror -i rtsp://admin:admin#192.168.1.135 -an -vcodec copy test.mp4
And I still get this:
ffmpeg version 3.3.3 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 7.1.0 (GCC)
configuration: --enable-gpl
--enable-version3 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --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-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-zlib
libavutil 55. 58.100 / 55. 58.100
libavcodec 57. 89.100 / 57. 89.100
libavformat 57. 71.100 / 57. 71.100
libavdevice 57. 6.100 / 57. 6.100
libavfilter 6. 82.100 / 6. 82.100
libswscale 4. 6.100 / 4. 6.100
libswresample 2. 7.100 / 2. 7.100
libpostproc 54. 5.100 / 54. 5.100
[udp # 0000000002533b60] 'circular_buffer_size' option was set but it is not supported on this build (pthread support is required)
[udp # 0000000000ec97a0] 'circular_buffer_size' option was set but it is not supported on this build (pthread support is required)
Input #0, rtsp, from 'rtsp://admin:admin#192.168.1.135': Metadata:
title : RTSP Session/2.0 Duration: N/A, start: 0.837144, bitrate: N/A
Stream #0:0: Video: h264 (High), yuvj420p(pc, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 7 fps, 25 tbr, 90k tbn, 14 tbc Output
#0, mp4, to 'test.mp4': Metadata:
title : RTSP Session/2.0
y encoder : Lavf57.71.100
Stream #0:0: Video: h264 (High) ([33][0][0][0] / 0x0021), yuvj420p(pc, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 7 fps, 25 tbr, 90k tbn, 90k tbc
Stream mapping: Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[mp4 # 00000000036b8340] Non-monotonous DTS in output stream 0:0; previous: 0, current: -62743; aborting.
Conversion failed!
Can anyone explain what the problem is and/or suggest the appropriate flags to handle this?

Cannot retrieve duration of webm file using ffmpeg

I am trying to retrieve the duration of a .webm video file that I recorded using the the video.js plugin (https://github.com/collab-project/videojs-record).
I am using ffmpeg to get the duration but it always return N/A:
ffprobe version 3.0.2-static http://johnvansickle.com/ffmpeg/ Copyright (c) 2007-2016 the FFmpeg developers
built with gcc 5.3.1 (Debian 5.3.1-16) 20160424
configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --enable-libmp3lame --enable-libx264 --enable-libx265 --enable-libwebp --enable-libspeex --enable-libvorbis --enable-libvpx --enable-libfreetype --enable-fontconfig --enable-libxvid --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvo-amrwbenc --enable-gray --enable-libopenjpeg --enable-libopus --enable-libass --enable-gnutls --enable-libvidstab --enable-libsoxr --enable-frei0r --enable-libfribidi --disable-indev=sndio --disable-outdev=sndio --enable-librtmp --enable-libmfx --enable-libzimg --cc=gcc
libavutil 55. 17.103 / 55. 17.103
libavcodec 57. 24.102 / 57. 24.102
libavformat 57. 25.100 / 57. 25.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 31.100 / 6. 31.100
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, matroska,webm, from '/home/demoss/public_html/source/bALRt9I697PVQh4zglou.webm':
Metadata:
encoder : Chrome
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0(eng): Video: vp8, yuv420p, 640x480, SAR 1:1 DAR 4:3, 30 fps, 30 tbr, 1k tbn, 1k tbc (default)
Stream #0:1(eng): Audio: opus, 48000 Hz, mono, fltp (default)
duration=N/A
I don't think the video is corrupted as it played in my VideoJS player without issues.
Any pointers as to why its not returning the duration would be greatly appreciated. I wouldn't mind using an alternative library as well
Thanks
If ffprobe/ffmpeg does not show the format or stream durations then you can fully decode the file to find the duration:
ffmpeg -i input.webm -f null -
...
frame= 2087 fps=0.0 q=-0.0 Lsize=N/A time=00:01:23.48 bitrate=N/A speed= 123x
Refer to time= in the second-to-last line in the output. In this example the file duration is 00:01:23.48.
Depending on the duration and complexity of your input this may take some time.
Also see FFmpeg Wiki: FFprobe Tips - Duration.
I was able to convert the webm to mp4 using the following command:
ffmpeg -fflags +genpts -i myfile.webm -r 24 mynew.mp4
I am not quite sure of how it works internally, but I hope the experts could expand on this.
Hope this helps someone

linux ffmpeg get rtmp stream and convert into a live webcam v4l2

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

Resources