2,3c2,52 < // macos_ffmpeg_convert.php < // Supervise macOS (via PHP exec) ffmpeg (command line) audio/video conversions --- > // macos_textutil_convert.php > // Supervise macOS (via PHP exec) textutil (command line) conversions > /* > textutil: [command_option] [other_options] file... > Command options are (-help is the default): > -help show this message and exit > -info display information about each file > -convert fmt convert each input file to format (txt, rtf, rtfd, > html, doc, docx, odt, wordml, or webarchive) > -cat fmt concatenate input files into one output file > There are some additional optional arguments: > -extension ext alternate extension for all output files > -output path alternate file name for first output file > -stdin read from stdin instead of files > -stdout send first output file to stdout > -encoding IANA_name|NSStringEncoding > encoding used for plain text or html output files > (default encoding is UTF-8) > -inputencoding IANA_name|NSStringEncoding > encoding used to interpret plain text input files > (by default encoding will be detected from BOM) > -format fmt force input files to be interpreted in this format > -font font specify font used for converting plain to rich text > -fontsize size specify font size for converting plain to rich text > -- specifies that all further arguments are file names > > -noload do not load subsidiary resources for html files > -nostore do not write out subsidiary resources for html files > -baseurl url base URL for subsidiary resources in html files > -timeout t time in seconds to wait for html resources to load > -textsizemultiplier x > factor to apply to font sizes in html files > -excludedelements "(tag1, tag2, ...)" > html elements to exclude from html output files > -prefixspaces n > number of spaces to indent nested html output > > -strip do not copy metadata attributes to output files > -title val title metadata attribute for output files > -author val author metadata attribute for output files > -subject val subject metadata attribute for output files > -keywords "(val1, val2, ...)" > keywords metadata attribute for output files > -comment val comment metadata attribute for output files > -editor val last editor metadata attribute for output files > -company val company metadata attribute for output files > -creationtime yyyy-mm-ddThh:mm:ssZ > creation time metadata attribute for output files > -modificationtime yyyy-mm-ddThh:mm:ssZ > modification time metadata attribute for output files > */ 12,18c61,63 < $verb="ffmpeg"; < $switchone="-i"; < $switchtwo=""; < < if (file_exists("/usr/local/bin/ffmpeg")) { < $verb="/usr/local/bin/ffmpeg"; < } --- > $verb="textutil"; > $switchone="-convert"; > $switchtwo="-output"; 24,25c69 < $title="Audio/Video Conversions via ffmpeg"; < $avtypes=""; --- > $title="Document Conversions via pandoc or textutil"; 27,40d70 < $types = ["audio/x-m4r","audio/wav","audio/x-wav","audio/x-pn-realaudio","audio/x-mpegurl","audio/x-aiff","audio/mpeg","audio/mid", < "audio/basic","audio/ogg","video/x-sgi-movie","video/x-msvideo","video/quicktime","audio/mp3","video/mp4","video/mpeg", < "video/x-la-asf","video/ogg","video/webm","audio/mp4", "image/jpeg", "image/jpeg", "image/png", "image/gif", "image/bmp", "image/tif", < "text/html", "text/html", "text/html", "text/javascript", "text/css", "text/plain", "text/xml", "text/csv", < "application/vnd.ms-word", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/x-php", "application/pdf", < "application/vnd.openxmlformats-officedocument.presentationml.presentation", "application/vnd.ms-powerpoint", < "application/vnd.ms-excel", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"]; < $exts = [".m4r",".wav",".wav",".ram",".m3u",".aiff",".mp3",".rmi", < ".snd",".ogg",".movie",".avi",".mov",".mp3",".m4v",".mpeg", < ".lsx",".ogv",".webm",".m4a", ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tif", < ".htm", ".html", ".htmls", ".js", ".css", ".txt", ".xml", ".csv", < ".doc", ".docx", ".php", ".pdf", < ".pptx", ".ppt", < ".xls", ".xlsx"]; 41a72,90 > if ( !file_exists( "/usr/local/bin" ) && !is_dir( "/usr/local/bin" ) ) { > if (get_env("USERPROFILE")) { > if (file_exists(get_env("USERPROFILE") . "\\AppData\\Local\\Pandoc\\pandoc.exe")) { > $verb=get_env("USERPROFILE") . "\\AppData\\Local\\Pandoc\\pandoc.exe"; > $switchone="-t"; > $switchtwo="-o"; > $panplus="pandoc or "; > } > } > } else { > //exec("which pandoc > lookup_pandoc.txt 2>>&1"); > //shell_exec("/usr/local/bin/pandoc --version > lookup_pandoc.txt 2>&1"); > if (file_exists("/usr/local/bin/pandoc")) { > $verb="/usr/local/bin/pandoc"; > $switchone="-t"; > $switchtwo="-o"; > $panplus="pandoc or "; > } > } 47c96 < echo '$ Input path ( eg. we will take blank to mean ' . dirname(__FILE__) . DIRECTORY_SEPARATOR . ' ) then Audio/Video Input File(spec) then Output path ( eg. we will take blank to mean ' . dirname(__FILE__) . DIRECTORY_SEPARATOR . ' ) then Audio/Video Output File Extension below ...' . "\n"; --- > echo '$ Input path ( eg. we will take blank to mean ' . dirname(__FILE__) . DIRECTORY_SEPARATOR . ' ) then *.pdf,*.doc,*.docx,*.htm,*.html,*.txt Input File(spec) then Output path ( eg. we will take blank to mean ' . dirname(__FILE__) . DIRECTORY_SEPARATOR . ' ) then .pdf,.doc,.docx,.htm,.html,.txt Output File Extension below ...' . "\n"; 56c105 < $line = readline('$ Input path ( eg. we will take blank to mean ' . dirname(__FILE__) . DIRECTORY_SEPARATOR . ' ) then Audio/Video Input File(spec) then Output path ( eg. we will take blank to mean ' . dirname(__FILE__) . DIRECTORY_SEPARATOR . ' ) thenAudio/Video Output File Extension below ...' . "\n"); --- > $line = readline('$ Input path ( eg. we will take blank to mean ' . dirname(__FILE__) . DIRECTORY_SEPARATOR . ' ) then *.pdf,*.doc,*.docx,*.htm,*.html,*.txt Input File(spec) then Output path ( eg. we will take blank to mean ' . dirname(__FILE__) . DIRECTORY_SEPARATOR . ' ) then .pdf,.doc,.docx,.htm,.html,.txt Output File Extension below ...' . "\n"); 64a114,122 > if ($verb != "textutil" && explode(".",$outlineinspec)[-1 + sizeof(explode(".",$outlineinspec))] == "pdf") { > if (file_exists("/Library/TeX/Root/bin/x86_64-darwin/pdflatex")) { > $cmdsuff=" --pdf-engine=/Library/TeX/Root/bin/x86_64-darwin/pdflatex"; > } else if (file_exists("/Library/TeX/texbin/pdflatex")) { > $cmdsuff=" --pdf-engine=/Library/TeX/texbin/pdflatex"; > } else { > $cmdsuff=" --pdf-engine=pdflatex"; > } > } 94,99c152,156 < //echo ($verb . " " . $switchone . " " . $filename . " " . $switchtwo . " " . $outnameis . $cmdsuff . " > macos_ffmpeg_convert.out 2> macos_ffmpeg_convert.err"); < echo ($verb . " " . $switchone . " " . $filename . " " . $switchtwo . " " . $outnameis . $cmdsuff . " > macos_ffmpeg_convert.out 2> macos_ffmpeg_convert.err \n"); < exec($verb . " " . $switchone . " " . $filename . " " . $switchtwo . " " . $outnameis . $cmdsuff . " > macos_ffmpeg_convert.out 2> macos_ffmpeg_convert.err; cat macos_ffmpeg_convert.err"); < //passthru($verb . " " . $switchone . " " . $filename . " " . $switchtwo . " " . $outnameis . $cmdsuff . " > macos_ffmpeg_convert.out 2> macos_ffmpeg_convert.err"); < if (file_exists("macos_ffmpeg_convert.out") && file_exists("macos_ffmpeg_convert.err")) { < if (7 == 6 && filesize("macos_ffmpeg_convert.out") == 0 && filesize("macos_ffmpeg_convert.err") != 0) { --- > //echo ($verb . " " . $switchone . " " . $filename . " " . $switchtwo . " " . $outnameis . $cmdsuff . " > macos_textutil_convert.out 2> macos_textutil_convert.err"); > echo ($verb . " " . $switchone . " " . str_replace(".", "", $outlineinspec) . " " . $filename . " " . $switchtwo . " " . $outnameis . $cmdsuff . " > macos_textutil_convert.out 2> macos_textutil_convert.err \n"); > exec($verb . " " . $switchone . " " . str_replace(".", "", $outlineinspec) . " " . $filename . " " . $switchtwo . " " . $outnameis . $cmdsuff . " > macos_textutil_convert.out 2> macos_textutil_convert.err"); > if (file_exists("macos_textutil_convert.out") && file_exists("macos_textutil_convert.err")) { > if (filesize("macos_textutil_convert.out") == 0 && filesize("macos_textutil_convert.err") != 0) { 104c161 < echo "\n\n" . file_get_contents("macos_ffmpeg_convert.err") . "\n\n"; --- > echo "\n\n" . file_get_contents("macos_textutil_convert.err") . "\n\n"; 131a189,197 > if ($verb != "textutil" && explode(".",$outlineinspec)[-1 + sizeof(explode(".",$outlineinspec))] == "pdf") { > if (file_exists("/Library/TeX/Root/bin/x86_64-darwin/pdflatex")) { > $cmdsuff=" --pdf-engine=/Library/TeX/Root/bin/x86_64-darwin/pdflatex"; > } else if (file_exists("/Library/TeX/texbin/pdflatex")) { > $cmdsuff=" --pdf-engine=/Library/TeX/texbin/pdflatex"; > } else { > $cmdsuff=" --pdf-engine=pdflatex"; > } > } 148,153c214,218 < //echo ($verb . " " . $switchone . " " . $filename . " " . $switchtwo . " " . $outnameis . $cmdsuff . " > macos_ffmpeg_convert.out 2> macos_ffmpeg_convert.err"); < echo ($verb . " " . $switchone . " " . $filename . " " . $switchtwo . " " . $outnameis . $cmdsuff . " > macos_ffmpeg_convert.out 2> macos_ffmpeg_convert.err \n"); < exec($verb . " " . $switchone . " " . $filename . " " . $switchtwo . " " . $outnameis . $cmdsuff . " > macos_ffmpeg_convert.out 2> macos_ffmpeg_convert.err; cat macos_ffmpeg_convert.err"); < //passthru($verb . " " . $switchone . " " . $filename . " " . $switchtwo . " " . $outnameis . $cmdsuff . " > macos_ffmpeg_convert.out 2> macos_ffmpeg_convert.err"); < if (file_exists("macos_ffmpeg_convert.out") && file_exists("macos_ffmpeg_convert.err")) { < if (8 == 9 && filesize("macos_ffmpeg_convert.out") == 0 && filesize("macos_ffmpeg_convert.err") != 0) { --- > //echo ($verb . " " . $switchone . " " . $filename . " " . $switchtwo . " " . $outnameis . $cmdsuff . " > macos_textutil_convert.out 2> macos_textutil_convert.err"); > echo ($verb . " " . $switchone . " " . str_replace(".", "", $outlineinspec) . " " . $filename . " " . $switchtwo . " " . $outnameis . $cmdsuff . " > macos_textutil_convert.out 2> macos_textutil_convert.err \n"); > exec($verb . " " . $switchone . " " . str_replace(".", "", $outlineinspec) . " " . $filename . " " . $switchtwo . " " . $outnameis . $cmdsuff . " > macos_textutil_convert.out 2> macos_textutil_convert.err"); > if (file_exists("macos_textutil_convert.out") && file_exists("macos_textutil_convert.err")) { > if (filesize("macos_textutil_convert.out") == 0 && filesize("macos_textutil_convert.err") != 0) { 158c223 < echo "\n\n" . file_get_contents("macos_ffmpeg_convert.err") . "\n\n"; --- > echo "\n\n" . file_get_contents("macos_textutil_convert.err") . "\n\n"; 215c280 < $accfoutext=".m4v"; --- > $accfoutext=".html"; 233,240d297 < < for ($iav=0; $iavConvert to " . strtoupper(substr($types[$iav],0,1)) . str_replace("/"," ",substr($types[$iav],1)) . ""; < } < } < } 286c343 < echo "'; --- > echo "'; 306,307c363 < //if (PHP_OS == "Darwin" || $verb != "textutil" || isset($_GET['emailanyway'])) { < if (PHP_OS == "Darwin" || isset($_GET['emailanyway'])) { --- > if (PHP_OS == "Darwin" || $verb != "textutil" || isset($_GET['emailanyway'])) { 322,346c378,388 < //echo ($verb . " " . $switchone . " " . ourstr_replace("+"," ",$thewords) . " " . $filename . " " . $switchtwo . " " . $outnameis . $cmdsuff . " > macos_ffmpeg_convert.out 2> macos_ffmpeg_convert.err \n"); < exec($verb . " " . $switchone . " " . ourstr_replace("+"," ",$thewords) . " " . $switchtwo . " " . yourstr_replace("+"," ",urldecode($_GET['outputname'])) . $cmdsuff . " > macos_ffmpeg_convert.out 2> macos_ffmpeg_convert.err; cat macos_ffmpeg_convert.err"); < //passthru($verb . " " . $switchone . " " . ourstr_replace("+"," ",$thewords) . " " . $switchtwo . " " . yourstr_replace("+"," ",urldecode($_GET['outputname'])) . $cmdsuff . " > macos_ffmpeg_convert.out 2> macos_ffmpeg_convert.err"); < < < $thecontent=""; < $mimetypeis=""; < for ($jia=0; $jia

