mencoder add hard-rendered subtitles on first 20 seconds without re-encoding the rest
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
mencoder add hard-rendered subtitles on first 20 seconds without re-encoding the rest
Hello!
I've tried reading through a number of threads on here about adding subtitles hard into the video stream with mencoder, but most of them are people asking how to do it or having problems. So apologies if this has already been asked somewhere, but I haven't found it yet.
I don't have any problem getting mencoder to add the subtitles. But I only actually want to add a subtitle (for credits) during the first say 20 seconds of the video, and it seems a shame to have to re-encode all the rest just for that.
So I was wondering about different ways to split off the first n seconds of video to render subtitles onto, then join it back on the remainder untouched. Obviously, I would need to use the same parameters to re-encode the bit with the subtitles, but if I try to split the file on a key frame or something like that, would this work OK when I join them back together? Is there any easy way to find the right byte offset of an avi (xvid stream) to split it right on a key frame? Or maybe it doesn't quite work the way I think it does at all?
I don't have a great deal of experience messing with video really, so all advice welcomed...thanks!
It seems obvious now that you spelled it out
Didn't occur to me that mencoder could just join them with -ovc copy, I was thinking I would need to cat the two parts back together so I was overcomplicating the whole thing.
I finally got a chance to test this out today, but I found a slight problem. It seems that -ss will only seek to the next key frame, not the exact position, so in my example file, the first 20 seconds were extracted correctly, but rest_of_movie.avi actually began about 4 seconds later than it should have.
So, is there any way to either:
1) Identify the first key frame located after 20 seconds (for making first_20_sec.avi to the right point)?
-or-
2) Seek exactly to 00:00:20 position (presumably by replaying from the previous key frame instead)?
Perhaps the first way would be best so that the key frames remain evenly spaced? But I can't find any options in mencoder/mplayer to locate the byte offset (as could be used in -endpos) for a suitable key frame point at which to split the file.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.