{"id":1039,"date":"2019-11-17T17:38:40","date_gmt":"2019-11-18T02:38:40","guid":{"rendered":"\/blog\/?p=1039"},"modified":"2023-09-21T09:26:46","modified_gmt":"2023-09-21T00:26:46","slug":"ffmpeg-rtsp-%eb%a0%88%ec%bd%94%eb%94%a9-%ec%8a%a4%ed%81%ac%eb%a6%bd%ed%8a%b8","status":"publish","type":"post","link":"https:\/\/hasu0707.duckdns.org\/blog\/?p=1039","title":{"rendered":"ffmpeg RTSP \ub808\ucf54\ub529 \uc2a4\ud06c\ub9bd\ud2b8"},"content":{"rendered":"\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#!\/bin\/bash\n############################################################\n#\n# ffmpeg RTSP \uc2a4\ud2b8\ub9ac\ubc0d \ub808\ucf54\ub529 \uc2a4\ud06c\ub9bd\ud2b8\n#\n# crontab -e\n# *\/10 0-5 * * * \/home\/armbian\/scripts\/ffmpeg_rtsp_record.sh\n#\n############################################################\nRECORD_DIR=\"\/st4000dm004\/cctv\/rtsp\"\nCAMERA_MODEL=\"es200k\"\n\n# RTSP \uc8fc\uc18c \uc815\ubcf4\nRTSP_ID=\"admin\"\nRTSP_PW='&lt;mypasswd>'\nRTSP_URL=\"rtsp:\/\/${RTSP_ID}:${RTSP_PW}@192.168.1.51:554\/11\"\n\n# mp4 \ud30c\uc77c\ub2f9 \uba87\ucd08\uc758 \ub179\ud654\uc2dc\uac04\uc744 \uae30\ub85d\ud560 \uac83\uc778\uac00\nSEGMENT_SEC=1800\n\nmkdir -p ${RECORD_DIR} > \/dev\/null\n\nif ! pgrep -x \"ffmpeg\" > \/dev\/null\nthen\n  ffmpeg -i ${RTSP_URL} -vcodec copy -c:a aac -f segment -segment_time ${SEGMENT_SEC} -reset_timestamps 1 -strftime 1 -map 0 \"${RECORD_DIR}\/%Y%m%d-%H%M%S_${CAMERA_MODEL}.mp4\"\nfi<\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#!\/bin\/bash\n############################################################\n#\n# openRTSP\ub97c \uc8fd\uc778\ub2e4.\n#\n# crontab -e\n# *\/30 6-23 * * * \/home\/armbian\/scripts\/ffmpeg_rtsp_kill.sh\n#\n############################################################\nRECORD_DIR=\"\/st4000dm004\/cctv\/rtsp\"\n\n# 2\uc77c\uc774 \uc9c0\ub09c \uc790\ub8cc\ub294 \uc0ad\uc81c\nOLDDATA_EXP_MIN=+2880\n\nif pgrep -x \"ffmpeg\" > \/dev\/null\nthen\n  killall -SIGINT ffmpeg\n  sleep 2\n\n  # $OLDDATA_EXP_MIN \ubcf4\ub2e4 \uc624\ub798\ub41c \ub3d9\uc601\uc0c1 \ud30c\uc77c\uc740 \uc0ad\uc81c\n  find ${RECORD_DIR} -mmin ${OLDDATA_EXP_MIN} -name \"*.mp4\" -type f -exec rm -f {} \\;\n\n  # 6Mb\ubcf4\ub2e4 \uc791\uc740 \ub3d9\uc601\uc0c1 \ud30c\uc77c\uc740 \uc0ad\uc81c\n  find ${RECORD_DIR} -size -6M -name \"*.mp4\" -type f -exec rm -f {} \\;\nfi\n\nsync<\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[11],"tags":[],"class_list":["post-1039","post","type-post","status-publish","format-standard","hentry","category-computing_network"],"_links":{"self":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1039","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1039"}],"version-history":[{"count":0,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1039\/revisions"}],"wp:attachment":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1039"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1039"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1039"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}