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.
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.
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
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.
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
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.
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.
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 ?
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?
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.
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?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.