Forum Archive Home -> Linux -> mencoder: ts to avi (x264) with multiple audio stream
| mencoder: ts to avi (x264) with multiple audio stream | ||||||||
| sven_911 posted 2008 May 24 12:27 | ||||||||
| Hi all,
I have some ts files directly recorded from the sat receiver to the hard disk, which I now want to encode with mencoder to an avi container using x264 as video codec (2GB / hour is way too big).
This works pretty fine, but if a ts file has more than one audio stream, the option -oac copy takes only the first audio stream. I am searching now the net a few days for a simple solution (without demuxing the ts file), without a result. Has anyone a simple solution for this problem? Thanks a lot, Sven | ||||||||
| buzzqw posted 2008 May 26 07:01 | ||||||||
| humble suggestion, try with AutoFF (NOTE COPY AUDIO ISN'T WORKING ACTUALLY, only encoding it)
thanks! BHH | ||||||||
| sven_911 posted 2008 May 28 02:31 | ||||||||
| Thanks for the tips!
It was not easy to figure it out of the ffmpeg documentation but finally the command line
Ok, this is out of topic in my own post, but I got a problem configuring the h264 codec. The default settings lead to a really ugly video stream. I used the options from http://rob.opendot.cl/index.php/useful-stuff/ffmpeg-x264-encoding-guide/, but the look of video didn't change a bit. -vcodec mpeg4 leads to a similar ugly result! I looking for settings that lead to a result comparable to the original mpeg2 stream. ffmpeg version is
| ||||||||
| buzzqw posted 2008 May 28 06:23 | ||||||||
| your version of ffmpeg is OUTDATED!, x264 on 2007 was is early stage...
add to your repository debian-multimedia BHH | ||||||||
| GMaq posted 2008 May 28 07:56 | ||||||||
| Hello,
With all due respect to buzzqw, if you are using Ubuntu you certainly do not want to use the ffmpeg from debian-multimedia, it has numerous dependency conflicts with mjpegtools, mencoder, avidemux and especially libfaad2. Go to www.medibuntu.org and follow the instructions on adding their repo to get a fully enabled ffmpeg with a version of x264 that works great with AutoFF in Ubuntu. Judging by the version you have posted it would appear to be the stock one that comes with Ubuntu and is very limited in use. | ||||||||
| buzzqw posted 2008 May 28 08:06 | ||||||||
| well i must admit that i use debian sid.. so dependency are all resolved.. automagically by aptitude/dpkg...
thanks GMaq, i will pay more attention next time :p BHH | ||||||||
| GMaq posted 2008 May 28 08:16 | ||||||||
| buzzqw,
Well it should be that way, Ubuntu and Debian share a common base but little else any more, debian-multimedia used to be very compatible with Ubuntu up until 7.10, Unfortunately that is no longer the case. | ||||||||
| buzzqw posted 2008 May 28 08:19 | ||||||||
| thanks for the info, i don't knew of recent "incompatibility", that's another plus to standard debian :)
BHH | ||||||||
| sven_911 posted 2008 May 28 09:10 | ||||||||
| First, thanks for all replies!
I tried the ffmpeg version from debian-multimedia, which is actually not working. It returned these strange
which seems only one person in the google world encountered before. As recommended I switched to www.medibuntu.org (thanks for that tip!!!), and ffmpeg works again! But the video using h264 or mpeg4 still looks just awful! No wonder, the video gets encoded at 500kBit... | ||||||||
| buzzqw posted 2008 May 28 09:43 | ||||||||
| for bitrate..
just edit your ffmpeg string, and add the -b parameter, for bitrate ffmpeg -i in.ts out.avi -vcodec h264 -b 1500000 -acodec copy -map 0:0 -map 0:1 -map 0:2 -newaudio EDIT: just for learing pourpose you can study the command line produced by WinFF or AutoFF BHH | ||||||||
| GMaq posted 2008 May 28 09:44 | ||||||||
| sven_911,
If you don't specify a bitrate ffmpeg will just apply whatever default, which in the case of x264 is 500kb. Are you using AutoFF to do this or the commandline? I am not at my computer with AutoFF installed right now but I'm certain you can change the bitrate to whatever you like, there is a tab that is specifically for x264 in ffmpeg. **EDIT** Buzz typed faster! | ||||||||
| buzzqw posted 2008 May 28 09:46 | ||||||||
| @GMaq
in autoff you can specify the final size, and bitrate will be computed automatically (and applied to whatever video codec selected) BHH | ||||||||
| sven_911 posted 2008 May 28 11:39 | ||||||||
I was just writing this replay, when I found the bug! The command line
The output file must not be specified before the codec parameters. ffmpeg is very curious about its parameter list, e.g. specifying in this example the output file at the end of the command line, leads to an syntax error
Many thanks to buzzqw and GMaq for your help and time! Hope this helps some of the frustrated ffmpeg command line users (wild guess) out there. | ||||||||
| GMaq posted 2008 May 28 11:56 | ||||||||
| Sven_911,
Glad you got it to work, many versions of ffmpeg including the current medibuntu one will also honor bitrate flags by adding "k" to the bitrate (ie: -b 1500k instead of 1500000) | ||||||||
| buzzqw posted 2008 May 28 13:32 | ||||||||
| @sven_911
why -newaudio option ? isn't needed afaik.. and.. -map 0:0 ... it's a unneeded plus BHH | ||||||||
| sven_911 posted 2008 Jun 01 04:41 | ||||||||
Actually, no... at least not in my version 3:0.cvs20070307-5ubuntu7+medibuntu1 For the source: Stream #0.1[0xc0](deu): Audio: mp2, 48000 Hz, stereo, 160 kb/s Stream #0.2[0xc1](eng): Audio: mp2, 48000 Hz, stereo, 160 kb/s Stream #0.3[0x80](deu): Audio: ac3, 48000 Hz, stereo, 448 kb/s ffmpeg -i in.ts out.avi -vcodec h264 -acodec copy is equal to ffmpeg -i in.ts out.avi -vcodec h264 -acodec copy -map 0:0 -map 0:1 both lead to Output #0, avi, to 'out.avi': Stream #0.0: Video: mpeg4, yuv420p, 720x576, q=2-31, 200 kb/s, 25.00 fps(c) Stream #0.1: Audio: mp2, 48000 Hz, stereo, 64 kb/s Stream mapping: Stream #0.0 -> #0.0 Stream #0.1 -> #0.1 If you want to add a second audio stream, you have to provide the full mapping info -map 0:0 -map 0:1 -map 0:2". But this alone leads to the error Number of stream maps must match number of output streams. For each audio stream beyond the first, you have to add -newaudio (1 video + 1 audio stream is default). So, the correct mapping for two audio streams is -map 0:0 -map 0:2 -map 0:3 -newaudio (stripping stream 0:1), for all three -map 0:0 -map 0:3 -map 0:2 -newaudio -map 0:1 -newaudio (inverted audio stream order). |
Login/Register to our forum to be able to post here.
