Skip to content

Instantly share code, notes, and snippets.

@hyades
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hyades/546512eaf028e1495814 to your computer and use it in GitHub Desktop.
Save hyades/546512eaf028e1495814 to your computer and use it in GitHub Desktop.
import os
from scipy.misc import imread
frames = {}
for filename in os.listdir('.'):
if filename.endswith('.jpg'):
img = imread(filename).astype(int)
left = img[99][75]
right = img[99][225]
frames[filename] = [0, 0]
if left[0] >= 250:
frames[filename][0] = 'R'
elif left[1] >= 250:
frames[filename][0] = 'G'
elif left[2] >= 250:
frames[filename][0] = 'B'
if right[0] >= 250:
frames[filename][1] = 'R'
elif right[1] >= 250:
frames[filename][1] = 'G'
elif right[2] >= 250:
frames[filename][1] = 'B'
for i in sorted(frames):
print i, frames[i]

Frame Drop Check

Setup

Terminal 1 Download gsttestsrc.tar.gz https://www.dropbox.com/s/vv2447xvikp5ftl/gsttestsrc.tar.gz?dl=0 wget

  • tar -xvf gsttestsrc.tar.gz
  • cd gst
  • ./gst-master

Terminal 2 Download kt.sh wget

  • chmod +x kt.sh
  • ./kt.sh
  • Wait for the compile/make for gst-switch and then gst-switch-srv and ui are started.
  • Wait for the UI to appear.

When UI pops up, go to Terminal 1 and start up a pipeline When first time UI comes up, put in the first pipeline in terminal 1. When second time the UI comes up, put in the second pipeline in terminal 2

Terminal 1 Pipelines

  • gst-launch-1.0 videotestsrc pattern=2 ! timeoverlay font-desc="90px" ! video/x-raw, width=300, height=200 ! gdppay ! tee name=abc ! queue ! tcpclientsink port=3000 abc. ! queue ! tcpclientsink port=3000 abc. ! gdpdepay ! jpegenc ! avimux ! filesink location=2.avi This pipeline is useful for finding dropped frames in switches and when a record file changes.

  • gst-launch-1.0 videotestsrc pattern=blink ! video/x-raw, width=300, height=200 ! gdppay ! tee name=abc ! queue ! tcpclientsink port=3000 abc. ! queue ! tcpclientsink port=3000 abc. ! gdpdepay ! jpegenc ! avimux ! filesink location=2.avi This pipeline is better to detect frame drops in between any UI events.

Producing frames -

  • Press tab key in the UI around 5-6 in an interval of around 15 secs to switch the video. After this press the r key 3-4 times.

Now each directory $HOME/frames/1/frames** and $HOME/frames/2/frames** will have lots of frames inside it. Going through these dumped frames, find positions of where exactly the switch event happens. Compare frames before and after the switch. Similarly, the frames produced by the recording can also be compared.

For finding frame dropped in between switches, the above pipeline can be difficult to use. Instead use the pipeline -

This should feed in a source which alternates frames of RED, GREEN, BLUE.

Python file to detect red/blue/green in equal pip mode is detect_frames.py

#! /bin/bash -ex
export GSTSWITCHPATH=$HOME/gstswitchbuild
mkdir -p $GSTSWITCHPATH
cd $GSTSWITCHPATH
git clone https://github.com/deeprave/gst-switch.git
cd gst-switch
git checkout set-video-format-support
chmod +x build-min-trusty.sh
./build-min-trusty.sh
export DIR1=$HOME/frames/1
mkdir -p $DIR1
mkdir -p $DIR1/frames
mkdir -p $DIR1/src_frames
mkdir -p $DIR1/frames_000
mkdir -p $DIR1/frames_001
mkdir -p $DIR1/frames_002
cd tools
./gst-switch-srv --record=$DIR1/1.avi &
export SRV=$!
sleep 5
./gst-switch-ui &
export UI=$!
echo "NOW START THE SOURCE IN OTHER TERMINAL WHICH HAS CUSTOM GSTREAMER INSTALLED"
echo "gst-launch-1.0 videotestsrc pattern=blink ! video/x-raw, width=1280, height=720 ! gdppay ! tee name=abc ! queue ! tcpclientsink port=3000 abc. ! queue ! tcpclientsink port=3000 abc. ! gdpdepay ! jpegenc ! avimux ! filesink location=$HOME/frames/1/2.avi"
sleep 100
# START THE OTHER SCRIPT WHICH FEEDS IN INPUT NOW AND DO SOME SWITCHES AND A FEW RECORDS
kill $SRV
kill $UI
cd $DIR1/frames
mplayer -vo jpeg ../1.avi
cd ../src_frames
mplayer -vo jpeg ../2.avi
cd ../frames_000
mplayer -vo jpeg ../1.avi.000
cd ../frames_001
mplayer -vo jpeg ../1.avi.001
export DIR2=$HOME/frames/2
mkdir -p $DIR2
mkdir -p $DIR2/frames
mkdir -p $DIR2/src_frames
mkdir -p $DIR2/frames_000
mkdir -p $DIR2/frames_001
mkdir -p $DIR2/frames_002
cd $GSTSWITCHPATH
cd gst-switch/tools
./gst-switch-srv --record=$DIR2/1.avi &
export SRV=$!
sleep 5
./gst-switch-ui &
export UI=$!
echo "NOW START THE SOURCE IN OTHER TERMINAL WHICH HAS CUSTOM GSTREAMER INSTALLED"
echo "gst-launch-1.0 videotestsrc pattern=2 ! timeoverlay font-desc='90px' ! video/x-raw, width=1280, height=720 ! gdppay ! tee name=abc ! queue ! tcpclientsink port=3000 abc. ! queue ! tcpclientsink port=3000 abc. ! gdpdepay ! jpegenc ! avimux ! filesink location=$HOME/frames/2/2.avi"
sleep 100
# START THE OTHER SCRIPT WHICH FEEDS IN INPUT NOW AND DO SOME SWITCHES AND A FEW RECORDS
kill $SRV
kill $UI
cd $DIR2/frames
mplayer -vo jpeg ../1.avi
cd ../src_frames
mplayer -vo jpeg ../2.avi
cd ../frames_000
mplayer -vo jpeg ../1.avi.000
cd ../frames_001
mplayer -vo jpeg ../1.avi.001
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment