diff --git a/hq2cd-ps1/convert-from-file.ps1 b/hq2cd-ps1/convert-from-file.ps1 new file mode 100644 index 0000000..f32358a --- /dev/null +++ b/hq2cd-ps1/convert-from-file.ps1 @@ -0,0 +1,26 @@ +# Output to a flat directory as I am going to use picard to rename the files after the fact + +# Read each line in the file +$filePaths = Get-Content -Path $args[0] +$files = @() +foreach ($filePath in $filePaths) { + $files += Get-Item -Path $filePath +} + +# Save to output folder "Output" +$destination = "Output" +if (-not (Test-Path -Path $destination)) { + New-Item -Path $destination -ItemType Directory +} + +# Now use ffmpeg to convert each file to 16-bit 44.1kHz +<# This is the old way, use the new way below using -Parallel +foreach ($file in $files) { + $destinationPath = $destination + "\" + $file.Name + ffmpeg -i $file.FullName -c:a flac -sample_fmt s16 -ar 44100 $destinationPath +} +#> +$files | ForEach-Object -Parallel { + $destinationPath = $destination + "\" + $_.Name + ffmpeg -i $_.FullName -c:a flac -sample_fmt s16 -ar 44100 $destinationPath +} \ No newline at end of file diff --git a/hq2cd-ps1/get-paths.ps1 b/hq2cd-ps1/get-paths.ps1 index 62f8487..1b156b8 100644 --- a/hq2cd-ps1/get-paths.ps1 +++ b/hq2cd-ps1/get-paths.ps1 @@ -3,16 +3,36 @@ # Get all files with the .flac extension $files = Get-ChildItem -Path . -Filter *.flac -Recurse +Write-Host "Found" $files.Count "files" + # For each file, run ffprobe with json ouptut, and include it in a new list if it has a sample rate above 44100, and a bit depth above 16 $hq = @() +<# This is the old way, use the new way below using -Parallel +foreach ($file in $files) { + $ffprobe = ffprobe -v quiet -print_format json -show_format -show_streams $file.FullName + $ffprobe = $ffprobe | ConvertFrom-Json + $stream = $ffprobe.streams | Where-Object {$_.codec_name -eq "flac"} + + if ($stream.sample_rate -gt 44100 -or $stream.bits_per_raw_sample -gt 16) { + Write-Host $file.FullName + $hq += $file + } +} +#> $files | ForEach-Object -Parallel { $ffprobe = ffprobe -v quiet -print_format json -show_format -show_streams $_.FullName $ffprobe = $ffprobe | ConvertFrom-Json - if ($ffprobe.format.sample_rate -gt 44100 -and $ffprobe.streams.bits_per_raw_sample -gt 16) { + $stream = $ffprobe.streams | Where-Object {$_.codec_name -eq "flac"} + + if ($stream.sample_rate -gt 44100 -or $stream.bits_per_raw_sample -gt 16) { + Write-Host $_.FullName $hq += $_ } } -Write-Host $hq \ No newline at end of file +# Save each file in hq to a text file with its full path +foreach ($file in $hq) { + $file.FullName | Out-File -FilePath hq.txt -Append +} \ No newline at end of file