28 March, 2013

Side-by-Side RTSP Stream Capture

Assuming you have two RTSP MPEG-4 streams and wish to generate a side-by-side mosaic. You can do this by using the video filter overlay method; ffmpeg -y -q:v 0 -i rtsp:// -q:v 0 -an -vf "[in] pad=2*iw:ih [left]; movie='rtsp\://' [right]; [left][right] overlay=main_w/2:0 [out]" /tmp/sidebyside.avi

Generate Side-by-Side Video Using FFMpeg

Seems I've been doing things the hard way for quite some time.  Occasionally, I've found it useful to generate mosaic'ish videos.  'til now, I've done so by extracting frames from the video into a series of png or jpg files, using ImageMagick to generate the source images, then reassemble the input frames into a video.  Seems an easier way is to extend one of the source video files into the destination dimensions, then overlay the other video over the extended space.

$ ffmpeg -y -i ./Downloads/big_buck_bunny_1080p_surround.avi -s 640x480 -an -sameq /var/tmp/left.avi
$ ffmpeg -y -i /var/tmp/left.avi -vf "pad=1280:480:0:0:black" -sameq /var/tmp/wide.avi
$ ffmpeg -y -i /var/tmp/wide.avi -vf "movie=/var/tmp/left.avi[mv]; [in][mv] overlay=640:0" -sameq /var/tmp/side.avi


16 March, 2013

FFMpeg Piping to Mplayer

Far too often I find myself playing with ffmpeg, trying to transcode a video and evaluating the results. The typical manner of doing this is taking the input file, generating an output file, then playing with the equivalent of mplayer. The need for the temporary output file is primarily motivated because I wasn't aware how to properly pipe the transcoded video to standard output and pipe it to the display utility (e.g. mplayer). I did however recently figure this out, and decided to post for those of you struggling with the same issue. The following example takes in the popular open-source video, transcoding to mpeg format and uses only the first audio chanel, using same video quality but resizes to 720x480 and pipes the output to mplayer.

ffmpeg -i Videos/big_buck_bunny_1080p_surround.avi -f mpeg -ac 1 -sameq -s 720x480 - | mplayer -