Log in

View Full Version : ac3 reencoding other options than BeSweet


bernd_b
9th June 2010, 10:02
Because I like to convert my PAL-TV-Recordings to the original movie lenght, I do a conversion to ntsc or recently to 24p too.

Because of the resulting different movie length, I have to at least reencode the ac3-audio streams.

For audio-only reencoding, the only tool I found to do the Job is BeSweet. Of course, I need wine to to the job in linux.

Googling furhter around, I am a little confused by threads like this: http://forum.doom9.org/showthread.php?t=127663.

So questions:
1. Are there maybe better and newer, maybe native linux applications to do the job of changing the lenght of an audio-ac3-file?
2. Do I suffer from this ac3enc-bug (didn't notice so far and found the resulting sound accurate and soft).
3. Can I use aften only with the BeLight-Gui or with the commandline BeSweet as well? So far I can see aften itself cannot change the lenght of an audio-file?

Nick
9th June 2010, 22:38
Some answers
1. Changing timelength inevitably requires re-encoding. I don't know of a native linux encoder that comes close to Aften for quality but as you know it alone won't do the timeshift. I would imagine ffmpeg would allow you to demux to wav whilst altering the framerate. You could then feed the wav file into Aften.
2. The ac3enc.dll shipped with the last release of BeSweet is nowhere close to Aften in terms of quality but it's all about what you're happy with.
3. You could try putting Kurtnoise's updated bsn.dll file in your BeSweet directory, along with a Windows compile of Aften.
http://kurtnoise.free.fr/BeLight/bsn_20070513.zip
http://aften.softpedia.com/
then navigate to your besweet directory and use a commandline along the lines of
wine ./besweet.exe -core\( -input Extracted_audio_1.ac3 -output Encoded_audio_1.ac3 -logfile C:\temp\Encoded_audio_1.log \) -azid\( -g max \) -ota\( -r 25000 24000 \) -bsn\( -exe aften.exe -b 384 -6chnew -readtoeof 1 \)
(note -6chnew only necessary for 5.1 streams - omit this for stereo)

Alternatively, search for "eac3to wine" - see if you come up with anything useful.

bernd_b
10th June 2010, 11:58
Tank you very much for your answers.

As far as I understood ffmpeg is of no help because it is build to change the frame rate without altering the length (deinterlace, pull-up/down or simply dropping frames). I just want to revert the speed up - so changing length is intended. But It took me months to get mencoder to work for me - so maybe useful options of ffmpeg are still hiding from me ...:confused::cool::rolleyes:

Taking your infos into account, I'll think about trying two things:

1. Using windows-aften with beSweet as decribed in your post (although I still wonder why my ears won't find a problem with ac3enc.dll, maybe because I use a high bitrate like 448 anyway?)

2. I found out that sox has a promising option called "stretch" which claims to alter the lenght of an audio file without changing the pitch - this - together with aften - maybe will do the job I'm running nowadays with beSweet even native on linux?

nm
10th June 2010, 13:09
As far as I understood ffmpeg is of no help because it is build to change the frame rate without altering the length (deinterlace, pull-up/down or simply dropping frames).

Ffmpeg can change the framerate and alter length when the user forces an input framerate, but that only works with input formats which don't have timestamps. That's probably not what you have, so you'd need to use the setpts filter (http://lists.mplayerhq.hu/pipermail/ffmpeg-user/2009-October/022734.html).

MEncoder or some actual muxer tool is probably an easier option. For example, if you're muxing to Matroska, mkvmerge can change the framerate for you.

2. I found out that sox has a promising option called "stretch" which claims to alter the lenght of an audio file without changing the pitch

You should first determine how the audio was treated in the Film->PAL conversion. I'd guess that usually audio is stretched simply by speeding up and resampling, so that pitch is altered too. In that case you'll want to do the same in reverse by simply slowing down and resampling back to 48 kHz. Along the encoder, resampling filter is a critical component, so pick it wisely.

Nick
10th June 2010, 13:57
Taking your infos into account, I'll think about trying two things:

1. Using windows-aften with beSweet as decribed in your post (although I still wonder why my ears won't find a problem with ac3enc.dll, maybe because I use a high bitrate like 448 anyway?)

2. I found out that sox has a promising option called "stretch" which claims to alter the lenght of an audio file without changing the pitch - this - together with aften - maybe will do the job I'm running nowadays with beSweet even native on linux?

The broader the dynamic range of the source, the lousier the encode, is a good rule for BeSweet's native AC3 library. Blockbuster movies and film trailer music therefore tend to suffer worse than speech and gentler music. Your sources may not particularly expose the weaknesses.

With regards pitch, I agree with nm the that original speed-up will have increased pitch and so I used -ota( r... to do the slowdown in my example commandline, as this will lower pitch to what I assume is original level. -soundtouch( r... will slow down preserving pitch of your source. See which sounds best to you.

Although native linux feels good, I suspect the two-phase process will be much slower than BeSweet under Wine. I remain convinced, however, that achieving this with native apps is well within the realms of possibility, if you desire to do so.

bernd_b
10th June 2010, 14:05
if you're muxing to Matroska, mkvmerge can change the framerate for you.

I suppose this will only work for the video, e.g. h264-stream -but the audio still needs to be reencoded to get a proper length at a proper sample rate?

Concerning sox:
There is an alternative option called "speed" which changes the lenght and the pitch ("like with an magnetic tape"). So there is a choice. Still have to try it anyway and yes - once you get it running beSweet is still a very attractive option. My biggest concern is if audio and video stays in sync - with beSweet, I never had to complain about this. So sox & co will have a hard battle on my pc...

Besides all this my biggest surprise was that reencoding the compressed movie audio tracks is possible at all without noticeable quality loss. My greatest thanks to all these super master coder who supply us with aften, sox, beSweet, ac3enc.dll & Co !!!!

nm
10th June 2010, 14:12
I suppose this will only work for the video, e.g. h264-stream -but the audio still needs to be reencoded to get a proper length at a proper sample rate?

Yes, audio needs to be filtered and re-encoded to have a standard-compliant samplerate.


Although native linux feels good, I suspect the two-phase process will be much slower than BeSweet under Wine.

If Aften can read the input from stdin or a named pipe, it should be about as fast.

Nick
10th June 2010, 19:37
If Aften can read the input from stdin or a named pipe, it should be about as fast.

Agreed. Haven't tried with sox (yet) but my previous attempts to demux mp3 audio from an avi file to wav via ffmpeg, piping the output directly to aften, resulted in aften closing immediately and a 0 byte AC3 file being produced.

Although I seem to recall reading somewhere recently that sox calculates the supposed output size and writes a valid wav header to a pipe, whereas ffmpeg does not, so some experimentation might be in order.

Nick
10th June 2010, 23:18
OK. Well, with Aften, sox and ffmpeg installed from my distro's repositories, the following seem to work:
If your audio is already demuxed to an ac3 file, just use this as ffmpeg's input

ffmpeg -i /path/to/capture.avi -f sox - | sox -p -t wav -r 48000 - tempo 0.96 | aften -b 224 -readtoeof 1 - output.ac3 ####(slow down retaining pitch) or

ffmpeg -i /path/to/capture.avi -f sox - | sox -p -t wav -r 48000 - speed 0.96 | aften -b 224 -readtoeof 1 - output.ac3 ####(slow down with lowering of pitch)

From the sox manual, it says for most uses, tempo seems to be better than stretch, so I've used that.

<edit>only tested with stereo source - may or may not need minor modification for 5.1</edit>