pyVideoTrans - Spanish Audio Video Creator
Create playable MP4 videos from Spanish MP3 audio + SRT subtitle files, with optional Chinese translations.
Prerequisites
- ffmpeg: D:\pyvideotrans\ffmpeg\ffmpeg.exe (also ffprobe)
- Background image: D:\pyvideotrans\swiss-landscape.png (1920x1080)
- Python 3.11+ available system-wide
- Output directory: D:\pyvideotrans\
Core Workflow
1. Build a Bilingual SRT
The source .srt file has Spanish text. Create a bilingual version by appending a Chinese translation line after each Spanish text line, keeping the same sequence numbers and timings.
Pattern per entry: ` N HH:MM:SS,mmm --> HH:MM:SS,mmm Spanish text line Chinese translation
`
Read source SRT with encoding='utf-8-sig', write with encoding='utf-8'. Use Python to parse SRT blocks and provide translations inline.
2. Create the Video
Run ffmpeg from D:\pyvideotrans\ffmpeg:
.\ffmpeg.exe -y -loop 1 -i "D:\pyvideotrans\swiss-landscape.png" -i "AUDIO.mp3" -vf "subtitles='BILINGUAL_SRT':fontsdir='C:/Windows/Fonts'" -c:v libx264 -preset fast -crf 22 -c:a aac -b:a 128k -shortest "D:\pyvideotrans\OUTPUT.mp4"
Use -timeout_ms up to 300000 for longer audio files (6-7 min).
3. Adjust Subtitle Position (MarginV)
For Spanish-only exercises where subtitles overlap the background:
-vf "subtitles='SRT':fontsdir='C:/Windows/Fonts':force_style='MarginV=55'"
MarginV=55 moves subtitles upward (larger = higher above bottom).
Spanish-Only Videos
For pure listening exercises using *-es.srt files:
- Use source SRT path directly in subtitles filter
- Do not add Chinese translations
- Add MarginV=55 if user requests adjusted positioning
Source File Locations
All under D:\Spain:
- 听力教程1: 西班牙语听力教程1\
- 晨读美文: 西班牙语晨读美文\第四章 经典台词\
- FSI Course: Spanish-Basic-Course\
- Output videos: D:\pyvideotrans\
