LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 12-09-2009, 03:57 AM   #1
magoot
Member
 
Registered: Feb 2005
Location: Finland
Distribution: Debian testing
Posts: 38

Rep: Reputation: 15
Mencoder AC3 problems


Hello!

I'm trying to convert a bunch of matroska-files to avi (to be able to watch them on my xbox 360). However i can't get ac3-audio to work with mencoder, it always ends up being out of sync and behaving really wierd.

Here is an example file i have been playing with:
Code:
[maggot@~/video] ffmpeg -i testfile.mkv 
FFmpeg version SVN-r20428, Copyright (c) 2000-2009 Fabrice Bellard, et al.
  built on Nov  1 2009 10:39:45 with gcc 4.3.4
  configuration: --prefix=/usr --extra-cflags='-Wall -g ' --cc='ccache cc' --enable-shared --enable-libmp3lame --enable-gpl --enable-libfaad --enable-libvorbis --enable-pthreads --enable-libfaac --enable-libxvid --enable-postproc --enable-x11grab --enable-libgsm --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264 --enable-libtheora --enable-libdc1394 --enable-libspeex --enable-nonfree --disable-stripping --enable-avfilter --enable-libdirac --disable-decoder=libdirac --enable-libschroedinger --disable-encoder=libschroedinger --enable-avfilter-lavf --enable-libopenjpeg --enable-version3 --disable-altivec --disable-armv5te --disable-armv6 --disable-vis
  libavutil     50. 3. 0 / 50. 3. 0
  libavcodec    52.37. 1 / 52.37. 1
  libavformat   52.39. 2 / 52.39. 2
  libavdevice   52. 2. 0 / 52. 2. 0
  libavfilter    1. 6. 0 /  1. 6. 0
  libswscale     0. 7. 1 /  0. 7. 1
  libpostproc   51. 2. 0 / 51. 2. 0

Seems stream 0 codec frame rate differs from container frame rate: 47.95 (48000/1001) -> 24.00 (24/1)
Input #0, matroska, from 'testfile.mkv':
  Duration: 00:21:27.16, start: 0.000000, bitrate: N/A
    Stream #0.0: Video: h264, yuv420p, 624x352, PAR 1:1 DAR 39:22, 24 tbr, 1k tbn, 47.95 tbc
    Stream #0.1: Audio: aac, 24000 Hz, stereo, s16
At least one output file must be specified
[maggot@~/video]
Then i try to convert it with the following command:
Code:
[maggot@~/video] mencoder -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=10000 -oac lavc -lavcopts acodec=ac3:abitrate=640  -channels 2 testfile.mkv -o testfile.avi

MPlayer SVN-r29809 (C) 2000-2009 MPlayer Team
success: format: 0  data: 0x0 - 0x3bb1218
[mkv] Track ID 1: video (V_MPEG4/ISO/AVC), -vid 0
[mkv] Track ID 2: audio (A_AAC), -aid 0, -alang und
[mkv] Will play video track 1.
Matroska file format detected.
VIDEO:  [avc1]  624x352  24bpp  23.976 fps    0.0 kbps ( 0.0 kbyte/s)
[V] filefmt:31  fourcc:0x31637661  size:624x352  fps:23.976  ftime:=0.0417
==========================================================================
Opening audio decoder: [faad] AAC (MPEG2/4 Advanced Audio Coding)
FAAD: compressed input bitrate missing, assuming 128kbit/s!
AUDIO: 48000 Hz, 2 ch, s16le, 128.0 kbit/8.33% (ratio: 16000->192000)
Selected audio codec: [faad] afm: faad (FAAD AAC (MPEG-2/MPEG-4 Audio))
==========================================================================
Opening video filter: [expand osd=1]
Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 0
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
==========================================================================
[ac3 @ 0x26e8220]No channel layout specified. The encoder will guess the layout, but it might be incorrect.
Pos:   0.0s      1f ( 0%)  0.00fps Trem:   0min   0mb  A-V:0.000 [0:0]
1 duplicate frame(s)!
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.
Movie-Aspect is 1.77:1 - prescaling to correct movie aspect..004 [0:0]
videocodec: libavcodec (624x352 fourcc=34504d46 [FMP4])
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.
Pos:   0.2s      5f ( 0%)  0.00fps Trem:   0min   0mb  A-V:0.017 [0:0]
1 duplicate frame(s)!
Pos:   3.6s     87f ( 0%)  0.00fps Trem:   4min 259mb  A-V:0.084 [771:640]
Skipping frame!
Pos:1286.4s  30843f (99%) 157.00fps Trem:   0min 362mb  A-V:0.033 [1717:640]
Flushing video frames.
Writing index...
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.

Video stream: 1717.222 kbit/s  (214652 B/s)  size: 276122581 bytes  1286.368 secs  30843 frames

Audio stream:  640.000 kbit/s  (80000 B/s)  size: 102950400 bytes  1286.880 secs
The result is an avi-file with completley out of sync audio... it starts off nicely and starts to get more and more out of sync. When i jump forward or back in mplayer, the video plays ok, but the audio starts from the beginning every time.

The command line in mplayer looks wierd too, the audio frame count is a lot higher than the video frame count, here is after a couple of seconds playing:
Code:
[maggot@~/video] mplayer testfile.avi 
MPlayer SVN-r29809 (C) 2000-2009 MPlayer Team
Can't open joystick device /dev/input/js0: No such file or directory
Can't init input joystick
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing testfile.avi.
AVI file format detected.
[aviheader] Video stream found, -vid 0
[aviheader] Audio stream found, -aid 1
VIDEO:  [FMP4]  624x352  24bpp  23.976 fps  1717.2 kbps (209.6 kbyte/s)
Clip info:
 Software: MEncoder SVN-r29809
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffodivx] vfm: ffmpeg (FFmpeg MPEG-4)
==========================================================================
==========================================================================
Opening audio decoder: [liba52] AC3 decoding with liba52
No accelerated IMDCT transform found
AUDIO: 48000 Hz, 2 ch, floatle, 640.0 kbit/20.83% (ratio: 80000->384000)
Selected audio codec: [a52] afm: liba52 (AC3-liba52)
==========================================================================
AO: [alsa] 48000Hz 2ch floatle (4 bytes per sample)
Starting playback...
Movie-Aspect is 1.77:1 - prescaling to correct movie aspect.
VO: [xv] 624x352 => 624x352 Planar YV12 
A:8191.9 V:   3.5 A-V:8188.420 ct:  0.342  83/ 83  5%  0%  0.4% 0 0 
Exiting... (Quit)
(Since this is a file with stereo audio, mp3 would probably work. The reason i want AC3 is because most of the files i try to convert have 5.1 sound, i use this file for testing only simply because it is small)

Anyone know why this is happening? I have tried a bunch of different files with mp3, vorbis, dts, ac3 and so on audio, same problem all the way... seems to be a problem with lavc/ac3 encoding audio?

Any help would be greatly appreciated.
Regards
MagooT
 
Old 12-09-2009, 07:19 AM   #2
H_TeXMeX_H
Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269
I would use the most recent version of ffmpeg, and the '-async' option. I don't know of a way to stop a/v desync with mencoder

You could try with mencoder using '-oac copy', which would copy the original audio, that might work ... possibly. But if not...

Here's the commands I would run (2 pass):

Code:
ffmpeg -i input.mkv -vcodec libxvid -qscale 5 -s 624x352 -r 23.976 -aspect 39:22 -g 240 -bf 2 -acodec ac3 -ab 160k -ar 24000 -async 24000 -ac 2 -pass 1 -an -f rawvideo -y /dev/null

ffmpeg -i input.mkv -vcodec libxvid -qscale 5 -s 624x352 -r 23.976 -aspect 39:22 -g 240 -bf 2 -acodec ac3 -ab 160k -ar 24000 -async 24000 -ac 2 -pass 2 output.avi
Now, I don't know what a good bitrate would be, but I know for mp3 I always use 160k if you were using that. I would use mp3 over ac3 '-acodec libmp3lame'. If you want instead of '-qscale 5' you can just specify a constant bitrate with '-b 1000k' if you like. But, I prefer VBR for better quality and compression, and if you want better quality then just use a lower qscale. Also, if you don't have libxvid you can replace '-vcodec libxvid' with '-vcodec mpeg4 -vtag xvid' which will result in just about the same thing, maybe even better in some cases.

Last edited by H_TeXMeX_H; 12-09-2009 at 07:31 AM.
 
1 members found this post helpful.
Old 12-10-2009, 04:53 AM   #3
magoot
Member
 
Registered: Feb 2005
Location: Finland
Distribution: Debian testing
Posts: 38

Original Poster
Rep: Reputation: 15
Thanks a lot, that seems to work really well. Have tried it on a couple of 1080p and 720p trailers, and after tweaking the parameters a bit i'm very pleased
-qscale 5 seems to produce a file only slightly larger than the input file, and the quality is pretty decent in my opinion, i tried -qscale 2 which produced a file 4 times as big as the input file, with about identical quality, i'm gonna keep playing a bit and see what i get.

A question about encoding generally, i tried:
-acodec ac3 -ab 640k -ar 48000 -async 48000
for the audio, which caused the audio to slowly go out of sync along the clip, it plays just a bit faster (or was it slower?) than the video.
Just out of curiosity, why is this? Is it a problem to encode audio with higher bitrate than the original audio track?

I don't know so much about these things, just learning as I go
 
Old 12-10-2009, 05:43 AM   #4
H_TeXMeX_H
Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269
Well, I've only gotten slight a/v desync with ffmpeg if you don't use the original sampling frequency, for example I think it's 24000 in this case. The bitrate shouldn't matter as much, unless it's really really high. Anyway, I usually use mp3 with 160k or 128k (plus original sampling rate) and I have not noticed any a/v desync.
 
