RTSP stream do 30min souborů

RTSP stream do 30min souborů
« kdy: 10. 05. 2014, 00:39:22 »
Ahoj,
potrebuju ukladat video z RTSP streamu kamery do souboru dlouhych 30 minut. Z kamery leze H.264 1280x720@30.

Kdyz zkusim pomoci ffmpeg udelat jpg obrazek, funguje to:
Kód: [Vybrat]
martin@martin:/tmp/camera$ ffmpeg -i rtsp://:@192.168.123.10:8554/live0.264 -y -f image2 -sameq -t 0.0001 /tmp/camera/obrazek.jpg
ffmpeg version 0.8.10-4:0.8.10-0ubuntu0.12.04.1, Copyright (c) 2000-2013 the Libav developers
  built on Feb  6 2014 20:56:59 with gcc 4.6.3
*** THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
[rtsp @ 0xacf9c0] Estimating duration from bitrate, this may be inaccurate

Seems stream 0 codec frame rate differs from container frame rate: 180000.00 (180000/1) -> 25.00 (25/1)
Input #0, rtsp, from 'rtsp://:@192.168.123.10:8554/live0.264':
  Metadata:
    title           : Session streamed by "rtspServerForJovision"
    comment         : live0.264
  Duration: N/A, start: 47721.859625, bitrate: N/A
    Stream #0.0: Video: h264 (Baseline), yuv420p, 1280x720, 25 tbr, 90k tbn, 180k tbc
    Stream #0.1: Audio: pcm_mulaw, 8000 Hz, 1 channels, s16, 64 kb/s
Incompatible pixel format 'yuv420p' for codec 'mjpeg', auto-selecting format 'yuvj420p'
[buffer @ 0xb74220] w:1280 h:720 pixfmt:yuv420p
[avsink @ 0xb99640] auto-inserting filter 'auto-inserted scaler 0' between the filter 'src' and the filter 'out'
[scale @ 0xacf4c0] w:1280 h:720 fmt:yuv420p -> w:1280 h:720 fmt:yuvj420p flags:0x4
Output #0, image2, to '/tmp/camera/obrazek.jpg':
  Metadata:
    title           : Session streamed by "rtspServerForJovision"
    comment         : live0.264
    encoder         : Lavf53.21.1
    Stream #0.0: Video: mjpeg, yuvj420p, 1280x720, q=2-31, 200 kb/s, 90k tbn, 25 tbc
Stream mapping:
  Stream #0.0 -> #0.0
Press ctrl-c to stop encoding
frame=    1 fps=  0 q=0.0 Lsize=      -0kB time=0.04 bitrate=  -4.4kbits/s   
video:75kB audio:0kB global headers:0kB muxing overhead -100.028829%
martin@martin:/tmp/camera$

Pokud pres ffmpeg chci nahrat video, spadne to:
Kód: [Vybrat]
martin@martin:/tmp/camera$ ffmpeg -i rtsp://:@192.168.123.10:8554/live0.264 -vcodec copy -map 0 -f segment -segment_time 30 -segment_format mp4 "out%03d.mp4"
ffmpeg version 0.8.10-4:0.8.10-0ubuntu0.12.04.1, Copyright (c) 2000-2013 the Libav developers
  built on Feb  6 2014 20:56:59 with gcc 4.6.3
*** THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
[rtsp @ 0x1c059c0] Estimating duration from bitrate, this may be inaccurate

Seems stream 0 codec frame rate differs from container frame rate: 180000.00 (180000/1) -> 25.00 (25/1)
Input #0, rtsp, from 'rtsp://:@192.168.123.10:8554/live0.264':
  Metadata:
    title           : Session streamed by "rtspServerForJovision"
    comment         : live0.264
  Duration: N/A, start: 47721.859625, bitrate: N/A
    Stream #0.0: Video: h264 (Baseline), yuv420p, 1280x720, 25 tbr, 90k tbn, 180k tbc
    Stream #0.1: Audio: pcm_mulaw, 8000 Hz, 1 channels, s16, 64 kb/s
Output #0, segment, to 'out%03d.mp4':
  Metadata:
    title           : Session streamed by "rtspServerForJovision"
    comment         : live0.264
    encoder         : Lavf53.21.1
    Stream #0.0: Video: libx264, yuv420p, 1280x720, q=2-31, 90k tbn, 90k tbc
Stream mapping:
  Stream #0.0 -> #0.0
Press ctrl-c to stop encoding
[segment @ 0x1c0db60] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 233929 >= 230075
av_interleaved_write_frame(): Invalid argument
martin@martin:/tmp/camera$

Novejsi avconv (nastupce ffmpeg) taky spadne:
Kód: [Vybrat]
martin@martin:/tmp/camera$ avconv -i rtsp://:@192.168.123.10:8554/live0.264 -vcodec copy -map 0 -f segment -segment_time 30 -segment_format mp4 "out%03d.mp4"
avconv version 0.8.10-4:0.8.10-0ubuntu0.12.04.1, Copyright (c) 2000-2013 the Libav developers
  built on Feb  6 2014 20:56:59 with gcc 4.6.3
[rtsp @ 0x15ce9c0] Estimating duration from bitrate, this may be inaccurate
Input #0, rtsp, from 'rtsp://:@192.168.123.10:8554/live0.264':
  Metadata:
    title           : Session streamed by "rtspServerForJovision"
    comment         : live0.264
  Duration: N/A, start: 47721.863750, bitrate: N/A
    Stream #0.0: Video: h264 (Baseline), yuv420p, 1280x720, 25 tbr, 90k tbn, 180k tbc
    Stream #0.1: Audio: pcm_mulaw, 8000 Hz, 1 channels, s16, 64 kb/s
Output #0, segment, to 'out%03d.mp4':
  Metadata:
    title           : Session streamed by "rtspServerForJovision"
    comment         : live0.264
    Stream #0.0: Video: libx264, yuv420p, 1280x720, q=2-31, 90k tbn, 90k tbc
    Stream #0.1: Audio: [0][0][0][0] / 0x0000, 8000 Hz, 1 channels, s16, 200 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (pcm_mulaw -> ?)
Encoder (codec id 0) not found for output stream #0:1
martin@martin:/tmp/camera$

Protoze zaznam potrebuju delat na OpenWrt, nejradeji bych pouzil program openRTSP.
Marne se snazim sestavit parametry programu.

Teoreticky by melo fungovat, ale jen to vypise seznam parametru:
Kód: [Vybrat]
martin@martin:/tmp/camera$ openRTSP -4 -w 1280 -h 720 -f 30 -P 10 "rtsp://:@192.168.123.10:8554/live0.264" > video.mp4
Usage: openRTSP [-p <startPortNum>] [-r|-q|-4|-i] [-a|-v] [-V] [-d <duration>] [-D <max-inter-packet-gap-time> [-c] [-S <offset>] [-n] [-O] [-t|-T <http-port>] [-u <username> <password>] [-s <initial-seek-time>] [-z <scale>] [-w <width> -h <height>] [-f <frames-per-second>] [-y] [-H] [-Q [<measurement-interval>]] [-F <filename-prefix>] [-b <file-sink-buffer-size>] [-B <input-socket-buffer-size>] [-I <input-interface-ip-address>] [-m] <url> (or openRTSP -o [-V] <url>)
martin@martin:/tmp/camera$

Pro tento prikaz sice dostanu video, ale jedno dlouhe a obsahuje pouze audio stopu:
Kód: [Vybrat]
martin@martin:/tmp/camera$ openRTSP -4 -w 1280 -h 720 -f 30  "rtsp://:@192.168.123.10:8554/live0.264" > video.mp4
Opening connection to 192.168.123.10, port 8554...
...remote connection opened
Sending request: OPTIONS rtsp://:@192.168.123.10:8554/live0.264 RTSP/1.0
CSeq: 2
User-Agent: openRTSP (LIVE555 Streaming Media v2011.12.23)


Received 152 new bytes of response data.
Received a complete OPTIONS response:
RTSP/1.0 200 OK
CSeq: 2
Date: Fri, May 09 2014 22:17:00 GMT
Public: OPTIONS, DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE, GET_PARAMETER, SET_PARAMETER


Sending request: DESCRIBE rtsp://:@192.168.123.10:8554/live0.264 RTSP/1.0
CSeq: 3
User-Agent: openRTSP (LIVE555 Streaming Media v2011.12.23)
Accept: application/sdp


Received 752 new bytes of response data.
Received a complete DESCRIBE response:
RTSP/1.0 200 OK
CSeq: 3
Date: Fri, May 09 2014 22:17:39 GMT
Content-Base: rtsp://192.168.123.10:8554/live0.264/
Content-Type: application/sdp
Content-Length: 582

v=0
o=- 946684803400769 1 IN IP4 192.168.123.10
s=Session streamed by "rtspServerForJovision"
i=live0.264
t=0 0
a=tool:LIVE555 Streaming Media v2013.09.18
a=type:broadcast
a=control:*
a=range:npt=0-
a=x-qt-text-nam:Session streamed by "rtspServerForJovision"
a=x-qt-text-inf:live0.264
m=video 0 RTP/AVP 96
c=IN IP4 0.0.0.0
b=AS:3072
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1;profile-level-id=42001F;sprop-parameter-sets=Z0IAH5WoFAFuQA==,aM48gA==
a=control:track1
m=audio 0 RTP/AVP 97
c=IN IP4 0.0.0.0
b=AS:40
a=rtpmap:97 PCMU/8000
a=control:track2

Opened URL "rtsp://:@192.168.123.10:8554/live0.264", returning a SDP description:
v=0
o=- 946684803400769 1 IN IP4 192.168.123.10
s=Session streamed by "rtspServerForJovision"
i=live0.264
t=0 0
a=tool:LIVE555 Streaming Media v2013.09.18
a=type:broadcast
a=control:*
a=range:npt=0-
a=x-qt-text-nam:Session streamed by "rtspServerForJovision"
a=x-qt-text-inf:live0.264
m=video 0 RTP/AVP 96
c=IN IP4 0.0.0.0
b=AS:3072
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1;profile-level-id=42001F;sprop-parameter-sets=Z0IAH5WoFAFuQA==,aM48gA==
a=control:track1
m=audio 0 RTP/AVP 97
c=IN IP4 0.0.0.0
b=AS:40
a=rtpmap:97 PCMU/8000
a=control:track2

Created receiver for "video/H264" subsession (client ports 48522-48523)
Created receiver for "audio/PCMU" subsession (client ports 49346-49347)
Sending request: SETUP rtsp://192.168.123.10:8554/live0.264/track1 RTSP/1.0
CSeq: 4
User-Agent: openRTSP (LIVE555 Streaming Media v2011.12.23)
Transport: RTP/AVP;unicast;client_port=48522-48523


Received 206 new bytes of response data.
Received a complete SETUP response:
RTSP/1.0 200 OK
CSeq: 4
Date: Fri, May 09 2014 22:17:44 GMT
Transport: RTP/AVP;unicast;destination=192.168.250.1;source=192.168.123.10;client_port=48522-48523;server_port=6970-6971
Session: 45A2B7CA


Setup "video/H264" subsession (client ports 48522-48523)
Sending request: SETUP rtsp://192.168.123.10:8554/live0.264/track2 RTSP/1.0
CSeq: 5
User-Agent: openRTSP (LIVE555 Streaming Media v2011.12.23)
Transport: RTP/AVP;unicast;client_port=49346-49347
Session: 45A2B7CA


Received 206 new bytes of response data.
Received a complete SETUP response:
RTSP/1.0 200 OK
CSeq: 5
Date: Fri, May 09 2014 22:17:44 GMT
Transport: RTP/AVP;unicast;destination=192.168.250.1;source=192.168.123.10;client_port=49346-49347;server_port=6972-6973
Session: 45A2B7CA


Setup "audio/PCMU" subsession (client ports 49346-49347)
Sending request: PLAY rtsp://192.168.123.10:8554/live0.264/ RTSP/1.0
CSeq: 6
User-Agent: openRTSP (LIVE555 Streaming Media v2011.12.23)
Session: 45A2B7CA
Range: npt=0.000-


Received 264 new bytes of response data.
Received a complete PLAY response:
RTSP/1.0 200 OK
CSeq: 6
Date: Fri, May 09 2014 22:17:44 GMT
Range: npt=0.000-
Session: 45A2B7CA
RTP-Info: url=rtsp://192.168.123.10:8554/live0.264/track1;seq=62543;rtptime=275227053,url=rtsp://192.168.123.10:8554/live0.264/track2;seq=48850;rtptime=8308401


Started playing session
Receiving streamed data (signal with "kill -HUP 9035" or "kill -USR1 9035" to terminate)...

Ja chci zaznamenavat pouze video, zvuk nepotrebuju. Da se nejak vyresit autodetekce rozlisieni kamery?
Pokud ho nedefinuju, chce to nahravat 240x180@15.
Kód: [Vybrat]
martin@martin:/tmp/camera$ openRTSP -4 "rtsp://:@192.168.123.10:8554/live0.264" > video.mp4
Warning: The -q, -4 or -i option was used, but not -w.  Assuming a video width of 240 pixels
Warning: The -q, -4 or -i option was used, but not -h.  Assuming a video height of 180 pixels
Warning: The -q, -4 or -i option was used, but not -f.  Assuming a video frame rate of 15 frames-per-second
Opening connection to 192.168.123.10, port 8554...

Muzete mi nekdo prosim poradit, jak pomoci openRTSP zaznamenavat video z RTSP streamu a ukladat ho do souboru po 30 minutach (idealne s nastavenim nejakeho prefixu nebo moznosti vkladat do nazvu souboru datum/timestamp)?
Idealne bez zvuku a s automatickou detekci rozliseni a fps.
Jako vystup bych s ohledem na vykon nejradeji kopii puvodniho kodeku, nechci prevod do h.264. Nejlepe pokud to jde ukladat raw stream na 30 minut kusy.

Exituje lepsi program, nez openRTSP? Je lepsi ffmpeg? Mplayer ani vlc pouzit nemuzu, nenarvu je do routeru z OpenWrt.
V OpenWrt mam pouze ffmpeg a openRTSP.

URL rtsp://:@192.168.123.10:8554/live0.264 ve vlc normalne hraje, tady chyba neni.
« Poslední změna: 11. 05. 2014, 21:15:30 od Petr Krčmář »
"Kdo v zájmu bezpečí obětuje část své svobody, v konečném důsledku přijde o svobodu i svou bezpečnost."


Fantomas

Re:Zaznam RTSP streamu z kamery do 30min dlouhych souboru
« Odpověď #1 kdy: 10. 05. 2014, 11:46:20 »
Ja na takove veci pouzivam mencoder, jiny program ti neporadim.

Re:Zaznam RTSP streamu z kamery do 30min dlouhych souboru
« Odpověď #2 kdy: 10. 05. 2014, 16:40:10 »
Ja na takove veci pouzivam mencoder, jiny program ti neporadim.
A muzes mi sem hodit prikaz? Zajimaly by me paratmetry mencoderu pro deleni videa na X minutove useky a tahani z rtsp streamu.
"Kdo v zájmu bezpečí obětuje část své svobody, v konečném důsledku přijde o svobodu i svou bezpečnost."

Fantomas

Re:Zaznam RTSP streamu z kamery do 30min dlouhych souboru
« Odpověď #3 kdy: 11. 05. 2014, 11:00:30 »
Tohle je pro ukladani hodinovych bloku streamu z kompozitniho signalu analogicke karty:
mencoder -o video_file -endpos 60 -tv driver=v4l2 tv://
Vstupni stream, container a kompresi videa si musis upravit podle sebe, navodu na netu je plno, vcetne man mplayer.

Re:RTSP stream do 30min souborů
« Odpověď #4 kdy: 12. 05. 2014, 00:45:36 »
Funkcni reseni s ffmpeg:
Kód: [Vybrat]
$ ffmpeg -i rtsp://:@192.168.123.10:8554/live0.264 -vcodec copy \
-map 0:0 -f segment -segment_time 10 -segment_format mp4 \
"kamera_1_-_`date +"%Y-%m-%d_%H-%M-%S"`_%03d.mp4"

a pada z toho: "kamera_1_-_2014-05-12_00-29-02_001.mp4", "kamera_1_-_2014-05-12_00-29-02_002.mp4", ...
"Kdo v zájmu bezpečí obětuje část své svobody, v konečném důsledku přijde o svobodu i svou bezpečnost."