LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This 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


Reply
  Search this Thread
Old 07-13-2010, 05:14 AM   #1
wdaniels
LQ Newbie
 
Registered: Jul 2010
Posts: 6

Rep: Reputation: 0
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!
 
Old 07-14-2010, 08:52 PM   #2
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,137
Blog Entries: 6

Rep: Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826
Code:
mencoder movie.avi -endpos 0:00:20 <add your stuff here> -o first_20_sec.avi
will get you the first 20 seconds of the video to a file. Use the rest of the parameters that you want to.

Code:
mencoder -ss 0:00:20 -oac copy -ovc copy movie.avi -o rest_of_movie.avi
will get you the rest of the movie untouched to a file.

Then join them together
Code:
mencoder -oac copy -ovc copy -o "joined.avi" "first_20_sec.avi" "rest_of_movie.avi"

Last edited by teckk; 07-14-2010 at 09:09 PM.
 
Old 07-16-2010, 11:24 AM   #3
wdaniels
LQ Newbie
 
Registered: Jul 2010
Posts: 6

Original Poster
Rep: Reputation: 0
Great, thank you!

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.

Cheers!
 
Old 08-18-2010, 12:10 AM   #4
wdaniels
LQ Newbie
 
Registered: Jul 2010
Posts: 6

Original Poster
Rep: Reputation: 0
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.

Can anybody help me here?
 
  


Reply

Tags
mencoder, subtitles



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
hdparm power save, 15 seconds of spin, 5 seconds of rest... Romanus81 Linux - Laptop and Netbook 1 01-01-2009 05:24 PM
MEncoder does not hardcore subtitles nazarioz Linux - Software 1 01-05-2008 10:40 PM
[mencoder] subtitles size Hyakutake Linux - Software 1 05-01-2007 05:05 PM
mencoder and subtitles help ZeroKun Linux - Software 0 07-19-2005 10:36 AM
Subtitles in Mencoder gwroy20 Linux - Software 2 05-15-2003 04:55 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration