A powerful Python application that converts standard 2D videos into stereoscopic 3D Side-by-Side (SBS) format for VR viewing. This converter uses deep learning (MiDaS) to generate accurate depth maps and create high-quality stereoscopic 3D videos optimized for various VR headsets.
- Deep Learning-Based Depth Estimation: Uses the MiDaS neural network for accurate depth map generation
- GPU Optimization: Maximizes GPU utilization for faster processing with batch frame handling
- Video Segment Processing: Select specific portions of longer videos to convert
- Adjustable 3D Parameters:
- Depth intensity control (0.0-1.0)
- Convergence distance adjustment (1.0-10.0)
- Eye separation control (0.1-5.0)
- Multiple Input Sources:
- Upload local video files (up to 500MB)
- Process videos from URLs including YouTube
- Format Support:
- Input: MP4, AVI, MOV, WebM, MKV (up to 4K resolution)
- Output: H.264 encoded MP4 in SBS format (1920x1080)
- Real-time Preview: Visualize parameter adjustments before processing
- Clean User Interface: Intuitive Gradio-based UI with tab-based workflow
- Comprehensive Progress Tracking: Detailed status updates during conversion
The converter uses a multi-stage pipeline to transform 2D videos into 3D SBS format:
- Frame Extraction: Extracts frames from the source video
- Depth Estimation: Processes each frame through the MiDaS neural network to generate depth maps
- Stereoscopic Synthesis: Creates left and right eye views by applying a displacement algorithm based on the depth maps
- View Combination: Combines the stereoscopic views into a side-by-side format
- Video Encoding: Encodes the final frames into an H.264 MP4 video
The easiest way to run this converter is through Google Colab, which provides free GPU resources:
- Open the Colab Notebook
- Select "Runtime" → "Change runtime type" → Set "Hardware accelerator" to "GPU"
- Run all cells
To run the converter locally (requires a CUDA-capable NVIDIA GPU):
-
Clone this repository:
git clone https://github.com/PointerSoftware/2D-to-3D-SBS-Converter.git cd 2D-to-3D-SBS-Converter -
Set up a Python virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate -
Install dependencies:
pip install -r requirements.txt -
Run the notebook:
jupyter notebook 2D_to_3D_SBS_Converter.ipynb
- Upload a video file or provide a URL to a video (supports YouTube)
- Adjust the 3D effect parameters:
- Depth Intensity: Controls the strength of the 3D effect (higher values create more pronounced depth)
- Convergence Distance: Adjusts where objects appear relative to the screen plane
- Eye Separation: Controls the virtual camera separation (higher values create more extreme 3D effects)
- Click "Update Preview" to see how your settings affect the 3D output
- Click "Process Video" to convert the entire video to 3D SBS format
- Download the converted video for viewing in a VR headset or 3D display
For longer videos, you can process specific segments:
- Check the "Process a specific segment" box
- Set the start and end times in seconds
- Process only the selected portion of the video
This is useful for:
- Testing 3D settings on a clip before processing the entire video
- Processing very long videos in manageable chunks
- Creating 3D highlights from specific parts of longer videos
The output video is in Side-by-Side (SBS) format, which can be viewed in:
- VR headsets using video players that support SBS format
- 3D TVs with SBS viewing mode
- Special 3D viewers like Google Cardboard with SBS-compatible apps
- Depth Map Generation: Uses MiDaS DPT_Large model for depth estimation
- Output Format: 1920x1080 (16:9) with 960x720 (4:3) content for each eye, embedded with black bars
- GPU Acceleration: Optimized for NVIDIA GPUs with dynamic batch sizing based on available memory
- Memory Management: Periodic GPU memory cleanup to handle larger videos
- Video Processing: FFmpeg-based segment extraction and final encoding
- Python 3.8+
- PyTorch with CUDA support
- OpenCV, NumPy, Gradio
- FFmpeg
- NVIDIA GPU with CUDA support (for GPU acceleration)
This project is licensed under the MIT License - see the LICENSE file for details.
- MiDaS for the depth estimation model
- Gradio for the user interface framework
- FFmpeg for video processing capabilities
Contributions are welcome! Please feel free to submit a Pull Request.
