kaltura / nginx-vod-module

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

clipFrom / clipTo don't work with mapped mode #1215

Open freddygood opened 4 years ago

freddygood commented 4 years ago

Hello, could you point me what am I doing wrong or if the feature even supported?

I have two modes enabled in the config - remote and mapped and I'd like to use clipping

Requesting file directly like https://host.net/packager/channel/file-123456-480p.mp4/clipFrom/60000/clipTo/70000/index-v1-a1.m3u8 works fine and responds with two chunks instead of 305

Requesting smil with converting it to mapped JSON always responds full set of chunks. URL looks like https://host.net/packager/channel/0987654322.smil/clipFrom/60000/clipTo/70000/index-f1-v1-a1.m3u8 in this case.

Btw if I use /clipFrom/60000/clipTo/60000/ the module throws an error because numbers are the same so the feature seems enabled.

Nginx config is here:

server {
    listen 80;
    listen 443 ssl;

    server_name host.net;
    ssl_certificate     /etc/letsencrypt/live/host.net/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/host.net/privkey.pem;

    # vod settings
    vod_last_modified 'Sun, 19 Nov 2000 08:52:00 GMT';
    vod_last_modified_types *;
    vod_proxy_header_name X-Packager;
    vod_base_url "";
    vod_segments_base_url "";

    location /packager {
        add_header Access-Control-Allow-Headers '*';
        add_header Access-Control-Expose-Headers 'Server,range,Content-Length,Content-Range';
        add_header Access-Control-Allow-Methods 'GET, HEAD, OPTIONS';
        add_header Access-Control-Allow-Origin '*';
        expires 1y;

        ### DIRECT request
        location ~ .*\.(mp4|mp3)/.*$ {
            vod_mode remote;
            vod_upstream_location /proxy;

            vod hls;
            vod_segment_duration 6000;
            vod_align_segments_to_key_frames on;
            vod_hls_master_file_name_prefix playlist;
        }

        ### SMIL request
        location ~ .*\.smil/.*$ {
            vod_mode mapped;
            vod_upstream_location /smil;
            vod_remote_upstream_location /proxy;

            vod hls;
            vod_segment_duration 6000;
            vod_align_segments_to_key_frames on;
            vod_hls_master_file_name_prefix playlist;
        }
    }

    location /proxy {
        proxy_read_timeout 600s;
        proxy_send_timeout 600s;
        proxy_pass https://cloud-object-storage;
    }

   location /smil/ {
        proxy_pass https://cloud-object-storage;
    }
}

Should this configuration work properly?

interlark commented 4 years ago

I remember I had the similar issue and also would like to know if it's a bug or is there something else.

erankor commented 3 years ago

This is not supported

interlark commented 3 years ago

@erankor, you mean there is no support for clipping at all?

erankor commented 3 years ago

There is support for clipping inside the JSON (clip duration + the clipFrom param on the source object), and there is support for clipping simple mapping JSONs using URL parameters. There is no support for clipping complex JSONs using URL parameters. Technically, it can be done, it's similar to the clipping of the live window, but currently it does not exist.

interlark commented 3 years ago

@erankor, I've got vod-module in mapping mode (here's nginx config | here's demo json file) and when I try get a clip with urls like "http://192.168.0.123:1234/hls/demo/clipFrom/60000/clipTo/70000/master.m3u8" or "http://192.168.0.123:1234/hls/demo/clipFrom/60000/clipTo/70000/index-f1-v1-a1.m3u8", I always get full chunked list. Is that means I have a complex demo json?

erankor commented 3 years ago

Yes, simple JSON = a JSON with a single source clip (https://github.com/kaltura/nginx-vod-module#simple-mapping), in your case there are 2 sequences.

interlark commented 3 years ago

@erankor, so just "video" is a simple JSON, but "video+subtitles" is a complex JSON, that's the problem. Now I got it, thank you.

erankor commented 3 years ago

Not necessarily, if you use multiurl with 2 JSONs instead of a single JSON, you can clip video+subs