Topic: Video Editing - scanning large files for occurances of a sol
no photo
Tue 07/05/11 09:43 AM
Edited by massagetrade on Tue 07/05/11 10:33 AM
Video Editing - scanning large files for occurances of a solid white screen:

I have a DVD that includes something like 800 or so clips that I am studying. It is very easy to break the videos into individual files that match those clips, if you know the time stamps for the beginning/end of each clip.

I processed about 150 of the clips already by sitting down and watching the video, pressing the 'lap' button on a software stopwatch, and using that list of time stamps in a script.

Now I want to skip the 'watch the video and press the lap button' step, and automate the whole process.

Each clip is separated from the one before and after by a transition that includes a completely white screen.

It seems like it should be very easy for software to scan the video file and recognize when that happens. I'm tempted to look into video file data formats, and figure how to code this myself. But: I'm sure there already exists a tool that can do this for me- if only I knew where to look for it.

Its not like it would be called 'White Screen Recognizer'. It might be something that gives you 'color histogram as a function of time' output, or that will 'scan for frames that exactly match the given frame', or 'note frames that are exactly identical to the previous frame', or 'given a particular collection of pixels, note when those pixels have certain qualities'. There are a lot of different ways this could work, and that function isn't likely to be the main function of the tool, making searching difficult. And since I'm not aren't already versed in the tools it could take me forever to find the right one.

Any ideas? suggestions? free tools I should look at? Has anyone done this before? Feeling bored and better at googling than I?

Has anyone here ever written software intimate with the data in a video file?




no photo
Tue 07/05/11 05:57 PM
8 hrs and only 12 views?

no photo
Tue 07/05/11 07:35 PM
Edited by Peter_Pan69 on Tue 07/05/11 07:38 PM
http://search.yahoo.com/search;_ylt=A0oG7m_AyRNO8j0A2QBXNyoA?ei=UTF-8&fr=yfp-t-701&p=scene+detection+algorithms&SpellState=&fr2=sp-qrw-corr-top




You may want to look into the "bitrate" detection. A completely white scene should be easy to detect by that...




no photo
Tue 07/05/11 11:23 PM

http://search.yahoo.com/search;_ylt=A0oG7m_AyRNO8j0A2QBXNyoA?ei=UTF-8&fr=yfp-t-701&p=scene+detection+algorithms&SpellState=&fr2=sp-qrw-corr-top

You may want to look into the "bitrate" detection. A completely white scene should be easy to detect by that...



Thanks, Peter_Pan. You've inspired me to be more proactive in searching for options, and I've discovered the following feature of the utility lav2yuv:


The -S -T -D options are used for scene detection which is used by linux video studio.

-S list.el
Output a scene list with scene detection

-T num
Set scene detection threshold to num (default: 4)

-D num
Width decimation to use for scene detection (default: 2)



This may be all that I need, but it will be a while before I can test it out.

Assuming this works, my next thought is: How can I be even lazier still? Instead of getting that scene list, converting it to the timestamp list I've already scripted for, and running the scripts.... I bet there's a tool that automatically chops up a video based on detected scene changes?

Anthony_Marx's photo
Tue 07/05/11 11:33 PM
Edited by Anthony_Marx on Tue 07/05/11 11:43 PM
Since you beat me to the post, try 'Key-frame extraction' for your second question.

