LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 01-15-2005, 12:49 PM   #1
J_Szucs
Senior Member
 
Registered: Nov 2001
Location: Budapest, Hungary
Distribution: SuSE 6.4-11.3, Dsl linux, FreeBSD 4.3-6.2, Mandrake 8.2, Redhat, UHU, Debian Etch
Posts: 1,126

Rep: Reputation: 58
Mencoder: audio delay when encoding in slices!?


I tried to slice up a dvd into chapters and encode each chapter separately to avi, then merge the avi's again, like this:
# slicing
mencoder dvd://1 -ovc copy -oac copy -chapter 1-1 -o chapter01.mpeg
mencoder dvd://1 -ovc copy -oac copy -chapter 2-2 -o chapter02.mpeg
# encoding the slices
mencoder chapter01.mpeg -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1000 -oac mp3lame -lameopts cbr:br=64 -o chapter01.avi
mencoder chapter02.mpeg -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1000 -oac mp3lame -lameopts cbr:br=64 -o chapter02.avi
# merging
cat chapter01.avi chapter02.avi > chapters01-02.avi
# fixing
mencoder chapters01-02.avi -noidx -avc copy -oac copy chapters01-02.fixed.avi

The problem: there will be an audio delay of cca. 2s inside the merged avi, starting from the original boundary of the two avi's (so, the first half of the avi will be correct, the other half corrupted).
When I play chapter02.avi, there is no audio delay, so the delay may be caused by mencoder, when fixing the merged avi.

Is it a known bug? Is there a workaround?

Last edited by J_Szucs; 01-15-2005 at 12:57 PM.
 
Old 01-17-2005, 02:25 AM   #2
J_Szucs
Senior Member
 
Registered: Nov 2001
Location: Budapest, Hungary
Distribution: SuSE 6.4-11.3, Dsl linux, FreeBSD 4.3-6.2, Mandrake 8.2, Redhat, UHU, Debian Etch
Posts: 1,126

Original Poster
Rep: Reputation: 58
Problem solved.

It turned out that it was actually a mencoder bug that affected the splitting command. But there was a workaround: just add a single mencoder command line option and everything is OK.

So, one can use mencoder for splitting and joining avi's, too.

Last edited by J_Szucs; 01-17-2005 at 02:30 AM.
 
Old 01-17-2005, 02:30 AM   #3
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
and that option would be?
 
Old 01-17-2005, 02:41 AM   #4
J_Szucs
Senior Member
 
Registered: Nov 2001
Location: Budapest, Hungary
Distribution: SuSE 6.4-11.3, Dsl linux, FreeBSD 4.3-6.2, Mandrake 8.2, Redhat, UHU, Debian Etch
Posts: 1,126

Original Poster
Rep: Reputation: 58
-audio-preload 0.0

I just realized that mencoder preloads the audio data during encoding. What is worse: it does not seem to throw away the preloaded, surplus audio-data at the end of the encoding process, but inserts them into the last encoded frame.

You do not notice this when you play the slices: the playback of each slice will be correct.
But, when you merge the slices, the surplus audio data at the end of the first slice will delay the audio data of the second slice by cca. 1s, when you merge the avi slices as described in the mencoder documentation. If you have more slices, then the audio delay will gradually increase all along the merged avi.

Last edited by J_Szucs; 01-17-2005 at 02:53 AM.
 
Old 01-22-2005, 08:58 PM   #5
J_Szucs
Senior Member
 
Registered: Nov 2001
Location: Budapest, Hungary
Distribution: SuSE 6.4-11.3, Dsl linux, FreeBSD 4.3-6.2, Mandrake 8.2, Redhat, UHU, Debian Etch
Posts: 1,126

Original Poster
Rep: Reputation: 58
Problem not solved :-(.

My findings seem to be valid for avi files, only, and not for dvds :-(:

I splitted an avi into 38 parts by mencoder, then I merged them by mencoder again, and I got an audio delay of cca. 19s (which in fact equals to 38 times the 0.5s default audio-preload value).

If I splitted the avi into 38 parts but used the -audio-preload 0.0 switch meanwhile, then there was no audio delay after merging the avi parts.

But: If I split a dvd into chapters, I get several errors like this during encoding of the parts into avi:
a52: CRC error...
Flushing video

Then I always get an audio delay after merging the separately-encoded avi parts.

I wonder why dvds behave differently in this case? Maybe it is a dvd seek problem with mencoder?
 
Old 06-24-2006, 04:18 PM   #6
netpup
LQ Newbie
 
Registered: Jun 2006
Distribution: NetBSD 3
Posts: 2

Rep: Reputation: 0
Arrow force video delay

for mpeg encoding with -mpegopts option, i messed about with init_apts (eg=init_apts=700) and init_vpts (eg init_vpts=100).

works for me using the following:

(other parts of the script are similar, ony ss (start time) and endpos are different... plus i dont use init parts on the first slice)

mencoder -audio-preload 0.0 \
-oac lavc -ovc lavc -of mpeg -mpegopts format=xvcd:init_vpts=700:init_apts=100 -vf \
scale=352:288,harddup -srate 44100 -lavcopts \
vcodec=mpeg1video:keyint=15:vrc_buf_size=327:vrc_minrate=1152:vbitrate=1152:\
vrc_maxrate=1152:acodec=mp2:abitrate=224 -ofps 25 \
-ss 01:00:00 -endpos 02:00:00 -o /disk2/videos/converted/$1.out.2.mpg $1

hope this solves

P

also ... put the result through vcdimager and cdrdao, hey presto a a/v synced vcd

Last edited by netpup; 06-24-2006 at 04:21 PM.
 
Old 06-24-2006, 06:19 PM   #7
theYinYeti
Senior Member
 
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 66
Do you mean you can create a SVCD with several chapters or even several titles this way?

Yves.
 
Old 06-25-2006, 05:30 PM   #8
netpup
LQ Newbie
 
Registered: Jun 2006
Distribution: NetBSD 3
Posts: 2

Rep: Reputation: 0
svcd / vcd

you cn make vcd slice with my code... would have to alter for SuperVCD (format, bitrate and the like).

the main reason for posting was to show a working example (for me anyway) of how you can delay the video slightly when chopping up a video from DVD, AVI or similar source.

which i wanted to do for the purposes of creating VideoCD's for watching stuff on my standalone dvd player, which I now can...

although I have been experiencing some delay in audio near the end of some AVI type movies but i blame the source (ie leeched).
 
  


Reply



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
Audio delay when ripping DVD to AVI with mencoder mikis Linux - Software 2 11-06-2005 05:52 AM
mencoder audio resample mrsolo Linux - Software 0 11-17-2004 11:03 PM
Problem with encoding dvdrips using mencoder/acidrip hari_seldon99 Linux - Software 7 01-29-2004 06:32 AM
Problems encoding DVDs with MEncoder. adz Linux - Software 5 10-26-2003 12:39 AM
mencoder jpeg stream encoding bakuretsu Linux - Software 0 10-10-2002 08:17 AM

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

All times are GMT -5. The time now is 12:03 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