VideoHelp Forum
+ Reply to Thread
Results 1 to 21 of 21
Thread
  1. Member racer-x's Avatar
    Join Date
    Mar 2003
    Location
    3rd Rock from the Sun
    Search Comp PM
    I just learned of the Stabilize filter in ffmpeg. I created one that will batch stabilize all MOV's in a folder. Just change input extension in lines 2 and 3 for other types. It's an automated two-step process that first analyses, then processes using codec of choice. It's almost as good as the DeShaker plugin for Virtualdub, but it also has advantages over it like batch processing.

    To use, you'll need latest version of ffmpeg 32 or 64 bit. You'll need to edit the Path to ffmpeg in the first line. Change the input extensions as needed in lines 2 and 3. Then just drag first clip into the batch file and all will be processed.

    Along with the newly created clips, it will produce RTF files (processing information) and a Dummy.avi that shows tracking markers. You can delete these when finished.

    Here is a script that should work OK with most shaky footage:
    Code:
    SET PATH="E:\Backup\Video Apps\Video Encoders\FFmpeg\FFMpeg\64-bit"
    for %%a in ("*.mov") do ffmpeg -i %%a -vf vidstabdetect=shakiness=10:accuracy=15:result="%%~na.trf":show=1 dummy.avi -y
    for %%a in ("*.mov") do ffmpeg -i %%a -vf vidstabtransform=crop=black:input="%%~na.trf" -c:v libx264 -level 41 -pix_fmt yuv420p -g 24 -crf 19 -c:a aac -strict experimental -ar 48000 -ab 256k -f mp4 "%%~na_stab.mp4"
    
    pause
    Here is an example of results:
    Image Attached Files
    Got my retirement plans all set. Looks like I only have to work another 5 years after I die........
    Quote Quote  
  2. Why create an output in the first pass at all?

    Why not use:
    Code:
    -an  -f null  NUL
    instead of
    Code:
    dummy.avi -y
    users currently on my ignore list: deadrats, Stears555
    Quote Quote  
  3. There's something different with the black level on the stabilized side.
    Quote Quote  
  4. Banned
    Join Date
    Oct 2014
    Location
    Northern California
    Search PM
    Can this filer detect single frame horizontal/vertical jitter as you often can see with digitized older films?
    Quote Quote  
  5. Member racer-x's Avatar
    Join Date
    Mar 2003
    Location
    3rd Rock from the Sun
    Search Comp PM
    Originally Posted by Selur View Post
    Why create an output in the first pass at all?

    Why not use:
    Code:
    -an  -f null  NUL
    instead of
    Code:
    dummy.avi -y
    I mistakenly assumed I needed an actual output file. Thanks for that valuable tip.....
    Got my retirement plans all set. Looks like I only have to work another 5 years after I die........
    Quote Quote  
  6. Member racer-x's Avatar
    Join Date
    Mar 2003
    Location
    3rd Rock from the Sun
    Search Comp PM
    Originally Posted by newpball View Post
    Can this filer detect single frame horizontal/vertical jitter as you often can see with digitized older films?
    I didn't see anything in the docs for Rolling Shutter compensation, hence why I said it's almost as good as Deshaker plugin for Virtualdub.
    Last edited by racer-x; 2nd Nov 2014 at 10:19.
    Got my retirement plans all set. Looks like I only have to work another 5 years after I die........
    Quote Quote  
  7. Member racer-x's Avatar
    Join Date
    Mar 2003
    Location
    3rd Rock from the Sun
    Search Comp PM
    Originally Posted by jagabo View Post
    There's something different with the black level on the stabilized side.
    Yes, I know. It seems to be converting from Rec.601 > PC.601. I'm trying to use the -vf colormatrix filter, but can't find the right command.....
    Got my retirement plans all set. Looks like I only have to work another 5 years after I die........
    Quote Quote  
  8. Originally Posted by newpball View Post
    Can this filer detect single frame horizontal/vertical jitter as you often can see with digitized older films?
    Like Stab() in AviSynth? It looks like you might be able to tweak some of the parameters to do that.

    http://www.ffmpeg.org/ffmpeg-filters.html#vidstabdetect-1
    http://www.ffmpeg.org/ffmpeg-filters.html#vidstabtransform-1
    Last edited by jagabo; 2nd Nov 2014 at 06:55.
    Quote Quote  
  9. Member racer-x's Avatar
    Join Date
    Mar 2003
    Location
    3rd Rock from the Sun
    Search Comp PM
    If Rolling Shutter is an issue, you're better off using DeShaker in Virtualdub. It has settings for that directly. My t2i likes 70% compensation for example.

    This is a useful tool to batch process a bunch of shaky source clips from phone or tablet, where quality isn't much concern anyway.
    Got my retirement plans all set. Looks like I only have to work another 5 years after I die........
    Quote Quote  
  10. Rolling shutter usually isn't an issue with film bounce. I've seen it a few times though.
    Quote Quote  
  11. I'm not getting any levels differences with -vf vidstabdetect/vidstabtransform on some quick tests. Something must be different about your example, maybe different libvidstab version ?

    Difficult to preview / make fine tuning , adjustments with ffmpeg - but still can be useful in some situations
    Quote Quote  
  12. Member racer-x's Avatar
    Join Date
    Mar 2003
    Location
    3rd Rock from the Sun
    Search Comp PM
    Originally Posted by poisondeathray View Post
    I'm not getting any levels differences with -vf vidstabdetect/vidstabtransform on some quick tests. Something must be different about your example, maybe different libvidstab version ?
    I believe the source (Canon t2i DSLR) is the culprit here. I normally shoot with tripod / monopod or shoulder-mount and very rarely have a need for video stabilizer. I had to look long and hard through my HDD for shaky footage and found a couple from my t2i hand-held shots.

    Just to test, I shot some shaky video with my Tablet and indeed it retained black and white levels. Interestingly the video was AVC with a .3gp extension, not a problem for ffmpeg though......
    Got my retirement plans all set. Looks like I only have to work another 5 years after I die........
    Quote Quote  
  13. Originally Posted by racer-x View Post
    I believe the source (Canon t2i DSLR) is the culprit here.
    Doesn't the Canon shoot full range YUV instead of video range (16-235) ?
    Quote Quote  
  14. It has a full range flag. So it depends on what software / decoder combination you are using, and whether or not flag is acknowledged

    But if you were using ffmpeg for both before / after it should be the same
    Quote Quote  
  15. Member racer-x's Avatar
    Join Date
    Mar 2003
    Location
    3rd Rock from the Sun
    Search Comp PM
    Well here is a test clip you can try from my t2i. I actually shot it on a tripod, but the wind in conjunction with the 300 mm lens made it shake a lot. I can't get the same color levels before and after. See what you can get.
    Image Attached Files
    Got my retirement plans all set. Looks like I only have to work another 5 years after I die........
    Quote Quote  
  16. I didn't download your video, but I tested with my own from a 7d, I can confirm levels are clamped in the output file. I'll take a closer look and try to suggest a workaround

    But on one hand, clamping makes everything "legal", how would you prefer to do it ?

    ffmpeg is one that distinguishes the full range flag (it reads it as yuvj420p, the "j" being full range), but other decoders like quicktime clamp it to 16-235
    Quote Quote  
  17. Member racer-x's Avatar
    Join Date
    Mar 2003
    Location
    3rd Rock from the Sun
    Search Comp PM
    Yes, reading the ffmpeg log, it sees the input as yuvj420p(pc, smpte170m), 1920x1080. It looks like it is opening it up to full range.
    Got my retirement plans all set. Looks like I only have to work another 5 years after I die........
    Quote Quote  
  18. Also, currently there is no way for ffmpeg to encode full range and flag it properly with x264 (assuming someone wanted to encode full range for whatever reason, and flag it properly). It's one of the various things missing from ffmpeg libx264 compared to x264.exe . (Neither -x264-params , or -x264opts in ffmpeg can call these options )

    IMO, working in full range is fine, as long as the final output is normal range. You are asking for trouble if final format is full range . Very few players and setups are configured properly for full range. And only 1 renderer can handle it properly (madvr) automatically
    Quote Quote  
  19. Another observation:

    1) The usual "workaround" for people wanting to encode full range properly is using a raw pipe from ffmpeg to x264 ; and use x264 with --input-range pc --range pc. This works fine with DSLR MOV's , full range MJPEG's etc...

    However, something looks like it's clamping as soon as you use -vf vidstabtransform. If I remove that filter, full range is encoded as normal with the pipe. So something is up with that filter. I'll look into it more
    Quote Quote  
  20. Ok if anyone is interested (...crickets.... ) in keeping full range and flagging it properly while using -vf vidstabtranform , there is a convoluted workaround:

    (for this purposes, I will post single, not batch cmd lines)

    1) strip the full range flag with mp4box (audio has to be muxed at a later stage, because mp4box has problems with PCM in MP4. I'll leave that for another discussion, but you can use 2 inputs with stream mapping)

    The mp4box build used has to have the golgol patch (offical builds do not)
    http://komisar.gin.by/tools/

    Code:
    mp4box -add input.mov:fullrange=off -new stripped.mp4
    2) pipe ffmpeg to x264, note the rawpipe is yuv420p now, not yuvj420p . But we treat the data in x264 as full range

    Code:
    ffmpeg -i stripped.mp4 -an -r 24000/1001 -vf vidstabtransform=crop=black:input="data.trf" -f rawvideo -pix_fmt yuv420p - | x264 --demuxer raw --input-res 1920x1080 --input-csp i420 --input-range pc --range pc --fps 24000/1001 -o output.mp4 -



    Anyways, nobody should be doing that IMO will full range, we should be evaluating how vidstabtranform actually performs compared to others... so carry on....
    Quote Quote  
  21. just registered to say thank you selur and specially THANK YOU monsieur {el pollito} RACER-X {the crowd's mad on ecstasy!!!}
    http://www.personal-view.com/talks/discussion/11519/mac-free-apps-tips-and-tricks
    not dead allgood
    maxr
    Quote Quote  
Visit our sponsor! Try DVDFab and backup Blu-rays!