IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
Re-encoding, with goal of "preserving quality"
twipley
post Jun 28 2010, 19:55
Post #1





Group: Members
Posts: 8
Joined: 28-June 10
Member No.: 81909



Hello everyone. I am sure you people are receiving such questions month after month, however I have done a quick search and have not found exactly what I am looking for, so I thought maybe of opening a new topic and seeing what you guys had to say.

Also please keep in mind that I am not too savvy in this domain. What I am looking to do basically is converting the audio of family-camera videos to CBR, so as to fix some sync issue I have stepped on (c.f. http://forum.doom9.org/showthread.php?p=1412005).

More to the point, my audio files currently are under "22050 Hz, 256 kbps ABR, stereo," and to fix the issue I have stepped on I apparently will have to convert them to "44100 Hz Stereo CBR." I wanted to know the necessary bitrate (kbps) for the preservation of audio quality, with the advantage of avoiding dwelling too much into "overkill."

Put into more succinct a manner, would a choice of 320 kbps, always with the goal of "avoiding potential degradations in audio quality," seem like a sound one?

P.S.: here is a common example (i.e. with "variable" bitrates averaging the one hundred fifties) of audio information outputted from the talked-about videos:

QUOTE
Audio
ID : 1
Format : MPEG Audio
Format version : Version 2
Format profile : Layer 3
Mode : Joint stereo
Mode extension : MS Stereo
Codec ID : 55
Codec ID/Hint : MP3
Duration : 3mn 38s
Bit rate mode : Variable
Bit rate : 148 Kbps
Channel(s) : 2 channels
Sampling rate : 22.05 KHz
Stream size : 3.88 MiB (11%)
Alignment : Split accross interleaves
Interleave, duration : 34 ms (1.01 video frame)
Interleave, preload duration : 859 ms

Thanks,
twipley

This post has been edited by twipley: Jun 28 2010, 19:58
Go to the top of the page
+Quote Post
greynol
post Jun 28 2010, 19:57
Post #2





Group: Super Moderator
Posts: 10338
Joined: 1-April 04
From: San Francisco
Member No.: 13167



http://www.hydrogenaudio.org/forums/index....showtopic=16295


--------------------
Your eyes cannot hear.
Go to the top of the page
+Quote Post
twipley
post Jun 28 2010, 20:02
Post #3





Group: Members
Posts: 8
Joined: 28-June 10
Member No.: 81909



Nice, and made me laugh (statistic-course memory uncoverings).

However, is not there a fiddle-free formula lying around somewhere that could be used into determining necessary bitrates? smile.gif

This post has been edited by twipley: Jun 28 2010, 20:03
Go to the top of the page
+Quote Post
benski
post Jun 28 2010, 20:47
Post #4


Winamp Developer


Group: Developer
Posts: 670
Joined: 17-July 05
From: Brooklyn, NY
Member No.: 23375



Perhaps you could use MP3 repacker or a similar tool to losslessly convert the ABR/VBR to CBR. It'll be much larger, but no quality loss. It basically just pads up every frame with 0's, but doesn't re-encode any of the existing audio.

This post has been edited by benski: Jun 28 2010, 20:47
Go to the top of the page
+Quote Post
lvqcl
post Jun 28 2010, 21:21
Post #5





Group: Developer
Posts: 3467
Joined: 2-December 07
Member No.: 49183



QUOTE
It'll be much larger, but no quality loss.


I don't think that 148 -> 160 kbps conversion will make files "much larger".
Go to the top of the page
+Quote Post
pdq
post Jun 28 2010, 21:37
Post #6





Group: Members
Posts: 3450
Joined: 1-September 05
From: SE Pennsylvania
Member No.: 24233



QUOTE (benski @ Jun 28 2010, 15:47) *
Perhaps you could use MP3 repacker or a similar tool to losslessly convert the ABR/VBR to CBR. It'll be much larger, but no quality loss. It basically just pads up every frame with 0's, but doesn't re-encode any of the existing audio.

What he is actually looking for is a way to convert 22050 sample rate to 44100 sample rate with minimal quality loss. Once that issue is addressed then we can talk about cbr vs. abr vs. vbr.

One thing to point out here is that when you reencode, be sure to set a lowpass frequency of 11 kHz, because your original files have no content above that.
Go to the top of the page
+Quote Post
Aleron Ives
post Jun 28 2010, 22:31
Post #7





Group: Members
Posts: 197
Joined: 22-March 10
From: California
Member No.: 79208



ABR/VBR is not supported in AVI files, but if you switch to MKV or MP4, you shouldn't have synchronization problems anymore and you won't have to transcode the audio. Technically, it is possible to use VBR in AVI files, but programs like VirtualDub do not support it since it's not standard. This seems like more of a Doom9 than a Hydrogenaudio question, as A/V desynchronization isn't usually related to the audio file itself.
Go to the top of the page
+Quote Post
DVDdoug
post Jun 28 2010, 22:55
Post #8





Group: Members
Posts: 2712
Joined: 24-August 07
From: Silicon Valley
Member No.: 46454



Before you start worrying about "audio quality", have you fixed the sync problem?

You no longer have the original A/V file that was (apparently) in-sync?
Go to the top of the page
+Quote Post
2Bdecided
post Jun 29 2010, 10:00
Post #9


ReplayGain developer


Group: Developer
Posts: 5362
Joined: 5-November 01
From: Yorkshire, UK
Member No.: 409



You don't need to resample (read the doom9 thread - the OP is only doing it to get a re-encode option in VirtualDub's GUI!).

You don't need to re-encode, since mp3 re-packer can sort it out.

Either use mp3repacker and re-mux to AVI, or just re-mux to MKV as-is.

With a 256kbps 22kHz stereo source, it's unlikely you'll hear much/any difference between 256kbps and 320kbps. One trick you can try: re-encode to VBR -V2, and look what bitrate lame chooses for the various frames - note down what the highest bitrate used is. If there are only a tiny number of frames at that rate, you might choose to use the next highest rate instead. Then go back to the source, and encode CBR at that rate.

Transcoding always loses quality, but I think it's the least of your worries here - 22kHz! sad.gif

Cheers,
David.
Go to the top of the page
+Quote Post
lvqcl
post Jun 29 2010, 16:18
Post #10





Group: Developer
Posts: 3467
Joined: 2-December 07
Member No.: 49183



QUOTE
With a 256kbps 22kHz stereo source


IIRC max. bitrate for MPEG-2 (22.05 kHz) layer3 is 160 kbps. And, from the 1st post:

QUOTE
Bit rate : 148 Kbps
Go to the top of the page
+Quote Post
twipley
post Jun 29 2010, 16:20
Post #11





Group: Members
Posts: 8
Joined: 28-June 10
Member No.: 81909



Hey everybody,

I've spent the last hours on this. Currently, two alternatives are in my mind:

1) resampling (to unlock vd's CBR encoding) and CBR reencode using virtualdub, but that would result in audio-quality loss. I believe, so I'd rather:

2) output wav using virtualdub, output mp3 file using lamedrop, then use mp3repacker to "losslessly convert (without re-encoding) the ABR/VBR to CBR [...] without any quality loss," basically just by padding up every frame with 0's, as benski has put it. Then, re-mux audio (coming from mp3repacker) together with video-only AVI (coming from virtualdub) to AVI using "AVI-Mux GUI," something I think can too be done straight using virtualdub, choosing "audio from file" for audio (is that right, that avi-mux gui thus would not be needed?).

However, I'm blocked in a particular step... Whatever I do using mp3packer, MediaInfo always say that the output file's bitrate remains "variable" and not, as I would want it, "constant."

I've spent all week on this thing. I feel I'm approaching the point where I can fix my AVI file (I want it to remain AVI so as to be DVD-player watchable) without re-encoding, thus without losing quality.

Thanks,
twipley
Go to the top of the page
+Quote Post
twipley
post Jun 29 2010, 16:23
Post #12





Group: Members
Posts: 8
Joined: 28-June 10
Member No.: 81909



QUOTE (lvqcl @ Jun 29 2010, 16:18) *
IIRC max. bitrate for MPEG-2 (22.05 kHz) layer3 is 160 kbps.

Does this mean I should go with -b 160 using mp3packer?
Go to the top of the page
+Quote Post
lvqcl
post Jun 29 2010, 16:50
Post #13





Group: Developer
Posts: 3467
Joined: 2-December 07
Member No.: 49183



Mp3packer will print min. possible CBR bitrate with --ib option:

CODE
mp3packer --ib file.mp3
Go to the top of the page
+Quote Post
lvqcl
post Jun 29 2010, 16:58
Post #14





Group: Developer
Posts: 3467
Joined: 2-December 07
Member No.: 49183



QUOTE
2) output wav using virtualdub, output mp3 file using lamedrop, then use mp3repacker


This is very... er, strange way. And it also results in quality loss.

Extract mp3 file from AVI (e.g. with VirtualDubMod), apply mp3packer and add resulting mp3 to AVI.
Go to the top of the page
+Quote Post
twipley
post Jun 29 2010, 18:49
Post #15





Group: Members
Posts: 8
Joined: 28-June 10
Member No.: 81909



Alright. Worked great extracting mp3 file using "virtualdubmod > streams > stream list > demux."

--ib indeed prints 160. So, I intuit I should go with "mp3packer -b 160 file.mp3" or the like, if I understand correctly?

As a side note, "mp3packer -b 162 file.mp3" produced about the same file, however with 4:58 duration (see info below) instead of the original, 4:57 duration (which 160 succeeded in reproducing).

CODE
Audio
Format                           : MPEG Audio
Format version                   : Version 2
Format profile                   : Layer 3
Mode                             : Joint stereo
Mode extension                   : MS Stereo
Duration                         : 4mn 58s
Bit rate mode                    : Constant
Bit rate                         : 160 Kbps
Channel(s)                       : 2 channels
Sampling rate                    : 22.05 KHz
Stream size                      : 5.69 MiB (100%)

