How to get frame number from FFMPEG RTSP stream

32 views Asked by At

I'm trying to write a script to run and maintain my live stream to youtube. Once every few hours my ffmpeg output shows that every frame is the same, so stream is not working. I want to get frame number from ffmpeg output and compare it to next output.

My output:

frame=1903903 fps= 19 q=-1.0 size=50678531kB time=28:24:20.53 bitrate=4059.8kbits/s speed=   1xframe=1903915 fps= 19 q=-1.0 size=50678759kB time=28:24:21.03 bitrate=4059.8kbits/s speed=   1xframe=1903928 fps= 19 q=-1.0 size=50679013kB time=28:24:21.55 bitrate=4059.8kbits/s speed=   1xframe=1903941 fps= 19 q=-1.0 size=50679260kB time=28:24:22.05 bitrate=4059.8kbits/s speed=   1xframe=1903953 fps= 19 q=-1.0 size=50679474kB time=28:24:22.54 bitrate=4059.8kbits/s speed=   1xframe=1903966 fps= 19 q=-1.0 size=50679709kB time=28:24:23.06 bitrate=4059.8kbits/s speed=   1xframe=1903979 fps= 19 q=-1.0 size=50679959kB time=28:24:23.57 bitrate=4059.8kbits/s speed=   1x

tail and head doesnt work since output is as i see in one big row. I don't need all this data and i think is it possible to show just one, latest ffmpeg stats. Then i could save it to file and grep frames from there.

My ffmpeg:

ffmpeg -f lavfi -i anullsrc -rtsp_transport tcp -i rtsp://192.168.51.93:554/Streaming/Channels/101 \
  -tune zerolatency -pix_fmt + -c:v copy -strict experimental -f flv -flvflags no_duration_filesize \
  rtmp://a.rtmp.youtube.com/live2/STREAM-KEY \
  2>&1

I tried tee tail -n 1 and a lot more that i find on the Internet.

0

There are 0 answers