Programming Thread

Started by the-pi-guy, Mar 13, 2016, 10:39 PM

0 Members and 6 Guests are viewing this topic.

the-pi-guy

I'm making a local web application to do some server management.

The minimum would some custom file management. Being able to batch rename files would be convenient.

It'd be kind of useful to have a local webpage that would tell me what the computer is doing. That'd probably be a lot more involved though.  

Legend

Sounds fun

I've used web pages for a bunch of things and sometimes they work great. Other times I've disliked them and switched to a custom app.

the-pi-guy

Making a powershell script to batch deinterlace files.

Need to add this in later.

# Define the path to the MKV file
$inputFile = "path\to\your\file.mkv"

# Run ffmpeg to analyze the file
$ffmpegOutput = & ffmpeg -i $inputFile -vf idet -frames:v 500 -an -f rawvideo -y NUL 2>&1

# Check the output for interlaced frames
if ($ffmpegOutput -match "Multi frame detection: TFF:") {
    Write-Output "The file is interlaced (Top Field First)."
} elseif ($ffmpegOutput -match "Multi frame detection: BFF:") {
    Write-Output "The file is interlaced (Bottom Field First)."
} else {
    Write-Output "The file is progressive."
}

Legend

Wow you are much better at putting comments in your own code than I am.

the-pi-guy

Quote from: Legend on Oct 11, 2024, 04:58 PMWow you are much better at putting comments in your own code than I am.
Ah yes, me and my code...  

It's actually copilot's code. I need to add it to my own code later

Legend

Quote from: the-Pi-guy on Oct 11, 2024, 05:41 PMAh yes, me and my code...  

It's actually copilot's code. I need to add it to my own code later
Copilot is you now. Embrace ai.

I've kinda integrated ai into my workflow, just as a google replacement. Like stack overflow you nevery copy and paste but it might still solve your problem.

the-pi-guy

Spoiler for Hidden:
$ffmpegDirectory = &#39;C:\path&#39;;<br><br>function New-DirectoryIfNotExists {<br>&nbsp; &nbsp;param (<br>&nbsp; &nbsp; &nbsp; &nbsp;[string]$Path<br>&nbsp; &nbsp;)<br>&nbsp; &nbsp;if (-Not (Test-Path -Path $Path)) {<br>&nbsp; &nbsp; &nbsp; &nbsp;New-Item -ItemType Directory -Path $Path<br>&nbsp; &nbsp; &nbsp; &nbsp;Write-Output &quot;Directory created: $Path&quot;<br>&nbsp; &nbsp;} else {<br>&nbsp; &nbsp; &nbsp; &nbsp;Write-Output &quot;Directory already exists: $Path&quot;<br>&nbsp; &nbsp;}<br>}<br><br>function Get-Interlaced {<br>param(<br>[string]$InputFile<br>)<br>$ffmpeg = &quot;$ffmpegDirectory\ffmpeg.exe&quot;<br>$ffmpegOutput = &amp; &quot;$ffmpeg -i $file -vf idet -frames:v 500 -an -f rawvideo -y NUL 2&gt;&amp;1&quot;<br>$interlaced = $false<br>if ($ffmpegOutput -match &quot;Multi frame detection: TFF:&quot;) {<br>Write-Output &quot;The file is interlaced (Top Field First).&quot;<br>$interlaced = $true<br>} elseif ($ffmpegOutput -match &quot;Multi frame detection: BFF:&quot;) {<br>Write-Output &quot;The file is interlaced (Bottom Field First).&quot;<br>$interlaced = $true<br>}<br>return $interlaced<br><br>}<br><br>function Deinterlace-Video {<br>&nbsp; &nbsp;param (<br>&nbsp; &nbsp; &nbsp; &nbsp;[string]$InputFilePath,<br>&nbsp; &nbsp; &nbsp; &nbsp;[string]$OutputFilePath,<br>[string]$Deinterlacer<br>&nbsp; &nbsp;)<br><br>if (-Not (Test-Path -Path $InputFilePath)) {<br>Write-Output &quot;Input file does not exist: $InputFilePath&quot;<br>exit<br>}<br><br>$ArgumentList = &#39;-i &quot;{0}&quot; -c:v libx264 -vf {1},format=yuv420p -preset veryslow -crf 18 -an &quot;{2}&quot;&#39; -f &quot;$InputFilePath&quot;, $Deinterlacer, &quot;$OutputFilePath&quot;;<br>if($Deinterlacer -eq &quot;nnedi&quot;){<br>#$ArgumentList = &#39;-i &quot;{0}&quot; -vf &quot;nnedi=&#39;&#39;{1}&#39;&#39;&quot; -c:v libx264 -preset slow -crf 19 -c:a aac -b:a 256k -hide_banner -loglevel error &quot;{2}&quot;&#39; -f &quot;$InputDirectory\$file&quot;, &quot;C:\\Users\\User\\Documents\\FFmpeg\\nnedi3_weights.bin&quot; ,&quot;$OutputDirectory\$file&quot;<br>$ArgumentList = &#39;-i &quot;{0}&quot; -vf &quot;nnedi=weights=&#39;&#39;C\:\\Users\\User\\Documents\\FFmpeg\\nnedi3_weights.bin&#39;&#39;&quot; &quot;{1}&quot;&#39; -f &quot;$InputFilePath&quot;, &quot;$OutputFilePath&quot;<br>}<br>Write-Host $ArgumentList<br>Start-Process -FilePath &quot;$ffmpegDirectory\ffmpeg.exe&quot; -ArgumentList $ArgumentList -Wait -NoNewWindow;<br>}<br><br>function Detelecine-Video {<br><br>param (<br>&nbsp; &nbsp;[string]$InputFilePath,<br>&nbsp; &nbsp;[string]$OutputFilePath<br>)<br><br>if (-Not (Test-Path -Path $InputFilePath)) {<br>Write-Output &quot;Input file does not exist: $InputFilePath&quot;<br>exit<br>}<br><br>$ffmpegPath = &quot;$ffmpegDirectory\ffmpeg.exe&quot; <br><br>$arguments = &quot;-i `&quot;$InputFilePath`&quot; -vf detelecine `&quot;$OutputFilePath`&quot;&quot;<br>&amp; $ffmpegPath $arguments<br><br>if ($LASTEXITCODE -eq 0) {<br>Write-Output &quot;Detelecine completed successfully. Output file: $OutputFilePath&quot;<br>} else {<br>Write-Output &quot;Detelecine failed.&quot;<br>} <br>}<br><br>function Get-VideoOptions {<br>Write-Output &quot;1: Deinterlacer - yadif (fast)&quot;<br>Write-Output &quot;2: Deinterlacer - bwdif (slow)&quot;<br>Write-Output &quot;3: Deinterlacer - nnedi - (slowest)&quot;<br>Write-Output &quot;4: Detelecine&quot;<br>$selection = Read-Host &quot;Specify Option&quot;<br>$result = &quot;&quot;<br>switch($selection){<br><br>1 {$result = &quot;yadif&quot;}<br>2 {$result = &quot;bwdif&quot;}<br>3 {$result = &quot;nnedi&quot;}<br>4 {$result = &quot;detelecine&quot;}<br>}<br><br>}<br><br><br><br><br>#Get Input<br>$InputDirectory = Read-Host &quot;Specify Input Directory&quot;<br>if(!(test-path -PathType container $InputDirectory)){<br>Write-Host &quot;No such directory&quot;<br>Exit(1)<br>}<br><br><br>$AllFiles = Get-ChildItem -Path $InputDirectory -File<br><br>$OutputDirectory = Read-Host &quot;Specify Output Directory&quot;<br><br>New-DirectoryIfNotExists -Path $OutputDirectory<br><br><br><br>#$deinterlacer = &quot;yadif&quot; #fast<br>#$deinterlacer = &quot;bwdif&quot; #slow<br>$deinterlacer = &quot;nnedi&quot; #slowest<br>foreach ($file in $AllFiles)<br>{<br>Write-Host $file<br>if(Get-Interlaced -InputFile $file ){<br>Deinterlace-Video -InputFilePath &quot;$InputDirectory\$file&quot; -OutputFilePath &quot;$OutputDirectory\$file&quot; -Deinterlacer $deinterlacer <br>}<br>}<br><br>

Legend

It's funny how chatGPT is killing stackoverflow, but chatGPT is still infested with stackoverflow like elitism.

Talk to it like you're an expert and it mostly does what you actually want. Talk to it casually and it just ignores elements of your request and assumes you didn't really want them anyway.

Legend

I have access to OpenAI's greatest model for example.

I gave it a chunk of code for this forum that had two shell commands that ran back to back. I made a mistake in one of the commands since I know so little on how to set them up.

I told o1 very harshly that I know php and I do not want any changes to php. I just want the microadjustment needed to fix the broken command. For the first time ever it actually just did that. Even kept my unclosed brackets that don't have a match in this small chunk. Nice!

However I also asked it to give me a second adjustment where both commands were combined into a single command, since that would work better. It then did the standard ai thing and renamed most variables, changed the structure, and changed the output so it was useless without a lot of cleanup.

the-pi-guy

thediscdb

I thought this website was eventually going to be a nice tool for figuring out the contents of each disc for TV series. 

Just found out, despite the name, there is apparently no database.

Everything is just being added to source control. 

https://github.com/TheDiscDb/data/blob/main/data/series/Avatar%20The%20Last%20Airbender%20(2005)/2018-complete-series-blu-ray/disc01.json

Legend

Quote from: the-Pi-guy on Dec 10, 2024, 12:49 AMthediscdb

I thought this website was eventually going to be a nice tool for figuring out the contents of each disc for TV series.

Just found out, despite the name, there is apparently no database.

Everything is just being added to source control.

https://github.com/TheDiscDb/data/blob/main/data/series/Avatar%20The%20Last%20Airbender%20(2005)/2018-complete-series-blu-ray/disc01.json
Guess you gotta convert it ypurself

the-pi-guy

#686
I'm just baffled by that.

Having a database, and having stuff set up so that people could contribute would be the absolute first thing I'd have done for this kind of website.

the-pi-guy

3PM:
*spends an hour getting frustrated by personal web apps, making no progress* 

10:30PM:
*Spends an hour, manages to fix a bunch of the issues that were plaguing me earlier* 


the-pi-guy

I would really like some kind of process where I could upload my program to my NAS drive and then have it deploy the app every time it gets updated... 

Legend

Quote from: the-Pi-guy on Jan 06, 2025, 08:58 PMI would really like some kind of process where I could upload my program to my NAS drive and then have it deploy the app every time it gets updated...
What do you mean? Like the app auto updates but doesn't restart?