Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync with ffmpeg #1554

Open
gstrat88 opened this issue Jan 8, 2025 · 6 comments
Open

Sync with ffmpeg #1554

gstrat88 opened this issue Jan 8, 2025 · 6 comments

Comments

@gstrat88
Copy link

gstrat88 commented Jan 8, 2025

If I try to cut from ffmpeg using time input from the playback,
e.g bring me the 10second to 25second part of the video
ffmpeg -ss 10 -i test.mp4 -t 15 -c copy out.mp4
there are sometimes small time differences, which is propably normal!
Do you know if its possible to emulate the timings of ffmpeg to that of the module?

Thanks a lot!

@erankor
Copy link
Contributor

erankor commented Feb 8, 2025

Hi, sorry for the delay, the differences you are seeing may be because ffmpeg uses the "presentation time" (PTS), while this module uses the "decoding time" (DTS). You can check the DTS/PTS values of the frames using ffprobe, e.g. ffprobe -i test.mp4 -show_frames, and see if that explains the differences you are seeing.
Either way, the clipping feature of this module can only start a clip from a keyframe, while ffmpeg can also re-encode the video, and start a clip from any frame (that is not the case in the sample command you pasted, which uses codec copy, but in general...)

@gstrat88
Copy link
Author

gstrat88 commented Feb 8, 2025

Many thanks for the answer! No problem for the delay it was a busy month for me too.
It should have crossed my mind by looking the code that this sould be the issue, as I am aware of the pts/dts thing.

ffmpeg -i test.mp4 -c:v libx264 -filter:v "trim=start_pts=1584001492967:end_pts=1584001514967000" out.mp4
This would be a nice solution (if it accepts dts of cource) for my problem, but the filter means re-encoding :(
If I dont find another solution, do you happen to know any alternatives to ffmpeg that use dts? (difficult I know)
If I dont find another solution, I will try to make the modification in the module's source code for the thumb part.
If you believe that this won't work for any reason it would be nice to know!

@erankor
Copy link
Contributor

erankor commented Feb 15, 2025

The question is about thumb? because you didn't mention it in the original post...
If so - when I implemented our live packager, I noticed that the thumb capture logic that I originally implemented here was not accurate. You can see the revised implementation here - https://github.com/kaltura/media-framework/blob/master/nginx-pckg-module/src/media/thumb/thumb_grabber.c

@gstrat88
Copy link
Author

gstrat88 commented Feb 15, 2025

Yeap, I am talking for the thumb grabber mainly, as this is the point of reference.
Someone has to mark something using the frames, and the ffmpeg should be synced with it.
The video sync is not so important, for my case.

So do you suggest to try to emulate the nginx-pckg-module thumb grabber into the vod module and then check what happens?

I did not mention the thumbs in the beginning because by changing the configuration, I found a way to have video + thumbs synced, so I thought it was the same "seeking" mechanism.

@erankor
Copy link
Contributor

erankor commented Feb 17, 2025

Yes, I think the thumb logic nginx-pckg-module is much more accurate. But it may require additional changes, because in the live framework, the packager (nginx-pckg-module) sends a param in the request to the segmenter (nginx-live-module) that returns only the frames of the relevant GOP (NGX_KSMP_FLAG_MEDIA_MIN_GOP). A similar logic will need to be added here.

@gstrat88
Copy link
Author

gstrat88 commented Feb 17, 2025

OK, I will try to give it a look in the next two weeks! Untill then, the mjpeg produced from ffmpeg will do the job :)
Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants