When I creating thumbnails via ffmpeg in video module, it took a long time ( 20minutes for 4 thumbnails in 1 hour video ).
The process of creating in background looks like -
/usr/local/bin/ffmpeg -i '/var/www/vddev/sites/default/rfiles/videos/original/test.flv' -ss '768' -t '768' -an -r '25' -vframes '1' -y /tmp/1339694710-4fda1e7690bd2-%12d.png 2>&1

The thumbnails are creating for example in this time of creation:

sites/default/rfiles/videos/thumbnails/254$ ls -l
total 1716
-rw-r--r-- 1 www-data www-data 402935 Jun 14 18:39 thumbnail-254_0001.png
-rw-r--r-- 1 www-data www-data 389126 Jun 14 18:44 thumbnail-254_0002.png
-rw-r--r-- 1 www-data www-data 355466 Jun 14 18:51 thumbnail-254_0003.png
-rw-r--r-- 1 www-data www-data 598806 Jun 14 18:56 thumbnail-254_0004.png

If i try to execute this comand in comand line it also took a long time, but if i try to execute same command with relocation of "-ss" parameter in the beginning of comand like this :
/usr/local/bin/ffmpeg -ss '768' -i '/var/www/vddev/sites/default/rfiles/videos/original/test.flv' -t '768' -an -r '25' -vframes '1' -y /tmp/1339694710-4fda1e7690bd2-%12d.png 2>&1
It took only 1 or 2 seconds for creating thumbnail.

It is possible to change order of "-ss" as the first parameter in command in module i guess in function extractFrames in file phpvideotoolkit.php5.php located in modules/video/libraries/phpvideotoolkit/ or in file TranscoderAbstractionFactoryFfmpeg.inc located in /modules/video/transcoders

I tried to rewrite this functions but i didn't success in changing order of this parameter, i havent deep experience with drupal modules, can anyone help with this ?

Thanks.

CommentFileSizeAuthor
#6 2009-03_0106_00001.jpg83.3 KBFrankVB123
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

johndewards’s picture

Issue summary: View changes

example of created thumbnails with information of creation time.

Jorrit’s picture

Assigned: Unassigned » Jorrit

I think it is related to the description of -ss:

-ss position (input/output)
           When used as an input option (before "-i"), seeks in this input file to position. When used as an output option (before an output filename), decodes but discards input until the timestamps reach position. This is slower, but more
           accurate.

What version of FFmpeg are you using? I think this got introduced in a recent version of FFmpeg.

Jorrit’s picture

I have another question: what is the file size and time length of your videos?

johndewards’s picture

Thanks for reply,
FFmpeg version - Video transcoder: FFmpeg git: 2012-05-24-36d0f8c
File size of testing videos about 500Mb, lenght about 1 hour, filetypes FLV and MP4 ( both H.264 ).

If i tested creating of thumbnails in command line with "-ss" as first parameter i got the same thumbnails with same accuracy and quality, but the time of creating was just second oposite to using "-ss" parameter after "-i" parameter, where it was minutes.

Jorrit’s picture

Status: Active » Fixed

Fixed in 7.x-2.x-dev.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

FrankVB123’s picture

Status: Closed (fixed) » Active
FileSize
83.3 KB

Hello Jorrit,

as described above, you can only find a performance differance -ss after -i is extremely slowlyer than before -i, but your both results are equal, isn't it?

By using avchd-files, the use of "-ss before -i" delivers only a grey picture-fragment: grey Picture

When I chose the followring command, everything ist ok, but the owfull performanc (> 15 min):
ffmpeg.exe -i "2009-03_0106.m2ts" -s 1920x1080 -ss 00:08:00.00 -f image2 2009-03_0106_00.01.jpg

When I chose the performant command, ffmpeg ist back in a few seconds, but the extracted frame ist only a grey fragment, so you can't detect anything:
ffmpeg.exe -ss 00:08:00.00 -i "2009-03_0106.m2ts" -s 1920x1080 -f image2 2009-03_0106_00.01.jpg

Do you have any idear, how to solfe this Problem (e.g. some other parameters, etc.)?

Here are the video-infos:
FFmpeg version SVN-r25456-Sherpya, Copyright (c) 2000-2010 the FFmpeg developers
built on Oct 14 2010 16:46:15 with gcc 4.2.5 20090330 (prerelease) [Sherpya]
libavutil 50.32. 3 / 50.32. 3
libavcore 0. 9. 1 / 0. 9. 1
libavcodec 52.92. 0 / 52.92. 0
libavformat 52.81. 0 / 52.81. 0
libavdevice 52. 2. 2 / 52. 2. 2
libavfilter 1.51. 1 / 1.51. 1
libswscale 0.12. 0 / 0.12. 0
libpostproc 51. 2. 0 / 51. 2. 0

Seems stream 0 codec frame rate differs from container frame rate: 50.00 (50/1) -> 50.00 (50/1)
Input #0, mpegts, from '2009-03_0106.m2ts':
Duration: 00:08:46.79, start: 1.000033, bitrate: 17339 kb/s
Program 1
Stream #0.0[0x1011]: Video: h264, yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], 50 fps, 50 tbr, 90k tbn, 50 tbc
Stream #0.1[0x1100]: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s
Stream #0.2[0x1200]: Subtitle: pgssub

You say, this Problem "...is Fixed in 7.x-2.x-dev..."
I can't find a newer ffmpeg.exe in the web. May you send me an link to "7.x-2.x-dev".

best regards,
Frank

Jorrit’s picture

When -ss is used before -i, the seconds are skipped with FFmpeg not checking whether the frame that is skipped to is actually a complete frame or a partial frame. With -ss after -i, FFmpeg renders the whole video up and until the requested time and the returned frame is complete.

http://ffmpeg.org/trac/ffmpeg/wiki/Seeking%20with%20FFmpeg offers a method of combining these two methods. I will look into implementing this.

Jorrit’s picture

Status: Active » Fixed

Fixed in 7.x-2.x-dev. You can download a new -dev release within 12 hours.

FrankVB123’s picture

Hello Jorrit,

great - this was the missing hint.

Now, i can extract correct frames in a pereformant way.

I wish you a happy new year ;o))

Best regards,
FrankVB123

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

correction in text ( some mistakes in preview of code ).