LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General > LinuxAnswers Discussion
User Name
Password
LinuxAnswers Discussion This forum is to discuss articles posted to LinuxAnswers.

Notices

Reply
 
Search this Thread
Old 11-06-2004, 01:43 PM   #151
wapcaplet
Guru
 
Registered: Feb 2003
Location: Colorado Springs, CO
Distribution: Gentoo
Posts: 2,018

Original Poster
Rep: Reputation: 48

Quote:
Mysil2 writes:
I have a question. Because I have an avi-file that is getting unsynced when encoding to mpg.
I think the reason is because the sound begin about 1.25 secs after the video. So in the avi, it's synced, but not when it's encoded.
Out-of-sync video is the biggest problem I'm trying to solve. Sometimes the sync problem can be fixed during multiplexing, but only if the audio and video are off by the same amount throughout the video. In my experience, this almost never happens - the sync problems usually seem to be caused by too-fast or too-slow video. When the frame rate is reported wrong, or is variable, there are problems.

In theory, however, if mplayer can play the original version correctly, then there has to be some way to convert it correctly. My goal is to make tovid's output exactly match what you would see and hear if you played the original file in mplayer (disregarding denoising/resizing). Sounds easy, right? Not really.

In the meantime, if you think your output video is out of sync by the same amount throughout the video, you can do the following:

Edit the tovid script, and comment out these two near the bottom (lines 675 and 676 in Version 0.14):

Code:
rm "$OUT_PREFIX.$SUF"
rm "$OUT_PREFIX.mpa"
Then, encode normally. When encoding completes, you will have a .m2v (or .m1v) and .mpa file. You can multiplex these together manually, and try to adjust sync, using this command:

Code:
mplex OutName.m2v OutName.mpa -o OutName.mpg -f 8 -O 1234ms
Use '-f 8' for DVD, '-f 1' for VCD, '-f 4' for SVCD. In place of '1234ms', use the amount of milliseconds that you think they are out of sync by. I think this is an audio delay, so 1500ms would make the audio come 1.5 seconds later. You can use negative numbers if it goes the wrong way.
 
Old 11-06-2004, 05:25 PM   #152
Mysil2
LQ Newbie
 
Registered: Oct 2004
Location: Norway
Distribution: Fedora Core 2
Posts: 22

Rep: Reputation: 15
Thank you very much it worked!

And just in case someone who have the same problem as me and discovers this thread, the file was episode 4 in season 4 of Smallville. And to my human-senses, it seems like the manual sync-value should be "-O -1435ms" for this file

Last edited by Mysil2; 11-06-2004 at 05:41 PM.
 
Old 11-06-2004, 07:10 PM   #153
sk545
Member
 
Registered: Aug 2002
Posts: 312

Rep: Reputation: 30
cool.

I think that info should be on the tovid webpage somewhere, cause you know its a a problem that will pop up more than anyone wants it to.

Where did you get the smallville episode? tvtorrents.net, suprnova.org? I want the exact name of it since there are couple of different ones (HDTV, vcd, etc). Then i will try it and see if i get the sync problem too.
/edit: nevermind, i am sure it was the HDTV one since thats the only one thats a .avi.

Thanks.

Last edited by sk545; 11-06-2004 at 07:17 PM.
 
Old 11-06-2004, 10:05 PM   #154
sk545
Member
 
Registered: Aug 2002
Posts: 312

Rep: Reputation: 30
A few interesting apps at kde.apps:

http://www.libsdl.de/projects/konverter/

http://www.kde-apps.org/content/show.php?content=16439

http://www.kde-apps.org/content/show.php?content=9706

Not sure if they are dead or not, but one thing is clear: The gui's are way more complex than they should be.
 
Old 11-07-2004, 10:38 AM   #155
sk545
Member
 
Registered: Aug 2002
Posts: 312

Rep: Reputation: 30
I can confirm that smallville had the out of sync problem. This was the first time i noticed it with tovid, tcprobe gives the following:

$ tcprobe -i smallville.s04e04.hdtv-lol.avi
[tcprobe] RIFF data, AVI video
[avilib] V: 23.976 fps, codec=XVID, frames=61044, width=624, height=352
[avilib] A: 48000 Hz, format=0x55, bits=0, channels=2, bitrate=122 kbps,
[avilib] 106050 chunks, 39085224 bytes, VBR
[tcprobe] summary for smallville.s04e04.hdtv-lol.avi, (*) = not default, 0 = not detected
import frame size: -g 624x352 [720x576] (*)
frame rate: -f 23.976 [25.000] frc=1 (*)
audio track: -a 0 [0] -e 48000,0,2 [48000,16,2] -n 0x55 [0x2000] (*)
bitrate=122 kbps
length: 61044 frames, frame_time=41 msec, duration=0:42:26.043


Thats also the first time i have encoded a xvid video with tovid, dunno if that matters.
 
Old 11-07-2004, 12:58 PM   #156
wapcaplet
Guru
 
Registered: Feb 2003
Location: Colorado Springs, CO
Distribution: Gentoo
Posts: 2,018

Original Poster
Rep: Reputation: 48
I've had a minor victory. It hasn't been tested too much yet, but I went back on my previous statement that I wouldn't use mencoder to encode MPEG; I've managed to get mencoder to output mpeg1 and mpeg2 video. I've figured out some of the reasons it was flaky before (wrong framerate format, for one: it will accept "30000/1001" but not "29.97") and it seems to have stabilized now. Mencoder is doing all resizing, letterboxing, frame rate adjustment, denoising, and encoding with a single command. No FIFOs or piping.

Advantages:
  • Significantly faster encoding time. For the 30-second DVD clip, new approach: 58 seconds; old approach: 1 minute 37 seconds.
  • Smaller file size. A 30-second DVD-format video encoded with tovid 0.14 was 12MB; the same video, same format encoded with the new method is 4.8MB. It remains to be seen whether this will apply in general, though.
  • Less complexity. The script is now about 80 lines shorter. yuvfps, yuvscaler, and mpeg2enc are not used at all now. mp2enc is still used to encode audio, and mplex is still used for multiplexing, so the mjpegtools dependency remains.
  • This theory is untested, but the new approach should resolve all framerate and sync problems. The -fps and -twopass options will not be needed any more.

Disadvantages:
  • Quality is very slightly, almost imperceptibly worse. I could only tell the difference by comparing individual frames at extreme close-up. This might be solved by additional quality-enhancing options.

I know it sounds too good to be true, and it just might be - I've only tested it so far on a couple video clips. The alterations to the script are so severe, I don't think I can safely introduce this as an encoding option to future versions; if any of you would like to help me test it, email me (wapcaplet99 at yahoo dot com) and I will send you a copy. If it tests out okay, this will become the basis for version 0.15.
 
Old 11-07-2004, 02:29 PM   #157
sk545
Member
 
Registered: Aug 2002
Posts: 312

Rep: Reputation: 30
well, thats not much in terms of disadvantages, lol. YGM.
 
Old 11-07-2004, 03:34 PM   #158
Steel_J
Member
 
Registered: Oct 2004
Location: Montreal, Canada
Distribution: Kubuntu 10.04, Mint 8 and Puppy 4.3.1
Posts: 355
Blog Entries: 1

Rep: Reputation: 31
Review of DVDDUP

Well I went over the script DVDDUP, created to copy DVD's that Wapcaplet sent to me.

It seems to to the exact same thing my method does, except for 2 things that annoy me a bit.

1) I have 5 dependencies for my script. He has 9.

2) His ripping and shrinking method is way slower than mine. The scripts warns that the process will take a few hours to complete. My method takes around 5 min to rip, 15 min to shrink and 20-25 min to burn a 2x speed. So It's around 45 minute for good quality.

Big difference.

The script is very well structured though and well documented. I might use some of it's structure features to make my script more understandable.

I will keep my original plan and keep fast and simple.
 
Old 11-07-2004, 04:59 PM   #159
sk545
Member
 
Registered: Aug 2002
Posts: 312

Rep: Reputation: 30
Interesting...lets see what you got cookin soon.
 
Old 11-07-2004, 10:01 PM   #160
wapcaplet
Guru
 
Registered: Feb 2003
Location: Colorado Springs, CO
Distribution: Gentoo
Posts: 2,018

Original Poster
Rep: Reputation: 48
As I suspected - too good to be true. After some more testing, here are some additional disadvantages to using mencoder for encoding:
  • Frame rate problems are not fixed; in fact, they're substantially worse.
  • There is no way to control the output bitrate. vbitrate, vrc_maxrate, vrc_minrate, and vrc_eq=1 (explicitly specifying constant bitrate) all seem to be totally ignored when encoding to mpeg1 or mpeg2. Makes VCD impossible, since it must be 1150kbps; can't control quality of other formats either.
  • Output aspect ratio is wrong, even when it's explicitly specified. Aspect ratio always ends up as 1:1 (though it still sometimes plays back correctly).
  • Other header info is either not written or incorrectly specified; resulting files are reported with 0 bitrate, 0 duration, 0.0 aspect ratio.
  • Copious quantities of cryptic error messages in some cases.

So, clearly, faster encoding and smaller files are not worth all this. Back to the drawing board
 
Old 11-08-2004, 08:02 AM   #161
sk545
Member
 
Registered: Aug 2002
Posts: 312

Rep: Reputation: 30
ah.
 
Old 11-08-2004, 09:56 PM   #162
wapcaplet
Guru
 
Registered: Feb 2003
Location: Colorado Springs, CO
Distribution: Gentoo
Posts: 2,018

Original Poster
Rep: Reputation: 48
I recently found out that mpeg2 audio is against the DVD standard for NTSC. I've been using it all this time, assuming it was okay (since it worked in my DVD player). NTSC players are only required (by the standard) to have AC-3 decoders, while PAL players are only required to have MP2 audio decoders. Looks like another small wrinkle in the PAL/NTSC conversion.