" . ourstr_replace("+"," ",$thewords) . " to " . yourstr_replace("+"," ",urldecode($_GET['outputname'])) . " via ffmpeg ...

<" . explode("/",$mimetypeis)[0] . " controls>"; < } < < if ($thecontent != "") { < echo $thecontent; < exit; < } < < < < < if (7 == 7 || explode(".",yourstr_replace("+"," ",urldecode($_GET['outputname'])))[-1 + sizeof(explode(".",yourstr_replace("+"," ",urldecode($_GET['outputname']))))] == "pdf") { --- > if ($verb != "textutil" && explode(".",yourstr_replace("+"," ",urldecode($_GET['outputname'])))[-1 + sizeof(explode(".",yourstr_replace("+"," ",urldecode($_GET['outputname']))))] == "pdf") { > if (file_exists("/Library/TeX/Root/bin/x86_64-darwin/pdflatex")) { > $cmdsuff=" --pdf-engine=/Library/TeX/Root/bin/x86_64-darwin/pdflatex"; > } else if (file_exists("/Library/TeX/texbin/pdflatex")) { > $cmdsuff=" --pdf-engine=/Library/TeX/texbin/pdflatex"; > } else { > $cmdsuff=" --pdf-engine=pdflatex"; > } > } > exec($verb . " " . $switchone . " " . explode(".",yourstr_replace("+"," ",urldecode($_GET['outputname'])))[-1 + sizeof(explode(".",yourstr_replace("+"," ",urldecode($_GET['outputname']))))] . " " . ourstr_replace("+"," ",$thewords) . " " . $switchtwo . " " . yourstr_replace("+"," ",urldecode($_GET['outputname'])) . $cmdsuff . " > macos_textutil_convert.out 2> macos_textutil_convert.err"); > if (explode(".",yourstr_replace("+"," ",urldecode($_GET['outputname'])))[-1 + sizeof(explode(".",yourstr_replace("+"," ",urldecode($_GET['outputname']))))] == "pdf") { 392,394c434,436 < if (file_exists("macos_ffmpeg_convert.out") && file_exists("macos_ffmpeg_convert.err")) { < if (filesize("macos_ffmpeg_convert.out") == 0 && filesize("macos_ffmpeg_convert.err") != 0) { < if (6 == 7 && $rone != "" && $rtwo != "") { --- > if (file_exists("macos_textutil_convert.out") && file_exists("macos_textutil_convert.err")) { > if (filesize("macos_textutil_convert.out") == 0 && filesize("macos_textutil_convert.err") != 0) { > if ($rone != "" && $rtwo != "") { 403c445 < echo "

