Closed GhostlyCrowd closed 2 years ago
Ive actually got live view, in mobile app live view and recording all working now. THe issue is i had to edit the code to force in ffmpeg args because of the error above, so i had to make the ffmpeg args
default='-c:v copy -bsf:v "h264_metadata=tick_rate=30000/1001:fixed_frame_rate_flag=1" -ar 32000 -ac 2 -codec:a aac -b:a 32k',
@keshavdv can you please advice how to fix the error im getting trying to pass arguments or if there is a way i can include this as a default in my reolink.py
I think alot of people are going to be happy.
-bsf:v "h264_metadata=tick_rate=30000/1001:fixed_frame_rate_flag=1"
Is the new magic for new versions of ffmpeg as -vbsf is depreciated.
Thanks for figuring out the new bitfilter format! I'd love to figure out exactly which version of ffmpeg supports this style of flags and add some logic to use the correct set of arguments since that will also allow me to fix #55. Do you know when this new format was introduced?
Thanks for figuring out the new bitfilter format! I'd love to figure out exactly which version of ffmpeg supports this style of flags and add some logic to use the correct set of arguments since that will also allow me to fix #55. Do you know when this new format was introduced?
somewhere between V3.4.X and 4.1.X I have not looked that deep into it yet. I am kind of learning as i go here.
Do you have any incite as to why i cannot pass --ffmpeg-args as explained above? ive been having to manually edit the default in base.py each time i want to try new arguments with my PR.
Ive also found that fixed_frame_rate_flag=1
is no longer supported in the latest ffmpeg 4.3.3 it throws an error. so there seems to be maybe even more changes we need to investigate to get this project working with the most recent ffmpeg.
This looks like https://stackoverflow.com/questions/16174992/cant-get-argparse-to-read-quoted-string-with-dashes-in-it so I'd suggest trying
--ffmpeg-args='-bsf:v "h264_metadata=tick_rate=30000/1001:fixed_frame_rate_flag=1"'
Can you share ffmpeg output both with and without fixed_frame_rate_flag
and corresponding error? The option itself is still supported and isn't deprecated, but the implementation might have changed in recent ffmpeg releases.
This looks like https://stackoverflow.com/questions/16174992/cant-get-argparse-to-read-quoted-string-with-dashes-in-it so I'd suggest trying
--ffmpeg-args='-bsf:v "h264_metadata=tick_rate=30000/1001:fixed_frame_rate_flag=1"'
Can you share ffmpeg output both with and without
fixed_frame_rate_flag
and corresponding error? The option itself is still supported and isn't deprecated, but the implementation might have changed in recent ffmpeg releases.
I thought i replied to this already sorry. Turns out I'm a fool I was missing the = in my ffmpef-args so thats working fine. As for the ffmpeg error im no longer on a version of ffmpeg that is an issue. But its been discussed here https://github.com/keshavdv/unifi-cam-proxy/issues/31#issuecomment-1000504396 and the error is
[h264_metadata @ 0x558813a280] Failed to write extradata.
Error initializing bitstream filter: h264_metadata```
@keshavdv Here is the output you wanted
y$ ffmpeg -nostdin -y -stimeout 15000000 -rtsp_transport tcp -i "rtsp://unifiprotect:jjh423600@192.168.7.100:554//h264Preview_01_main" -c:v copy -bsf:v "h264_metadata=tick_rate=60000/1001:fixed_frame_rate_flag=1" -ar 32000 -ac 2 -codec:a aac -b:a 32k -metadata streamname=VIt3mr7LLdjlN8p7 -f flv - | /usr/bin/python3 -m unifi.clock_sync | nc 192.168.7.245 7550
ffmpeg version 4.3.3-0+deb11u1 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 10 (Debian 10.2.1-6)
configuration: --prefix=/usr --extra-version=0+deb11u1 --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-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --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-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --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-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Input #0, rtsp, from 'rtsp://unifiprotect:jjh423600@192.168.7.100:554//h264Preview_01_main':
Metadata:
title : Session streamed by "preview"
comment : h264Preview_01_main
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: h264 (Baseline), yuv420p(progressive), 2560x1920, 12 tbr, 90k tbn, 180k tbc
Stream #0:1: Audio: aac (LC), 16000 Hz, mono, fltp
[h264_metadata @ 0x561f0f0db540] low_delay_hrd_flag does not match inferred value: 1, but should be 0.
[h264_metadata @ 0x561f0f0db540] Failed to write unit 0 (type 7).
[h264_metadata @ 0x561f0f0db540] Failed to write extradata.
Error initializing bitstream filter: h264_metadata
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Last message repeated 1 times
And with out the ixed_frame_rate_flag
ffmpeg -nostdin -y -stimeout 15000000 -rtsp_transport tcp -i "rtsp://unifiprotect:jjh423600@192.168.7.100:554//h264Preview_01_main" -c:v copy -bsf:v "h264_metadata=tick_rate=60000/1001" -ar 32000 -ac 2 -codec:a aac -b:a 32k -metadata streamname=VIt3mr7LLdjlN8p7 -f flv - | /usr/bin/python3 -m unifi.clock_sync | nc 192.168.7.245 7550
ffmpeg version 4.3.3-0+deb11u1 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 10 (Debian 10.2.1-6)
configuration: --prefix=/usr --extra-version=0+deb11u1 --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-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --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-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --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-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Input #0, rtsp, from 'rtsp://unifiprotect:jjh423600@192.168.7.100:554//h264Preview_01_main':
Metadata:
title : Session streamed by "preview"
comment : h264Preview_01_main
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: h264 (Baseline), yuv420p(progressive), 2560x1920, 12 tbr, 90k tbn, 180k tbc
Stream #0:1: Audio: aac (LC), 16000 Hz, mono, fltp
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Output #0, flv, to 'pipe:':
Metadata:
title : Session streamed by "preview"
comment : h264Preview_01_main
streamname : VIt3mr7LLdjlN8p7
encoder : Lavf58.45.100
Stream #0:0: Video: h264 (Baseline) ([7][0][0][0] / 0x0007), yuv420p(progressive), 2560x1920, q=2-31, 12 tbr, 1k tbn, 90k tbc
Stream #0:1: Audio: aac (LC) ([10][0][0][0] / 0x000A), 32000 Hz, stereo, fltp, 32 kb/s
Metadata:
encoder : Lavc58.91.100 aac
[flv @ 0x55aa769eda00] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
[aac @ 0x55aa769ee8c0] Queue input is backward in time
[flv @ 0x55aa769eda00] Non-monotonous DTS in output stream 0:1; previous: 672, current: 589; changing to 672. This may result in incorrect timestamps in the output file.
[flv @ 0x55aa769eda00] Non-monotonous DTS in output stream 0:1; previous: 672, current: 621; changing to 672. This may result in incorrect timestamps in the output file.
[flv @ 0x55aa769eda00] Non-monotonous DTS in output stream 0:1; previous: 672, current: 653; changing to 672. This may result in incorrect timestamps in the output file.
@keshavdv I'm working on main and substream separation now. Mainly the substream if i use it the web app and mobile app preview and live views are 100% stable. and in reality We should just want full resolution for recording.
I see 3 video streams are spawned 1-3 what one is for what? is Video1 say for recording or high rez viewing and Video2 is for ow resolution viewing and preview? and video 3 should never spawn with a snapshot url correct?
Fat fingers on mobile sorry
Finally, after a back and forth between flake8 and isort the actions passes and Lint is happy with everything.
i have tested over three different OS , ubuntu , photonOS and finally debian , with a reolink rlc520a does not work at resolution 2560x1440 , try different bitrates but nothing .... lowest is 1024
continue respawning ffmpeg.
ok now it's work , the only thing that i have changed is the cam firmware , works with the latest reolink firmware that they have made improvements in the rtsp feed. it's smooth at 1024 and 2048 , at 4096 start loosing some frames looking at the clock, resolution 2560x1440
@GhostlyCrowd i don't think is a VM cpu problem , i have tested on the old and new server , it's not a cpu limit i think. probably is the ffmpeg metadata injector ....
any chance to get onvif alerts? i'm really interested in this project , i'm not a programmer but i can port forward my cam and donate $$ :)
ok now it's work , the only thing that i have changed is the cam firmware , works with the latest reolink firmware that they have made improvements in the rtsp feed. it's smooth at 1024 and 2048 , at 4096 start loosing some frames looking at the clock, resolution 2560x1440
@GhostlyCrowd i don't think is a VM cpu problem , i have tested on the old and new server , it's not a cpu limit i think. probably is the ffmpeg metadata injector ....
any chance to get onvif alerts? i'm really interested in this project , i'm not a programmer but i can port forward my cam and donate $$ :)
Link to firmware?
Also 1024 and 2048 bit rate is the butter zone for these cameras otherwise with 3 streams open they begin to choke.
https://reolink.com/download-center/?utm_source=Rdt&utm_medium=Post&utm_campaign=Rdt+Sidebar
but my is RLC-520A , the A version have vehicle and person detection
Work in progress getting Standalone Reolink cams to work more in line with how t he ReolinkNVR parts work.
What's working:
-s main, or -s sub
argument note, is maximum 15fps so usetick_rate-30000/1001
What's not working:
Examples on how to use:
Main camera stream example
Sub camera stream example
(Note: Camera/channel arguments are either -s main, or -s sub. The substream is limited to a maximum 15fps so note the tick_rate in the example)
Possibly a limitation of my VM I'm testing I cannot get smooth Live view on mobile/web if the main streams bitrate is over 1024
The Reolink part of this project seems to not work well any more many of us seem to fail to get it to work. I'm not a pro but this is my small contribution, and I'm learning along the way.