A powerful Azure Batch application that converts MP4 videos to GIF format using distributed cloud computing. Perfect for creating adorable pet GIFs at scale! π±πΆ
- Scalable Processing: Leverages Azure Batch for parallel video conversion
- Cost Effective: Uses low-priority VM instances to minimize costs
- Automated Workflow: End-to-end pipeline from upload to processed output
- FFmpeg Integration: High-quality video-to-GIF conversion using industry-standard tools
- Cloud Storage: Seamless integration with Azure Blob Storage
- Monitoring: Real-time task monitoring and error handling
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β Input Files βββββΆβ Azure Batch βββββΆβ Output GIFs β
β (MP4 Videos) β β Processing Pool β β (Blob Storage) β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β β β
β βββββββββββββββββββ β
ββββββββββββββββΆβ Azure Storage ββββββββββββββββ
β Containers β
βββββββββββββββββββ
- .NET 6.0 SDK or later
- Azure CLI
- Active Azure subscription with:
- Azure Batch account
- Azure Storage account
- FFmpeg application package configured in Batch
-
Clone the repository
git clone https://github.com/yourusername/cutifypets.git cd cutifypets
-
Restore dependencies
dotnet restore
-
Set up Azure resources (see Setup Guide)
-
Configure environment variables
export BATCH_URL="https://yourbatchaccount.region.batch.azure.com" export BATCH_NAME="yourbatchaccount" export BATCH_KEY="your-batch-account-key" export STORAGE_NAME="yourstorageaccount" export STORAGE_KEY="your-storage-account-key"
-
Add your MP4 files
mkdir InputFiles # Copy your .mp4 files to the InputFiles directory
-
Run the application
dotnet run
Use the provided setup script to configure your Azure resources:
# Set your subscription
az account set --subscription 'Your Subscription Name'
# Run the setup script
chmod +x setup-azure.sh
./setup-azure.sh
Click to expand manual setup instructions
-
Create Resource Group
az group create --name MLSA-demo --location eastus
-
Create Batch Account
az batch account create \ --name yourbatchaccount \ --resource-group MLSA-demo \ --location eastus
-
Create Storage Account
az storage account create \ --name yourstorageaccount \ --resource-group MLSA-demo \ --location eastus \ --sku Standard_LRS
-
Upload FFmpeg Application Package
- Download FFmpeg from official website
- Upload as application package to your Batch account
- Set Application ID:
ffmpeg
, Version:3.4
cutifypets/
βββ Program.cs # Main application logic
βββ CutifyPets.csproj # Project configuration
βββ setup-azure.sh # Azure resource setup script
βββ InputFiles/ # Directory for input MP4 files
βββ docs/ # Additional documentation
β βββ ARCHITECTURE.md # Detailed architecture guide
β βββ TROUBLESHOOTING.md # Common issues and solutions
β βββ API_REFERENCE.md # Code documentation
βββ scripts/ # Utility scripts
β βββ cleanup-azure.sh # Resource cleanup script
βββ README.md # This file
The application uses the following environment variables:
Variable | Description | Example |
---|---|---|
BATCH_URL |
Azure Batch account endpoint | https://mybatch.eastus.batch.azure.com |
BATCH_NAME |
Batch account name | mybatchaccount |
BATCH_KEY |
Batch account access key | abc123... |
STORAGE_NAME |
Storage account name | mystorageaccount |
STORAGE_KEY |
Storage account access key | def456... |
The application creates a processing pool with the following default settings:
- VM Size:
STANDARD_D2_v2
(2 cores, 7GB RAM) - Low Priority Nodes: 3 (cost-effective)
- Dedicated Nodes: 0
- OS: Windows Server 2012 R2
You can modify these settings in the Program.cs
file:
private const int LOW_PRIORITY_NODE_COUNT = 3; // Adjust based on workload
private const string POOL_VM_SIZE = "STANDARD_D2_v2"; // Change VM size as needed
- Low Priority VMs: Uses low-priority instances for up to 80% cost savings
- Auto-scaling: Pool scales based on workload
- Automatic Cleanup: Resources are cleaned up after job completion
- Efficient Processing: Parallel processing reduces overall runtime
The application provides comprehensive logging:
- Pool creation and status
- Job submission and progress
- Task execution monitoring
- Resource cleanup confirmation
Example output:
Creating pool [WinFFmpegPool]...
Creating job [WinFFmpegJob]...
Adding 5 tasks to job [WinFFmpegJob]...
Monitoring all tasks for 'Completed' state, timeout in 00:30:00...
All tasks reached state Completed.
Success! All tasks completed successfully. Output files uploaded to output container.
To support additional input formats, modify the file filtering in UploadInputFilesAsync
:
List<string> inputFilePaths = new List<string>(Directory.GetFiles(inputPath, "*.mov")); // Add .mov support
To convert to different formats, update the FFmpeg command in AddTasksAsync
:
string taskCommandLine = $"cmd /c {appPath}\\ffmpeg-3.4-win64-static\\bin\\ffmpeg.exe -i {inputMediaFile} -vf scale=480:-1 {outputMediaFile}";
Add quality settings, resolution changes, or filters:
// High quality GIF with custom palette
string taskCommandLine = $"cmd /c {appPath}\\ffmpeg-3.4-win64-static\\bin\\ffmpeg.exe -i {inputMediaFile} -vf \"fps=15,scale=320:-1:flags=lanczos,palettegen\" palette.png && {appPath}\\ffmpeg-3.4-win64-static\\bin\\ffmpeg.exe -i {inputMediaFile} -i palette.png -lavfi \"fps=15,scale=320:-1:flags=lanczos [x]; [x][1:v] paletteuse\" {outputMediaFile}";
Issue: Pool creation fails
Solution: Verify your Batch account quotas and ensure the VM size is available in your region
Issue: Tasks fail with FFmpeg errors
Solution: Check that the FFmpeg application package is correctly uploaded and accessible
Issue: Storage access denied
Solution: Verify storage account keys and ensure containers have proper permissions
For more detailed troubleshooting, see TROUBLESHOOTING.md.
We welcome contributions! Please see our Contributing Guidelines for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Transform your pet videos into shareable GIFs with the power of Azure!