It's probably not a very big deal, but I've decided to try going with AC-3 audio for NTSC. Some nice advantages to AC-3: mencoder is able to decode Dolby surround from stereo audio files that contain it, and can also generate a subwoofer channel from the existing audio. MP2 can supposedly contain 5.1 surround, but mp2enc does not support encoding of it. Best of all, for normal stereo audio, AC-3 is the same bitrate as MP2 (at roughly the same quality, I assume; 192kbps is considered adequate, while I've been using 224kbps for MP2 all this time).

No other exciting news right now.
 
Old 11-08-2004, 10:22 PM   #163
Steel_J
Member
 
Registered: Oct 2004
Location: Montreal, Canada
Distribution: Kubuntu 10.04, Mint 8 and Puppy 4.3.1
Posts: 355
Blog Entries: 1

Rep: Reputation: 31
AC3 audio

Well you are right. I hadn't noticed in all those post, but you never mentionned ac3 before, hahahaha!

Mp2 is in effect a NTSC standard but only for VCD and SVCD. For DVD actually you can have AC3 stereo(192 kbps), AC3 dolby 5.1 (384kbps or 448kbps), DTS and finally the good old LPCM (1536 kps), but that last one takes a lot of space for an audio track.

For example I use the following metthod to encode to AC3 stereo using FFMPEG:

From an avi video: ffmpeg -i video.avi -ac 2 -ab 192 -ar 48000 audio.ac3
or
From an audio track : ffmpeg -i audio.wav -ac 2 -ab 192 -ar 48000 audio.ac3

Usually 95% of the time I always deal with the audio stream and the video separately. Only at the end of a project will I multiplex them together for the standard needed. Many reasons for this approach, one of them because a lot of movies out there are encoded with variable bitrate MP3, witch is known to cause a lot of AV sync issues.

Another is that in my experience it avoids bad sync problems.

Also even more avi movies today have the original untouch sountrack in them i.e AC3 6 channel 448kbps. Those are my favorites. You get the original quality and no processing is needed. You need to extract it only as is.

Then I use Avidemux to extract the audio as is.

Last edited by Steel_J; 11-10-2004 at 12:37 AM.
 
Old 11-09-2004, 09:54 PM   #164
wapcaplet
Guru
 
Registered: Feb 2003
Location: Colorado Springs, CO
Distribution: Gentoo
Posts: 2,018

Original Poster
Rep: Reputation: 48
I've fixed a couple of small bugs (including that one at the end about "-v unary operator expected") and re-posted version 0.14 to sourceforge. I also changed the "makempg" script - I accidentally included the wrong one last time. This one is more useful, but still very basic. Not worth doing a new release for

I think I've got AC3 encoding working pretty well (after some initial confusion - a side note, if you multiplex two AC3 streams together without any video, you get some weird results!) Can't figure out how to normalize the audio just yet (since mencoder won't take a .wav as input). By the way, are you guys using the normalize option at all? I barely ever use it, but it may come in handy someday, so I'll make sure to get AC3 working with it before release. MP2 is automatically used for PAL, and for (S)VCD, so we should be a little bit closer to conforming to DVD standards now.

Added a new '-help' option to see advanced usage options; also added an '-audiodelay' advanced option for delaying the audio, when audio and video are out of sync.

Also, rather than trying to burden the already-complex tovid script with tons of user-interaction stuff, I've made a new script, 'tovid-interactive' that guides the user through encoding by prompting for formats and stuff. It then calls tovid to do the encoding. Nothing fancy, but it'll do for now.

Steel_J: thanks for your comments on AC3; they are quite helpful. You are definitely more familiar with the standards than I am.

sk545 and Mysil2: I got your emails, but unfortunately there's nothing useful I can email you right now. I'll send you something once I get closer to release, so I can use you as guinea-pigs!
 
Old 11-10-2004, 05:26 AM   #165
oldstinkyfish
Member
 
Registered: Nov 2003
Posts: 148

Rep: Reputation: 15
Quote:
Originally posted by wapcaplet
sk545 and Mysil2: I got your emails, but unfortunately there's nothing useful I can email you right now. I'll send you something once I get closer to release, so I can use you as guinea-pigs! [/B]
I also volunteer to be a guinea-pig!

linuxeatswindows(at)yahoo(dot)com
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Convert AVI to either DVD, VCD or SVCD format linux-rulz Linux - General 13 12-27-2011 01:29 PM
XVID, VCD, SVCD and so on. How to?? Thakowbbery Suse/Novell 7 10-31-2005 03:39 PM
Encoding video for VCD and DVD wapcaplet LinuxQuestions.org Member Success Stories 3 08-01-2004 01:03 PM
SVCD, VCD, DVD editing asalford Linux - Software 19 07-16-2004 04:47 PM
converting *.avi file to *.vcd (or svcd) zstingx Linux - General 1 10-07-2003 06:44 AM


All times are GMT -5. The time now is 05:07 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration