Open mazanov opened 7 years ago
Sorry, just noticed I didn't reply to this one.
Technically, it is possible to implement what you suggest, however it may be problematic in multiple bitrate scenarios - unless special care is taken during the encoding process, different renditions may have different key frame positions. For example, we are forcing a key frame every 2 seconds, but we leave it up to the encoder to decide whether and where to create additional key frames. If different renditions have different key frame positions, in your suggestion, segment 100 in rendition A may be very different from segment 100 in rendition B, and I'm quite sure some players will not handle it well (even though the player is 'supposed' to align the renditions based on timestamps and not on segment indexes...) Either way, this is not a small change, the module assumes in many places that the segment duration is (roughly) known, and in more complex cases (e.g. playlist) it's even more problematic (it will have to load all previous videos to figure out how to build a specific segment). So, at the moment we won't be adding this feature.
Hello, Thanks for answer! I have special checking process that all keyframes in all ABR renditions are placed at the same positions. It is because in HLS and DASH standards every segment must be started from keyframe and keyframes must be aligned between renditions. If not, players will not be possible to properly switch between renditions and make video seeking. And that's why I can work only with vod_align_segments_to_key_frames on. And all is ok until I have to work with videos with integer fps (like 24/25/30) and with fractional fps (like 23.97/29.97) at the same time. I have to use different vod_segment_duration to integer and fractional fps videos. Or to encode fractional fps videos to nearest integer fps (make 24fps from 23.97, 30fps from 29.97 and so on). Both ways are quite hard to implement on a big system with huge video library. It'll be good if you'll keep in mind this problem and may be it'll be solved in future. Thank you!
If it helps, we will most likely change vod_segment_duration
soon to accept nginx variables, so you may be able to solve it with that - e.g. populate the value using some lua code based on the media info that is fetched from some database or upstream server (not sure ngx_lua can populate vars based on something async like upstream request, but maybe).
Also, to clarify, we are transcoding the files with forced keyframes every 2 sec, and we are always using segment durations that are multiple of 2 sec, so all of our segments start with a keyframe. But the way we are doing it, it is still possible that rendition A will have a KF at offset 3 sec, while rendition B will not. This should not cause any problem in seeking / bitrate switching.
Using nginx variables in vod_segment_duration seems to solve the problem. Not the best way but better than to re-encode all videos. And may be the better way will be to set vod_segment_duration in JSON, like this:
{
"sequences": [
{
"clips": [
{
"type": "source",
"path": "/path/to/video.mp4",
"vod_segment_duration": 4000
}
]
}
]
}
It will be more efficient than using additional requests to database or upstream. And you will be able to make all needed calculations for more complex cases (e.g. playlists) using vod_segment_duration from JSON or a default value from nginx conf.
I have huge library with different frame rates videos - 25fps, 30fps, 24fps, 23.97fps, 29.97fps and so on. All those videos are encoded with fixed gop size = 8 seconds. Nginx-vod-module configuration is: vod_segment_duration XXXX; vod_align_segments_to_key_frames on; vod_manifest_segment_durations_mode accurate; I'm trying to tune vod_segment_duration XXXX to different values to get all videos to be cutted to segments on each I-frame, but with no success. Setting vod_segment_duration to different values I get empty segments, or segments with double vod_segment_duration (containing 2 GOPs in them), or both of them. Is it possible to tune nginx-vod-module to cut segments on each I-frame in my case (for videos with different frame rates)? Maybe you can add a setting like cut_on_iframes X, and when X is 1 segments will be cutted on each I-frame, when 2 - on each second I-frame, when 3 - on each third I-frame and so on.