no photo
Thu 07/07/11 06:40 PM
I finally found some time to work on this. Naturally, lav2yuv doesn't work on DVD formats, and while I'm not sure yet how much of the DVD data I will want sliced up into scenes, it could be as much as 8gb. First to convert, then to scene detect, then to use that info for slicing and conversion. Not very efficient. :(

I've started a conversion of one of the files to the needed format with ffmpeg, but I'm still hoping for a more graceful, efficient, and easy solution.

I notice that ffmpeg has the option sc_threshold, which is for scene detection but the man page is basically useless for figuring out how to use it.

Anthony: I took a few minutes to google for keyframe extraction, and was impressed with some of the demos I saw on the web. I didn't find any free utilities that would help me.

When I have more time I'll follow up on all of the above leads, but I am still interested in hearing from anyone who has done this before (using free tools).

no photo
Fri 07/08/11 03:16 PM
Failing to find a good explanation for the parameters of lav2yuv, I scripted it run 160 times with 160 different combinations of parameters, queried the # scenes detected with each run. (Turns out it won't even take floating point values - integers only for the scene detection threshold and width decimation. )

None of them were anywhere close to the actual number of scenes I determined by watching the video with a lap-counter.

There should be a shortcut to this process. I don't need any complicated comparison-based scene detection algorithm, I just need to locate all the freaking entirely white screens. This should be so easy.

I could even work with detecting when a few pixels in the center all go white simultaneously. Blech.

no photo
Fri 07/08/11 08:42 PM
So I can't figure out exactly how to use and fine tune sc_threshold and sc_detect for ffmpeg, and I keep reading that its not reliable. I read about blackdetect, a ffmpeg filter used to locate commercial breaks, but its not included in my version of ffmpeg. I looked into compiling it but its a hassle for a tool that likely won't work.

Finally, I just decided to break the entire video file into still frames:

ffmpeg -i myfile -r 4 output.image.%d.jpg

Then I use one of the imagemagick utilities, 'identify' to get info on color statistics for each file. It looks like one of those values only gets large when the screen goes white, so I wrote a script that checks that value for each file and prints a list of times (since the file name number is proportional to the time of the frame) that the value exceeds a threshold.

On the first run, it says there are 171 such screen transitions. I counted 167. This is *way* better than lav2yuv did, and I haven't yet looked for the cause of the discrepancy, could be easy to fix.

If anyone ever has to do something similar and wants help, I'll be glad to explain in more detail.

And, I would still love to hear about any tools that automatically slice videos in a way that would help me here, or have better, more controllable scene change detection approaches.

I'm quite grateful to the good people who wrote ffmpeg, lav2yuv, imagemagick, and linux.


donthatoneguy's photo
Wed 07/13/11 08:05 PM
These may be obvious questions, but ... Is this a created DVD or an actual movie? Did you account for any logo clips before the feature or following the credits that may explain your discrepancy?

Totage's photo
Wed 07/13/11 08:19 PM
I have a ton of video editing products on my site.

I was skimming through it just now and found this, it may have what you're looking for. You can download a free trial to see if it suits your needs.
http://totage.co.cc/product_detail.php/pid/19697-55/pa/3herosoft-DVD-Creator

You can browse more here.
http://totage.co.cc/search_result.php/cp/1/kw/DVD%20video%20editing

no photo
Thu 07/14/11 10:22 PM

These may be obvious questions, but ... Is this a created DVD or an actual movie? Did you account for any logo clips before the feature or following the credits that may explain your discrepancy?


Wow, I had forgotten that I never resolved the small discrepancy. I've been working on some other projects, and I considered this basically 'solved', I just need the time to implement the solution.

I'm not working directly with the actual DVD - I copy a few of the files from the DVD, then I cut them to the piece that I need, then I shrink it and do the rest listed above. The segment being analyzed is the exact same as the one that I watched with a lap counter - oh, and there is a textbook that goes with the dvd which was used to confirm my lap-counter count.

I'm pretty sure I can solve the discrepancy by using more frames per second and changing the threshold (fingers crossed), though I may not come back to that for a another week or two. And just to answer your actual question: its a professionally published instructional dvd.

no photo
Thu 07/14/11 10:23 PM

I have a ton of video editing products on my site.

I was skimming through it just now and found this, it may have what you're looking for. You can download a free trial to see if it suits your needs.
http://totage.co.cc/product_detail.php/pid/19697-55/pa/3herosoft-DVD-Creator

You can browse more here.
http://totage.co.cc/search_result.php/cp/1/kw/DVD%20video%20editing


Thanks!

Totage's photo
Fri 07/15/11 12:36 AM
You're welcome. Did you find something that works for you?