Old 12-10-2009, 02:17 PM   #5
magoot
Member
 
Registered: Feb 2005
Location: Finland
Distribution: Debian testing
Posts: 38

Original Poster
Rep: Reputation: 15
Ok, i tried lowering the bitrate to 192k and that worked for the particular file i was trying to convert.
However now i ran into another bump in the road when running the second pass on this file:
Code:
Seems stream 0 codec frame rate differs from container frame rate: 47.95 (27956/583) -> 23.98 (24000/1001)
Input #0, matroska, from 'xmen-besthd.mkv':
  Duration: 01:44:20.30, start: 0.000000, bitrate: N/A
    Stream #0.0(eng): Video: h264, yuv420p, 1280x544, PAR 1:1 DAR 40:17, 23.98 tbr, 1k tbn, 47.95 tbc
    Stream #0.1(eng): Audio: dca, 48000 Hz, 6 channels, s16
    Stream #0.2(eng): Subtitle: 0x0000
[ac3 @ 0x6c1900]No channel layout specified. The encoder will guess the layout, but it might be incorrect.
Output #0, avi, to 'xmen-besthd.avi':
    Stream #0.0(eng): Video: libxvid, yuv420p, 1280x544 [PAR 1:1 DAR 40:17], q=2-31, pass 2, 200 kb/s, 23.98 tbn, 23.98 tbc
    Stream #0.1(eng): Audio: ac3, 48000 Hz, 5.1, s16, 192 kb/s
Stream mapping:
  Stream #0.0 -> #0.0
  Stream #0.1 -> #0.1
Press [q] to stop encoding
Resampling with input channels greater than 2 unsupported.
Can not resample 6 channels @ 48000 Hz to 6 channels @ 48000 Hz
It seems 6 channels input just isn't supported at this time (running FFmpeg version SVN-r20428), and i can't get the latest svn version to compile...
Any way around this or do i have to wait until support is added? 5.1 would be nice to have.
 
Old 12-10-2009, 02:35 PM   #6
H_TeXMeX_H
Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269
Well, I never tried 6 -> 6 channel. But I know that 6 -> 2 works fine. Still even this did not work until I got the latest version of ffmpeg, so before you couldn't even do 6 -> 2. Maybe they'll add support at some point. Have you tried different output audio codecs ?
 
Old 12-10-2009, 02:43 PM   #7
magoot
Member
 
Registered: Feb 2005
Location: Finland
Distribution: Debian testing
Posts: 38

Original Poster
Rep: Reputation: 15
I just updated to FFmpeg version SVN-r20787 from debian-multimedia.org's sid-repository. Started another run at the same file with 2 channels this time to see if that works... (6 channels didn't work, at least i couldn't run the second pass with this version either).

I have only tried AC3 and MP3 so far, my Xbox 360 seems a bit picky with the formats so i have just kept trying AC3 because i know that works... any suggestions on codecs that support 6 channels i could try out?
 
Old 12-11-2009, 04:09 AM   #8
H_TeXMeX_H
Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269
I'm not sure, I don't have a sample video to try it out with.

I would say you might wanna try aften:
Code:
git clone git://aften.git.sourceforge.net/gitroot/aften/aften
http://parumi.wordpress.com/2007/12/...ideo-in-linux/

Don't worry, development is not dead, it's been updated just a few days ago. So I would try to dump the audio to something aften can convert, then mux the result back in with the video.
 
Old 07-29-2010, 02:17 AM   #9
thealtenbach
LQ Newbie
 
Registered: Jul 2010
Posts: 1

Rep: Reputation: 0
So I use Divx web player quite a lot to watch videos and usually I have issues with either video or audio but sometimes no audio at all.

I think it's when I play videos with AC3 Support that I get no audio.

I have Perian installed, but their support page says the following:

"Please consider removing obsolete QuickTime Components: FFusion, Xvid Delegate, 3ivX, DivX, DivX Decoder, XviD, msmpeg4v1, msmpeg4v2, AviImporter, EX_M4S2, Casio AVI Importer, AC3 Codec, and MatroskaQT.
Now, in my QT folder (library/quicktime/) I used to have an AC3 filter file, which I deleted, nothing happened. The only file in there is Perian.component"

Is there somewhere else I should look or is that not the issue?

Please help
 
  


Reply

Tags
conversion, matroska, mencoder


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
Problems with mencoder brokenpromises Linux - Server 5 02-23-2008 11:39 PM
problems with mencoder for video compatibility with Sansa e250 zach014 Linux - Software 5 07-31-2007 09:54 AM
Problems encoding DVDs with MEncoder. adz Linux - Software 5 10-26-2003 12:39 AM
MEncoder audio codec problems ddpicard Linux - Software 16 05-29-2003 03:49 AM


All times are GMT -5. The time now is 05:45 AM.

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