" . file_get_contents("macos_ffmpeg_convert.err") . "

"; --- > echo "

" . file_get_contents("macos_textutil_convert.err") . "

"; 438,462c480,490 < exec($verb . " " . $switchone . " " . ourstr_replace("+"," ",$thewords) . " " . $switchtwo . " " . yourstr_replace("+"," ",urldecode($_POST['outputname'])) . $cmdsuff . " > macos_ffmpeg_convert.out 2> macos_ffmpeg_convert.err; cat macos_ffmpeg_convert.err"); < //passthru($verb . " " . $switchone . " " . ourstr_replace("+"," ",$thewords) . " " . $switchtwo . " " . yourstr_replace("+"," ",urldecode($_POST['outputname'])) . $cmdsuff . " > macos_ffmpeg_convert.out 2> macos_ffmpeg_convert.err"); < < < < $thecontent=""; < $mimetypeis=""; < for ($jia=0; $jia

" . ourstr_replace("+"," ",$thewords) . " to " . yourstr_replace("+"," ",urldecode($_POST['outputname'])) . " via ffmpeg ...

<" . explode("/",$mimetypeis)[0] . " controls>"; < } < < if ($thecontent != "") { < echo $thecontent; < exit; < } < < < < < if (9 == 9 || explode(".",yourstr_replace("+"," ",urldecode($_POST['outputname'])))[-1 + sizeof(explode(".",yourstr_replace("+"," ",urldecode($_POST['outputname']))))] == "pdf") { --- > if ($verb != "textutil" && explode(".",yourstr_replace("+"," ",urldecode($_POST['outputname'])))[-1 + sizeof(explode(".",yourstr_replace("+"," ",urldecode($_POST['outputname']))))] == "pdf") { > if (file_exists("/Library/TeX/Root/bin/x86_64-darwin/pdflatex")) { > $cmdsuff=" --pdf-engine=/Library/TeX/Root/bin/x86_64-darwin/pdflatex"; > } else if (file_exists("/Library/TeX/texbin/pdflatex")) { > $cmdsuff=" --pdf-engine=/Library/TeX/texbin/pdflatex"; > } else { > $cmdsuff=" --pdf-engine=pdflatex"; > } > } > exec($verb . " " . $switchone . " " . explode(".",yourstr_replace("+"," ",urldecode($_POST['outputname'])))[-1 + sizeof(explode(".",yourstr_replace("+"," ",urldecode($_POST['outputname']))))] . " " . ourstr_replace("+"," ",$thewords) . " " . $switchtwo . " " . yourstr_replace("+"," ",urldecode($_POST['outputname'])) . $cmdsuff . " > macos_textutil_convert.out 2> macos_textutil_convert.err"); > if (explode(".",yourstr_replace("+"," ",urldecode($_POST['outputname'])))[-1 + sizeof(explode(".",yourstr_replace("+"," ",urldecode($_POST['outputname']))))] == "pdf") { 508,509c536,537 < if (file_exists("macos_ffmpeg_convert.out") && file_exists("macos_ffmpeg_convert.err")) { < if (3 == 6 && filesize("macos_ffmpeg_convert.out") == 0 && filesize("macos_ffmpeg_convert.err") != 0) { --- > if (file_exists("macos_textutil_convert.out") && file_exists("macos_textutil_convert.err")) { > if (filesize("macos_textutil_convert.out") == 0 && filesize("macos_textutil_convert.err") != 0) { 513c541 < echo "

" . file_get_contents("macos_ffmpeg_convert.err") . "

"; --- > echo "

" . file_get_contents("macos_textutil_convert.err") . "

"; 523,528d550 < $mimetypeis=""; < for ($jia=0; $jiaffmpeg ...<" . explode("/",$mimetypeis)[0] . " controls>"; --- > if (strtolower("~" . $extis, "~htm") !== false) { > $thecontent=file_get_contents(str_replace("+"," ",urldecode($_GET['outputname']))); 576,582d597 < < $mimetypeis=""; < for ($jia=0; $jiaffmpeg ...<" . explode("/",$mimetypeis)[0] . " controls>"; --- > if (strtolower("~" . $extis, "~htm") !== false) { > $thecontent=file_get_contents(str_replace("+"," ",urldecode($_POST['outputname']))); 634c649 < var lastvalue='.m4v'; --- > var lastvalue='.html'; 646d660 < if (1 == 4) { 648d661 < } 653c666 < if (document.getElementById('resultav').value == '') { --- > if (document.getElementById('resultout').value == '') { 662c675 < newwo.document.write(document.getElementById('resultav').value); --- > newwo.document.write(document.getElementById('resultout').value); 673,676d685 < if (thisvalue.indexOf('/') != -1) { < document.getElementById('outputname').value=document.getElementById('outputname').value.replace(/\.\*/g,'.' + thisvalue.split('/')[1]); < lastvalue='.' + thisvalue.split('/')[1]; < } else { 679,680c688 < } < document.getElementById('cbi').src=document.getElementById('cbi').src.split('#')[0].split('?')[0] + '?totype=' + encodeURIComponent(thisvalue.replace('*','m4v')) + '&d=' + Math.floor(Math.random() * 19876543); --- > document.getElementById('cbi').src=document.getElementById('cbi').src.split('#')[0].split('?')[0] + '?totype=' + encodeURIComponent(thisvalue.replace('*','html')) + '&d=' + Math.floor(Math.random() * 19876543); 698c706 < document.getElementById('globit').src=document.URL.split('#')[0].split('?')[0] + '?globit=' + encodeURIComponent(tv) + '&globpath=' + encodeURIComponent(document.getElementById('path').value) + '&globext=' + encodeURIComponent(document.getElementById('cto').value.replace('*','m4v')); --- > document.getElementById('globit').src=document.URL.split('#')[0].split('?')[0] + '?globit=' + encodeURIComponent(tv) + '&globpath=' + encodeURIComponent(document.getElementById('path').value) + '&globext=' + encodeURIComponent(document.getElementById('cto').value.replace('*','html')); 700c708 < document.getElementById('outputname').value=tv.split('.')[0] + '.' + document.getElementById('cto').value.replace('*','m4v').replace('.',''); --- > document.getElementById('outputname').value=tv.split('.')[0] + '.' + document.getElementById('cto').value.replace('*','html').replace('.',''); 723c731 <

Supervise ffmpeg Audio/Video Conversions

--- >

Supervise " . $panplus . "textutil Document Conversions

726c734 <
--- > 728,731c736,749 < Input Audio/Video File(s)   <

" . $thecontent . "
--- > Input Document File(s)   >

" . str_replace("\n","
",$thecontent) . "
734c752 < --- > 744c762 < echo "Email off your Audio/Video Conversion Attachment Input Files for Your Inhouse Audio/Video Converter to Listen For and Convert

This PHP web application only works with ffmpeg. Perhaps consider getting a local Apache/PHP/MySql web server such as MAMP or you have an email listener and will Email and Download to that emailee to do the conversions

"; --- > echo "Email off your Document Conversion Attachment Input Files for Your Inhouse Document Converter to Listen For and Convert

This PHP web application only works with macOS and its textutil -convert [outextension] [infilename] -output [outfilename] command line Document Conversion functionality, or install pandoc (for Windows). Perhaps consider getting a local Apache/PHP/MySql web server such as MAMP or you have an email listener and will Email and Download to that emailee to do the conversions

";