Log in

View Full Version : Any way deshake with native apps?


Spotteri
3rd July 2006, 13:22
I have a large number of DVcam-recordings that are in need of deshaking and can't be joined. These shear number of these files would make the "DGIndex-Avisynth+deshake"-method too complex.

So I'm asking is there a native linux method to deshake using commandline tools. Preferably one that inputs/output yuvmpeg from/to stdin/stdout.

alec_robertson
4th July 2006, 16:58
Try y4mstabilizer from mjpegtools. It works directly on yuv4mpeg streams and depending on the nature of your footage, it may do the trick...

scharfis_brain
4th July 2006, 17:03
DVcam and MPEG? did I miss something?

DV-AVIs can be loaded to Virtualdub, being deshaked and save as DV.AVI. All with a batch job list.

So: where is the problem?

even with MPEG & AVS it is not a big deal.
prepare all D2Vs and AVS-Scripts, load them to VDub and save the jobs.

Spotteri
7th July 2006, 19:12
Try y4mstabilizer from mjpegtools. It works directly on yuv4mpeg streams and depending on the nature of your footage, it may do the trick...

I'm unable to convert to the recommended colormode and if I feed it directly from mplayer it causes some serious croma errors. i.e. picture keeps flipping to grayscale from time to time and colors are in the wrong place (about 80 pixel offset to right and down)

DVcam and MPEG? did I miss something?
The cam records in DVD(mpeg2+ac3)-format. Directly playable on standalone.


even with MPEG & AVS it is not a big deal.
prepare all D2Vs and AVS-Scripts, load them to VDub and save the jobs.
If you have close to a 100 small clips, it is a big deal. Using a native software with a good effective bash-script would make a life a lot more easier. Besides Mplayer seems to be the only one that keeps the V/A-sync. All other methods force me to find the right sync manually...for every single clip.

Oh well. I'll just have to leave out the deshake or spend a dull afternoon with the "DGIndex->Avisynth+Deshake->Encoder"-method.

alec_robertson
7th July 2006, 22:00
I'm unable to convert to the recommended colormode
Yes, you need to convert the colorspace using y4mscaler (from y4mstabilizer -h):
... | yuvdeinterlace | \
y4mscaler -v 0 -O sar=src -O chromass=444 | \
y4mstabilizer | \
y4mscaler -v 0 -O sar=src -O chromass=420_MPEG2 | ...
You can get y4mstabilizer from http://www.mir.com/DMG/Software/

Spotteri
8th July 2006, 08:38
Yes, you need to convert the colorspace using y4mscaler (from y4mstabilizer -h):
... | yuvdeinterlace | \
y4mscaler -v 0 -O sar=src -O chromass=444 | \
y4mstabilizer | \
y4mscaler -v 0 -O sar=src -O chromass=420_MPEG2 | ...
You can get y4mstabilizer from http://www.mir.com/DMG/Software/
Yes I know that, but using y4mscaler causes mplayer to crash and if I try to get mplayer to output 444p, it complains that 444p is not suitable for yuv4mpeg output.

EDIT:
P.S. Sorry. It wasn't the Mplayer. Mplayer crash was only a symptom. Not the cause. The cause seems to be the y4mscaler, but the only debug it gives me is "**ERROR: [y4mscaler] STREAMS ONLY MY FRIEND!". I'm in a loss here.

mplayer -nosound -noframedrop -noautosub -vo yuv4mpeg "VTS_08_1.VOB" | \
y4mscaler -v 0 -I sar 4:3 -O sar=4:3 -O chromass=444 | \
y4mstabilizer | \
y4mscaler -v 0 -O sar=src -O chromass=420_MPEG2 | \
any_encoder_that_takes_stdin

alec_robertson
8th July 2006, 17:57
OK, so the problem is that your mplayer command line dumps to the stream.yuv file rather than to stdout. I hunted around on the mplayer mailing list and found the following solution, which creates a pipe called stream.yuv that mplayer can write to and subsequent mjpegtools commands can access:
mkfifo -m 660 stream.yuv &
mplayer -benchmark -noframedrop -nosound -vo yuv4mpeg VTS_08_1.VOB < /dev/null &
yuvplay < stream.yuv
The yuvplay is just a simple test to make sure the stream coming out is compliant. You can replace it with y4mscaler and the rest of your pipes. The "< /dev/null" is important as mplayer (and ffmpeg too) expects to read from stdin and will hang unless it is redicted as such.

Spotteri
8th July 2006, 22:51
No joy. I still get the same crap:
**ERROR: [y4mscaler] STREAMS ONLY MY FRIEND!

All other mjpegtools filters seem to work, but y4mscaler doesn't (I even reinstalled from different source). With no debug other than that, theres nowhere for me to go.

Are there any other apps that decode to stdout? I already tried mpeg2dec. Same error.

alec_robertson
8th July 2006, 23:53
Hmmm, the following works for me for y4m, mkv/h264 and VOB versions of the same video. I'm using latest cvs/svn versions of mjpegtools and mplayer and y4mscaler v9.0:
mkfifo -m 660 stream.yuv
mplayer -really-quiet -benchmark -noframedrop -nosound -vo yuv4mpeg VTS_01_1.VOB < /dev/null &
y4mscaler < stream.yuv -v 0 -I sar=4:3 -O sar=4:3 -O chromass=444 \
| y4mstabilizer | y4mscaler -v 0 -O sar=src -O chromass=420_MPEG2 \
> stream2.yuv
If that fails, delete the stream.yuv pipe and let mplayer output directly to a file. Then test each step in your chain, outputting to intermediate yuv files along the way. When each step works, try linking it all up together.

Spotteri
9th July 2006, 09:07
Ever had those days you wished you were dead? I found whats wrong... It was a typo. God damned TYPO in the y4mscaler options! Since I kept copy-pasting lines it remained. How I missed it in over 30 code checks is beyond me.

Apparently "**ERROR: [y4mscaler] STREAMS ONLY MY FRIEND!" means "You have an invalid option. Are you perhaps trying to load a file? - streams only please"

Now everything works at first, but...

For reasons I don't understand, the encoding always stops after 169 frames. Even when I wirst re-encode it to lossless format (no error in the original source). No debug again. Mplayer just crashes and I know it's not it's fault. Same thing if I use lav2yuv or mpeg2dec, so it's gotta be the mjpegtools filters again.

I'll look in to it and try to get some debug-reports from somewhere.

EDIT:
Through trial and exclusion, I was able to narrow it down to the y4mstabilizer. Everything works if it is removed. BTW... the succesfully encoded frames keeps alterating from 150-300 depending depending where I start.

alec_robertson
9th July 2006, 16:01
Are you compiling the latest svn/cvs versions of mplayer and mjpegtools?

With the following commands I was able to encode the entire vob (web.mit.edu/alecr/www/cwf/trailer.vob) to h264:
mkfifo -m 660 stream.yuv stream2.y4m
mplayer -really-quiet -benchmark -noframedrop -nosound \
-vo yuv4mpeg trailer.vob </dev/null 1>/dev/null &
y4mscaler < stream.yuv -v 0 -I sar=4:3 -O sar=4:3 \
-O chromass=444 | y4mstabilizer | y4mscaler \
-v 0 -O sar=src -O chromass=420_MPEG2 \
> stream2.y4m &
#yuvplay < stream2.yuv
x="-B 1000 -b 2 --b-pyramid -w --direct auto
-f -2,-2 --progress --no-psnr
-m 5 --me umh -A all -8 -r 2 -t 1"
x264 $x -o stream.mkv stream2.y4m

Spotteri
9th July 2006, 17:43
Are you compiling the latest svn/cvs versions of mplayer and mjpegtools?

With the following commands I was able to encode the entire vob (web.mit.edu/alecr/www/cwf/trailer.vob) to h264:

IT WORKED! I wonder why? Your script was almost identical to the ones I've been bashing for a day now. Another typo? I hope not, or I'm gonna shoot myself :angry:

I'm gonna dig in to this and wonder what you did differently. I haven't tried it yet with the y4mstabilizer-setting i used before, but I don't think it matters.

Thx & Bye for now.

EDIT:
I'm using the latest stables mplayer 1.0pre8, mjpegtools 1.8.0 and y4mscaler 9.0

EDIT2:
It seems that the problem was the y4mstabilizer. When I put my settings in your script, it starts to crash the same way. The "viscosity measure" (-a) is the only one I can change. Others don't tolerate the smallest change (-r or -s). With default setting my scripts work fine too.