
{"id":697,"date":"2023-12-26T21:46:00","date_gmt":"2023-12-26T20:46:00","guid":{"rendered":"https:\/\/tty.tartux.net\/?p=697"},"modified":"2023-12-26T21:46:00","modified_gmt":"2023-12-26T20:46:00","slug":"script-de-decalage-des-sous-titres-dans-un-fichier-srt","status":"publish","type":"post","link":"https:\/\/tty.tartux.net\/?p=697","title":{"rendered":"Script de d\u00e9calage des sous-titres dans un fichier srt"},"content":{"rendered":"<blockquote><p>#! \/bin\/bash<\/p>\n<p>IFS=$'\\n'<br \/>\noption_F_found=0<br \/>\noption_T_found=0<\/p>\n<p>usage()<br \/>\n{<br \/>\necho \"usage: .\/subtitles.sh -f [srt file] -t '[+\/- time]'\"<br \/>\necho \"ex : .\/subtitles.sh -f \/home\/std\/lecuisinierlevoleursafemmeetsonamant.srt -t '- 18.100'\"<br \/>\necho \"ex : .\/subtitles.sh -f \/home\/std\/lecuisinierlevoleursafemmeetsonamant.srt -t '+ 18.100'\"<br \/>\necho \"\"<br \/>\nexit 3<br \/>\n}<\/p>\n<p>while getopts f:t: OPTNAME; do<br \/>\ncase \"$OPTNAME\" in<br \/>\nf)<br \/>\nFILE=\"$OPTARG\"<br \/>\noption_F_found=1<br \/>\n;;<\/p>\n<p>t)<br \/>\nTIME=\"$OPTARG\"<br \/>\noption_T_found=1<br \/>\n;;<\/p>\n<p>*)<br \/>\nusage<br \/>\n;;<br \/>\nesac<br \/>\ndone<\/p>\n<p>if [ \"$option_F_found\" -eq \"0\" ] || [ \"$option_T_found\" -eq \"0\" ]; then<br \/>\nusage<br \/>\nfi<\/p>\n<p>FunctionDuration()<br \/>\n{<br \/>\nduration_temp=$(date -d \"1983-12-12 $1\" \"+%s.%3N\")<br \/>\nduration_diff=$(echo \"scale=3; $duration_temp $TIME\" | bc -l)<br \/>\nduration_dest=$(date -d\"@$duration_diff\" \"+%H:%M:%S,%3N\")<br \/>\necho \"$duration_dest\"<br \/>\n}<\/p>\n<p>for i in $(grep -E \"[0-9]{2}:[0-9]{2}\\,[0-9]{3}\" \"$FILE\");<br \/>\ndo<br \/>\nA=$(echo \"$i\" | sed 's\/\\([0-9]\\{2\\}:[0-9]\\{2\\}:[0-9]\\{2\\}\\,[0-9]\\{3\\}\\) --&gt; \\([0-9]\\{2\\}:[0-9]\\{2\\}:[0-9]\\{2\\}\\,[0-9]\\{3\\}\\)\/\\1\/')<br \/>\nB=$(echo \"$i\" | sed 's\/\\([0-9]\\{2\\}:[0-9]\\{2\\}:[0-9]\\{2\\}\\,[0-9]\\{3\\}\\) --&gt; \\([0-9]\\{2\\}:[0-9]\\{2\\}:[0-9]\\{2\\}\\,[0-9]\\{3\\}\\)\/\\2\/')<br \/>\nVAL1=$(FunctionDuration \"$A\")<br \/>\nVAL2=$(FunctionDuration \"$B\")<br \/>\necho \"working on $A --&gt; $B\"<br \/>\nsed -i \"s\/$i\/$VAL1 --&gt; $VAL2\/\" \"$FILE\"<br \/>\ndone<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>#! \/bin\/bash IFS=$'\\n' option_F_found=0 option_T_found=0 usage() { echo \"usage: .\/subtitles.sh -f [srt file] -t '[+\/- time]'\" echo \"ex : .\/subtitles.sh -f \/home\/std\/lecuisinierlevoleursafemmeetsonamant.srt -t '- 18.100'\" echo \"ex : .\/subtitles.sh -f \/home\/std\/lecuisinierlevoleursafemmeetsonamant.srt -t '+ 18.100'\" echo \"\" exit 3 } while getopts f:t: OPTNAME; do case \"$OPTNAME\" in f) FILE=\"$OPTARG\" option_F_found=1 ;; t) TIME=\"$OPTARG\" option_T_found=1 ;; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[137],"class_list":["post-697","post","type-post","status-publish","format-standard","hentry","category-script","tag-video"],"_links":{"self":[{"href":"https:\/\/tty.tartux.net\/index.php?rest_route=\/wp\/v2\/posts\/697","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tty.tartux.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tty.tartux.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tty.tartux.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tty.tartux.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=697"}],"version-history":[{"count":1,"href":"https:\/\/tty.tartux.net\/index.php?rest_route=\/wp\/v2\/posts\/697\/revisions"}],"predecessor-version":[{"id":698,"href":"https:\/\/tty.tartux.net\/index.php?rest_route=\/wp\/v2\/posts\/697\/revisions\/698"}],"wp:attachment":[{"href":"https:\/\/tty.tartux.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=697"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tty.tartux.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=697"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tty.tartux.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=697"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}