kaltura / nginx-vod-module

NGINX-based MP4 Repackager
GNU Affero General Public License v3.0
2k stars 439 forks source link

Thumbnails in interlaced video with vod_thumb_accurate_positioning off #1518

Open setnicka opened 8 months ago

setnicka commented 8 months ago

Hello, I am using nginx-vod-module for generating thumbnails for some videos. I'm using vod_thumb_accurate_positioning off; to speed up generating thumbnails by just using keyframes.

It works great with normal mp4 videos. But with an interlaced video, it returns 500 error and this line in the error log:

2024/03/18 17:43:50 [error] 125515#0: *3 thumb_grabber_write_frame: no frames were decoded while processing frames, client: 127.0.0.1, server: , request: "GET /thumb/letterman.mp4/thumb-20000.jpg HTTP/1.1", host: "od28ibf82jf4xjvy5354.push-0.cdn77.com"

Without the vod_thumb_accurate_positioning it generates thumbnails even for interlaced videos but it takes some time to generate them.

Version

I am using version 1.33 of the nginx-vod-module and version 1.24. of the nginx itself. Compiled in this way:

auto/configure --add-module=nginx-vod-module/
make -j

Configuration to reproduce

This is minimal nginx.conf to reproduce:

daemon off;

events {
        worker_connections 65536;
}

http {
    error_log /tmp/error.log notice;

    vod_cache_buffer_size 1024K;

    server {
        listen *:8088;

        location /thumb/ {
            alias /var/www/nginx-vod/;
            vod thumb;
            vod_mode local;
            vod_thumb_accurate_positioning off;
        }
    }
}

Tested on several videos. For example interlaced MP4 video from some thread of the videohelp.com forum:

https://forum.videohelp.com/attachments/56920-1611374890/20090227_233739-H.264.m2ts_1080i_interlaced_letterman_sample.mp4

I have this version saved as letterman.mp4 and a deinterlaced version of the same file as letterman2.mp4 (converted by ffmpeg -i letterman.mp4 -filter:v yadif=0:-1:0 letterman2.mp4). Then testing by curl:

$ curl -sv http://127.0.0.1:8088/thumb/letterman.mp4/thumb-20000.jpg > /dev/null 
> GET /thumb/letterman.mp4/thumb-20000.jpg HTTP/1.1
> Host: 127.0.0.1:8088
> User-Agent: curl/7.82.0-DEV
> Accept: */*
> 
< HTTP/1.1 500 Internal Server Error
< Server: nginx/1.25.4
< Date: Mon, 18 Mar 2024 16:54:59 GMT
< Content-Type: text/html
< Content-Length: 177
< Connection: close

$ curl -sv http://127.0.0.1:8088/thumb/letterman2.mp4/thumb-20000.jpg > /dev/null 
*   Trying 127.0.0.1:8088...
* Connected to 127.0.0.1 (127.0.0.1) port 8088
> GET /thumb/letterman2.mp4/thumb-20000.jpg HTTP/1.1
> Host: 127.0.0.1:8088
> User-Agent: curl/7.82.0-DEV
> Accept: */*
> 
< HTTP/1.1 200 OK
< Server: nginx/1.25.4
< Date: Mon, 18 Mar 2024 16:55:26 GMT
< Content-Type: image/jpeg
< Content-Length: 147965
< Connection: keep-alive
< ETag: "-1-241fd"
< Accept-Ranges: bytes
< 
{ [102208 bytes data]