User Tools

Site Tools


project:stereoscopy

This is an old revision of the document!


Stereoscopic recording using FFmpeg

FFmpeg is a free software project that produces libraries and programs for handling multimedia data. FFmpeg is developed mostly on Linux, but can be compiled under most operating systems, including Mac OS X, Microsoft Windows, Android, iOS, as well as AmigaOS and MorphOS.

http://ffmpeg.org/

ffmpeg -help

Accessing USB cameras

Here we use two identical USB cameras for capturing. These examples are for Windows Windows os (DirectShow multimedia framework). Commands for accessing cameras on other operating sistem are here: https://trac.ffmpeg.org/wiki/Capture/Webcam. Linux/Debian v4l-utils package.

Example to list dshow input devices:

ffmpeg -list_devices true -f dshow -i dummy

Example to print a list of options from a selected device:

ffmpeg -f dshow -list_options true -i video="Icatch(X) KV Series Null Device"

Camera calibration

Preview obiju komara (za kalibraciju). Dva cam ulaza i overlay (checkerboard) za provjeru prekpapanja.

ffmpeg -y -f dshow -video_size 640x480 -framerate 30 -pixel_format yuyv422 -video_device_number 0 -i video="Icatch(X) KV Series Null Device" -f dshow -video_size 640x480 -framerate 30 -pixel_format yuyv422 -video_device_number 1 -i video="Icatch(X) KV Series Null Device" -filter_complex blend=all_expr='if(eq(mod(X,2),mod(Y,2)),A,B)' -vcodec rawvideo -pix_fmt yuyv422 -f sdl "SDL output"

Video recording

Paralelno spremanje dvaju video inputa (kamere) u dva file-a. Svakako prije treba utvrditi koja je desna, a koja lijeva kamera.

ffmpeg -y -f dshow -video_size 640x480 -framerate 30 -pixel_format yuyv422 -video_device_number 0 -i video="Icatch(X) KV Series Null Device" LEFT.mp4 | ffmpeg -y -f dshow -video_size 640x480 -framerate 30 -pixel_format yuyv422 -video_device_number 1 -i video="Icatch(X) KV Series Null Device" RIGHT.mp4

direktan stream, bez rekompresije (veća rezolucija i bez lag-a)

ffmpeg -y -f dshow -video_size 1280x720 -framerate 30 -vcodec mjpeg -video_device_number 0 -i video="Icatch(X) KV Series Null Device" -vcodec copy RIGHT.mp4 | ffmpeg -y -f dshow -video_size 1280x720 -framerate 30 -vcodec mjpeg -video_device_number 1 -i video="Icatch(X) KV Series Null Device" -vcodec copy LEFT.mp4

Framepacking

Pack two different video streams into a stereoscopic video, setting proper metadata on supported codecs. Convert left and right video to one side-by-side. https://ffmpeg.org/ffmpeg-filters.html#framepack

ffmpeg -i LEFT.mp4 -i RIGHT.mp4 -filter_complex framepack=sbs OUTPUT_SBS.mp4

Convert views into a side-by-side video with the same output resolution as the input (SBS half resolution)

ffmpeg -i LEFT.mp4 -i RIGHT.mp4 -filter_complex [0:v]scale=w=iw/2[left],[1:v]scale=w=iw/2[right],[left][right]framepack=sbs OUTPUT_SBS.mp4

Framepacking možda neće raditi sa falovima snimljenim s direktnim streamom, pa treba prije rekomprimirati forsirajući framerate.

ffmpeg -i LEFT.mp4 -r 30 -vcodec libx264 -preset ultrafast -qp 0 LEFT_2.mp4
ffmpeg -i RIGHT.mp4 -r 30 -vcodec libx264 -preset ultrafast -qp 0 RIGHT_2.mp4

Changing stereoscopic formats

Convert between different stereoscopic image formats. https://trac.ffmpeg.org/wiki/Stereoscopic https://ffmpeg.org/ffmpeg-filters.html#stereo3d

Converting SBS (full res) to anaglyph (Red-cyan dubois):

ffmpeg -i OUTPUT_SBS.mp4 -vf stereo3d=sbsl:arcd OUTPUT_ANAGLYPH.mp4

Still image capture

Direct stereo SBS image capture from usb cams. Postoji latencija između L i R slike … FIXME

ffmpeg.exe -y -f dshow -video_size 1600x1200 -vcodec mjpeg  -video_device_number 0 -i video="Icatch(X) KV Series Null Device"  -f dshow -video_size 1600x1200 -vcodec mjpeg  -video_device_number 1 -i video="Icatch(X) KV Series Null Device" -filter_complex framepack=sbs -vframes 1 STEREO_SBS.jpeg

SBS image to ANAGLYPH image

ffmpeg -i STEREO_SBS.jpeg -vf stereo3d=sbsl:arcd -vframes 1 STEREO_ANAGLYPH.jpeg
project/stereoscopy.1508085889.txt.gz · Last modified: 2017/10/15 18:44 by dp