Skip to content

Commit

Permalink
ffmpeg ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
JAlcocerT committed Mar 8, 2025
1 parent 2f7dc44 commit 6305546
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 5 deletions.
21 changes: 19 additions & 2 deletions Z_Linux_Installations_101/FFMpeg/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,30 @@ Have been playing around with video at:
3. https://jalcocert.github.io/JAlcocerT/asrock-x300-home-server/#video-editing-101
4. https://jalcocert.github.io/JAlcocerT/dji-osmo-action-5-pro/

## FFMPEG and Linux
## FFMPEG

### FFMPEG and Linux

```sh

```

## FFMPEG with Windows
### FFMPEG with Windows

```sh
# Install Chocolatey (Run as Administrator)
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; Invoke-WebRequest -UseBasicParsing 'https://community.chocolatey.org/install.ps1' | Invoke-Expression

# Verify Chocolatey Installation
choco --version

# Install FFmpeg (Run as Administrator)
choco install ffmpeg -y
#choco install chocolateygui #optionally, install a UI to install other packages with GUI

# Verify FFmpeg Installation
ffmpeg -version #I got the version 7.1-essentials_build
```

```sh

Expand Down
71 changes: 71 additions & 0 deletions Z_Linux_Installations_101/FFMpeg/video_copy.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Define source and destination paths
$source = "C:\Users\j--e-\Desktop\CAM"
$destination = "F:\DCIM\DJI_001"

# Ensure the destination folder exists
if (!(Test-Path -Path $destination)) {
New-Item -ItemType Directory -Path $destination -Force
}

# Get all .MP4 files from source
$files = Get-ChildItem -Path $source -Filter "*.MP4"

# Check if there are files to copy
if ($files.Count -eq 0) {
Write-Host "No MP4 files found in $source."
exit
}

$totalFiles = $files.Count
$copiedFiles = 0
$totalBytes = ($files | Measure-Object -Property Length -Sum).Sum
$startTime = Get-Date

foreach ($file in $files) {
$fileSizeMB = [math]::Round($file.Length / 1MB, 2)
$fileName = $file.Name
$sourcePath = $file.FullName
$destPath = Join-Path -Path $destination -ChildPath $fileName

$copyStart = Get-Date
Copy-Item -Path $sourcePath -Destination $destPath -Force
$copyEnd = Get-Date

# Calculate time taken for the copy
$timeTaken = ($copyEnd - $copyStart).TotalSeconds
$speed = if ($timeTaken -gt 0) { [math]::Round($fileSizeMB / $timeTaken, 2) } else { 0 }

# Update progress
$copiedFiles++
$percentComplete = ($copiedFiles / $totalFiles) * 100

Write-Progress -Activity "Copying MP4 Files" -Status "Processing: $fileName ($copiedFiles of $totalFiles)" -PercentComplete $percentComplete
Write-Host "Copied: $fileName - Size: ${fileSizeMB}MB - Speed: ${speed} MB/s"
}

$endTime = Get-Date
$totalTime = ($endTime - $startTime).TotalSeconds
$avgSpeed = if ($totalTime -gt 0) { [math]::Round(($totalBytes / 1MB) / $totalTime, 2) } else { 0 }

Write-Host "`n✅ Transfer complete!"
Write-Host "Total Files: $totalFiles"
Write-Host "Total Size: $([math]::Round($totalBytes / 1MB, 2)) MB"
Write-Host "Total Time: $([math]::Round($totalTime, 2)) seconds"
Write-Host "Average Speed: ${avgSpeed} MB/s"


# # Define source and destination paths
# $source = "C:\Users\j--e-\Desktop\CAM"
# $destination = "F:\DCIM\DJI_001"

# # Ensure the destination folder exists
# if (!(Test-Path -Path $destination)) {
# New-Item -ItemType Directory -Path $destination -Force
# }

# # Copy only .MP4 files from source to destination
# Get-ChildItem -Path $source -Filter "*.MP4" | ForEach-Object {
# Copy-Item -Path $_.FullName -Destination $destination -Force
# }

# Write-Host "MP4 files copied successfully!"
11 changes: 11 additions & 0 deletions Z_Linux_Installations_101/FFMpeg/video_tricks.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
$camFolderPath = Join-Path -Path "C:\Users\j--e-\Desktop" -ChildPath "CAM"

if (Test-Path -Path $camFolderPath -PathType Container) {
Set-Location -Path $camFolderPath

Get-ChildItem -Filter "*.MP4" | ForEach-Object { "file '$($_.Name)'" } | Set-Content file_list.txt

Write-Host "File list generated in: $($camFolderPath)\file_list.txt"
} else {
Write-Warning "CAM folder not found at: $($camFolderPath)"
}
6 changes: 3 additions & 3 deletions Z_Linux_Installations_101/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ Trying Linux for the first time?

This guide will get you and your system started with **your favourite Apps**.

1. Benchmark a PC/Server: While [testing the x300](https://jalcocert.github.io/JAlcocerT/asrock-x300-home-server/#benchmarks-101)
1. **Benchmark** a PC/Server: While [testing the x300](https://jalcocert.github.io/JAlcocerT/asrock-x300-home-server/#benchmarks-101)

```sh
curl -O https://raw.githubusercontent.com/JAlcocerT/Linux/main/Z_Linux_Installations_101/Benchmark101.sh
chmod +x Benchmark101.sh & ./Benchmark101.sh
```

2. [SelfHosting 101](https://jalcocert.github.io/Linux/docs/linux__cloud/selfhosting/):
2. [**SelfHosting** 101](https://jalcocert.github.io/Linux/docs/linux__cloud/selfhosting/):

```sh
curl -O https://raw.githubusercontent.com/JAlcocerT/Linux/main/Z_Linux_Installations_101/Selfhosting_101.sh
Expand All @@ -21,7 +21,7 @@ chmod +x Selfhosting_101.sh
sudo ./Selfhosting_101.sh
```

3. Quick Video Edition with ffmpeg, as covered [here](https://jalcocert.github.io/JAlcocerT/my-action-cam-video-workflow/#quick-videos---ffmpeg-cli)
3. **Quick Video Edition**: with ffmpeg, as covered [here](https://jalcocert.github.io/JAlcocerT/my-action-cam-video-workflow/#quick-videos---ffmpeg-cli)

```sh

Expand Down

0 comments on commit 6305546

Please sign in to comment.