The reason I've tried with 162 is that, while -i prints out 160 as "smallest bitrate for CBR," it does print out "largest frame uses [...] 161.36 kbps." Strange, isn't it? huh.gif

Furthermore, consulting the mp3packer readme makes me realize I do not understand much of these internals:
CODE
Minimum bitrate allowed for output. Defaults to 0, which means all frame sizes are allowed. If the number given is a valid bitrate, the minimum frame size will be "dithered" between padded and unpadded frames, depending on standard CBR rules. If the bitrate given is one more than a valid bitrate, all frames will be padded. Anything larger than the maximum bitrate will be clamped to a padded maximum-bitrate frame. All other bitrates will round up to the next higher unpadded frame.

Could you confirm that the used command line indeed (theoretically speaking) has not left any significant bits behind?

This post has been edited by twipley: Jun 29 2010, 19:48
Go to the top of the page
+Quote Post
Fandango
post Jun 29 2010, 20:09
Post #16





Group: Members
Posts: 1549
Joined: 13-August 03
Member No.: 8353



I would use a modern container like MP4 or MKV.
Go to the top of the page
+Quote Post
twipley
post Jun 29 2010, 20:18
Post #17





Group: Members
Posts: 8
Joined: 28-June 10
Member No.: 81909



But, AVI is compatible with my DVD player. smile.gif

EDIT: up there, when I say "strange," I'm talking about the modified duration (i.e. 4:58).

The only thing really tying me to this thread is waiting for the following confirmation:
"the number one should use for -b # is the one that is given in the --ib print."

-- I am preparing a short readme for the solution for the doom9 thread, and, being on sloppy ground, I would not want to post inaccurate information. wink.gif

This post has been edited by twipley: Jun 29 2010, 20:23
Go to the top of the page
+Quote Post
Aleron Ives
post Jun 29 2010, 20:36
Post #18





Group: Members
Posts: 197
Joined: 22-March 10
From: California
Member No.: 79208



You don't need VirtualDubMod to extract the MP3 from the AVI file. Just use the Extract -> Raw audio in VirtualDub. It'll output xxx.bin, and then all you need to do is change the extension to .mp3.
Go to the top of the page
+Quote Post
twipley
post Jun 30 2010, 14:11
Post #19





Group: Members
Posts: 8
Joined: 28-June 10
Member No.: 81909



QUOTE (Aleron Ives @ Jun 29 2010, 20:36) *
You don't need VirtualDubMod to extract the MP3 from the AVI file. Just use the Extract -> Raw audio in VirtualDub. It'll output xxx.bin, and then all you need to do is change the extension to .mp3.

Awesome. This contributes to shortening the length of my readme solution, which is a good thing (think parsimoniousness):

CODE
I've just spent a some time over at the nice and expansive Hydrogenaudio Forums. There, two options were being offered to me:

1) resampling (to unlock vd's CBR encoding) and CBR reencode using virtualdub, but that might, as some suggested, result in audio-quality loss;

2) outputing audio through "file > export > raw audio," video through "audio > no audio; video > direct stream copy; file > save as avi," both using virtualdub, then, secondly, using mp3packer to, "losslessly convert [i.e. without re-encoding] from VBR to CBR, basically just by padding every frame with 0s" (using the same "-b #" as "--ib" prints out), and, finally, remuxing audio (coming from mp3repacker) together with video (coming from virtualdub) to a final AVI file using AVI-Mux GUI.

Thus, needed software:
- virtualdub
- mp3packer
- avimuxgui
Go to the top of the page
+Quote Post
lvqcl
post Jun 30 2010, 15:48
Post #20





Group: Developer
Posts: 3467
Joined: 2-December 07
Member No.: 49183



You don't need avimuxgui actually:
1) Extract raw audio in VDub
2) use mp3packer
3) return to VDub and select: Video > Direct stream copy; Audio > Audio from other file... (select proper mp3 file) and then File > Save as AVI...

This post has been edited by lvqcl: Jun 30 2010, 15:50
Go to the top of the page
+Quote Post
twipley
post Jun 30 2010, 16:58
Post #21





Group: Members
Posts: 8
Joined: 28-June 10
Member No.: 81909



Nice suggestion. I was just experimenting with that at the moment, actually. I've found that avimuxgui produces "Aligned on interleaves" by default, whereas by default virtualdub produces "Split across interleaves." Not really wanting to fiddle more than I to this point have, I've kept avimuxgui as the third tool, some people having suggested "aligned" being a secure means of further avoiding sync problems.

source:
http://forum.videohelp.com/threads/232996-...dio-interleaves
http://www.fixya.com/support/r4099743-set_...gn_audio_frames

However, your method seems very fast. Outputted files seem, for some reason, to be 200k bigger that way, though.

I hope someday this thread will benefit someone to read.

Peace out,
twipley
Go to the top of the page
+Quote Post
Aleron Ives
post Jun 30 2010, 20:29
Post #22





Group: Members
Posts: 197
Joined: 22-March 10
From: California
Member No.: 79208



VirtualDub lets you configure how you want to mux the audio in one of the audio menus. IIRC it's the "Interleaving" one. tongue.gif
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 21st December 2014 - 09:51