Re: [FFmpeg-user] Input 5.1 DTS, output 2.0 MP3: Atrocious Quality

2015-05-18 Thread Carl Eugen Hoyos
John L orionfyre at hotmail.com writes:

  Please test the following:
  $ ffmpeg -i inter.dts -rematrix_maxval 1.0 -ac 2 out.ac3
  $ ffmpeg -i inter.dts -rematrix_maxval 1.0 -ac 2 out.mp3
  $ ffmpeg -i inter.dts -rematrix_maxval 1.0 -ac 2 
  -acodec pcm_f32le out.wav
 
 I ran all three as requested, including '-loglevel debug'. 
 All three resulting files resulted in poor quality audio 
 as before.

Now we are there;-)
Hendrik says the option fixes audio for him, you 
report it does not fix the issue...

Carl Eugen

___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user


Re: [FFmpeg-user] Input 5.1 DTS, output 2.0 MP3: Atrocious Quality

2015-05-18 Thread John L


 To: ffmpeg-user@ffmpeg.org
 From: ceho...@ag.or.at
 Date: Mon, 18 May 2015 08:48:32 +
 Subject: Re: [FFmpeg-user] Input 5.1 DTS, output 2.0 MP3: Atrocious Quality
 
 John L orionfyre at hotmail.com writes:
 
   Please test the following:
   $ ffmpeg -i inter.dts -rematrix_maxval 1.0 -ac 2 out.ac3
   $ ffmpeg -i inter.dts -rematrix_maxval 1.0 -ac 2 out.mp3
   $ ffmpeg -i inter.dts -rematrix_maxval 1.0 -ac 2 
   -acodec pcm_f32le out.wav
  
  I ran all three as requested, including '-loglevel debug'. 
  All three resulting files resulted in poor quality audio 
  as before.
 
 Now we are there;-)
 Hendrik says the option fixes audio for him, you 
 report it does not fix the issue...
 
 Carl Eugen

I reviewed my work on this section and I was wrong; this does in fact work and 
solve the issue i was originally having. Perhaps I had my file browser pointed 
at the wrong working folder...?

Thanks all, especially you Carl.
  
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user


Re: [FFmpeg-user] Input 5.1 DTS, output 2.0 MP3: Atrocious Quality

2015-05-18 Thread Andy Furniss

John L wrote:


Please test the following:
$ ffmpeg -i inter.dts -rematrix_maxval 1.0 -ac 2 out.ac3
$ ffmpeg -i inter.dts -rematrix_maxval 1.0 -ac 2 out.mp3
$ ffmpeg -i inter.dts -rematrix_maxval 1.0 -ac 2 -acodec pcm_f32le out.wav


I ran all three as requested, including '-loglevel debug'. All three resulting 
files resulted in poor quality audio as before. the filtergraph output does 
show something different however, but the resulting audio is still terrible and 
indistinguishable from before.


That's strange, it seems to do the correct thing for me (only tested 
last one).
I notice typical of loud movie dts the master sample is quite extreme 
to start with (and clipped a bit by studio I think).


But ignoring that the downmix with -rematrix_maxval 1.0 is the same for 
me as using a signed wav.


Looking with sox

ffmpeg -i inter.dts -rematrix_maxval 1.0 -ac 2 -acodec pcm_f32le outf-1.wav

sox outf-1.wav -n stats
sox WARN wav: wave header missing FmtExt chunk
 Overall Left  Right
DC offset  -0.000397 -0.000397 -0.000138
Min level  -0.986728 -0.977729 -0.986728
Max level   0.988566  0.974450  0.988566
Pk lev dB  -0.10 -0.20 -0.10
RMS lev dB-11.54-11.47-11.60
RMS Pk dB  -4.73 -4.73 -4.97
RMS Tr dB -36.11-36.08-36.11
Crest factor   -  3.66  3.76
Flat factor 0.00  0.00  0.00
Pk count   2 2 2
Bit-depth  32/32 32/32 32/32
Num samples1.44M
Length s  29.995
Scale max   1.00
Window s   0.050

Without -rematrix_maxval 1.0

sox outf-0.wav -n stats
sox WARN wav: wave header missing FmtExt chunk
 Overall Left  Right
DC offset  -0.005071 -0.005071 -0.002057
Min level  -1.00 -1.00 -1.00
Max level   1.00  1.00  1.00
Pk lev dB   0.00  0.00  0.00
RMS lev dB -5.62 -5.61 -5.63
RMS Pk dB  -0.79 -0.79 -1.03
RMS Tr dB -28.46-28.42-28.46
Crest factor   -  1.91  1.91
Flat factor45.34 46.05 44.52
Pk count222k  228k  216k
Bit-depth  32/32 32/32 32/32
Num samples1.44M
Length s  29.995
Scale max   1.00
Window s   0.050
sox WARN sox: `outf-0.wav' input clipped 443634 samples




___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user


Re: [FFmpeg-user] Input 5.1 DTS, output 2.0 MP3: Atrocious Quality

2015-05-17 Thread David Favor

John L wrote:

Backstory: I have a system in place to automagically convert video files to smaller 
formats/versions on request to have a sort of mobile version for my father 
who travels extensively. The purpose is so that he can fit significantly more videos on 
his tablet than if they were the high quality rips.

It all boils down to:
ffmpeg -i [input-file] -ac 2 -c:v libx264 -c:a libmp3lame -b:v 1024k -preset 
fast [output-file]

I was under the impression everything was hunky dory until I took a bunch of the shrunken movies on my phone on a roadtrip. A good many of the videos were as good as can be expected, and nothing was egregiously wrong. However on a few videos the audio was absolutely atrocious, blown out, clipping, and just noise from seemingly nowhere. 


One of the worst was Intersteller which was completely unwatchable after the 
first two minutes with all the blown out crescendos, pops, cracks, static, and 
voices of the deep adulterating the audio stream. All video files affected by 
this were 5.1DTS sources, but not all 5.1DTS were affected.

When talking with my father he said it was a frequent enough occurrence that he 
suspected it was just because I had shrunk the file so small and was an 
artifact of that. He did confirm that most videos that were affected weren't as 
bad as the Interstellar conversion.



~/testing$ ffmpeg -version
ffmpeg version 2.5.6-0ubuntu0.15.04.1 Copyright (c) 2000-2015 the FFmpeg 
developers
built with gcc 4.9.2 (Ubuntu 4.9.2-10ubuntu13)
configuration: --prefix=/usr --extra-version=0ubuntu0.15.04.1 
--build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu 
--shlibdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu 
--enable-gpl --enable-shared --disable-stripping --enable-avresample 
--enable-avisynth --enable-ladspa --enable-libass --enable-libbluray 
--enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite 
--enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme 
--enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg 
--enable-libopus --enable-libpulse --enable-libschroedinger --enable-libshine 
--enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame 
--enable-libvorbis --enable-libwavpack --enable-libwebp --enable-libxvid 
--enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 
--enable-libzvbi --enable-libzmq --enable-frei0r --enable-libvpx 
--enable-libx264 --enable-libsoxr --enable-gn

ut

 ls --enable-openal --enable-libopencv --enable-librtmp --enable-libx265
libavutil  54. 15.100 / 54. 15.100
libavcodec 56. 13.100 / 56. 13.100
libavformat56. 15.102 / 56. 15.102
libavdevice56.  3.100 / 56.  3.100
libavfilter 5.  2.103 /  5.  2.103
libavresample   2.  1.  0 /  2.  1.  0
libswscale  3.  1.101 /  3.  1.101
libswresample   1.  1.100 /  1.  1.100
libpostproc53.  3.100 / 53.  3.100


To troubleshoot I copied out a particularly bad snippet of audio
ffmpeg -i Int*.mkv -vn -c copy -ss 1:30 -t 0:30 inter.dts

This audio clip is confirmed to be a good 5.1dts stream


ffmpeg -i inter.dts -ac 2 -c libmp3lame inter-test.mp3
This audio sample has the exact same audio defects as in the shrunken video 


Converting it to a stereo wave format, and then converting into an mp3:
ffmpeg -i inter.dts -ac 2 -c pcm_s32le inter.wav  ffmpeg -i inter.wav -c 
libmp3lame inter.mp3
both inter.wav and inter.mp3 are confirmed to be GOOD stereo copies of the 
audio with no defects.

https://www.dropbox.com/s/tru46zo07gcr8ve/testing.tar.gz?dl=0
This is a link to the files in question to my testing above. 
inter.dts : 30 second rip of audio from video

inter-test : dts-mp3 conversion
inter.mp3 : dts-wav-mp3 conversion

I apologize if I'm missing something glaring, but I've been unable to find any 
other instances of this issue with my google-fu. Until I have a solution I've 
already edited my services to perform this intermediary wave step work-around 
on all conversions.

Thank you for your time.


If your target output file is .mp4 (no output type mentioned in your commands) 
then
consider fdkaac, which many times produces smaller files than .mp3 + is stellar 
quality + plays
anywhere an .mp4 file plays.

Downmixing from 5.1 to stereo is automagick.

To get .mp3 sized files use the he2 profile as with this snippet...

   -c:a libfdk_aac -profile:a aac_he_v2 -afterburner 1 -signaling explicit_sbr 
-vbr 5 -ac 2 -ar 44100

HE2 takes more CPU cycles than HE + produces far smaller files.

Another trick is using vbr encoding which also reduces file size.
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user


Re: [FFmpeg-user] Input 5.1 DTS, output 2.0 MP3: Atrocious Quality

2015-05-17 Thread Bazza
On Sun, 17 May 2015 02:16:56 -0500, John L orionf...@hotmail.com
wrote:

-
the resulting wav file is significantly distorted, but qualitatively doesn't 
'feel' as harsh


Just FYI John, _some_ of those channels in the 5.1 are already
flattening at peak levels so the sound overall, will never be
great. Of course, this is not an FFMPEG thing or even related to
your transcode issue.



___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user


Re: [FFmpeg-user] Input 5.1 DTS, output 2.0 MP3: Atrocious Quality

2015-05-17 Thread John L
 
 Please test the following:
 $ ffmpeg -i inter.dts -rematrix_maxval 1.0 -ac 2 out.ac3
 $ ffmpeg -i inter.dts -rematrix_maxval 1.0 -ac 2 out.mp3
 $ ffmpeg -i inter.dts -rematrix_maxval 1.0 -ac 2 -acodec pcm_f32le out.wav

I ran all three as requested, including '-loglevel debug'. All three resulting 
files resulted in poor quality audio as before. the filtergraph output does 
show something different however, but the resulting audio is still terrible and 
indistinguishable from before.

[AVFilterGraph @ 0x2387f20] query_formats: 4 queried, 6 merged, 3 already done, 
0 delayed
0.414214 0.00 0.292893 0.00 0.292893 0.00 
0.00 0.414214 0.292893 0.00 0.00 0.292893 

I do appreciate your help in resolving this issue.

Just to see if it wasn't my system causing the issue I loaded up a windows XP 
vm and used the 32-bit windows binary from the ffmpeg homepage, resulting in 
the same outputs.
  
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user


Re: [FFmpeg-user] Input 5.1 DTS, output 2.0 MP3: Atrocious Quality

2015-05-17 Thread Bazza
On Sun, 17 May 2015 07:41:31 + (UTC), Carl Eugen Hoyos
ceho...@ag.or.at wrote:

Not a problem about misunderstanding.
Hope I make sense sometimes too -)

 I did now and the question now is: 
 Is the issue reproducible with:
 $ ffmpeg -i inter.dts -ac 2 -acodec pcm_f32le outf.wav

This (above) produces the the same overload/over-modulation/
distortion as in the original raised issue. You were expecting it?
OP seems to think its an fltp issue.

If not, what about the following?
$ lame outf.wav

Sorry. This last makes no sense to me. 
I don't have lame installed.

___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user


Re: [FFmpeg-user] Input 5.1 DTS, output 2.0 MP3: Atrocious Quality

2015-05-17 Thread Carl Eugen Hoyos
John L orionfyre at hotmail.com writes:

 But I'm still curious why it would behave in such a way

Me too!
So please test the following and report back:
ffmpeg -i inter.dts -acodec pcm_f32le -ac 2 out.wav

Carl Eugen

___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user


Re: [FFmpeg-user] Input 5.1 DTS, output 2.0 MP3: Atrocious Quality

2015-05-17 Thread Carl Eugen Hoyos
Bazza lamia at jeack.com.au writes:

 The simple command 
 'ffmpeg -i inter.dts -ac 2 -ab 320k out.mp3',
 for an MP3 file, will produce this result. 
 Plainly distorted. -)

You told that and John told us.
I did neither deny it nor asked for another 
example for the same comamnd line.
When I originally asked for testing I had 
not yet completely understood what FFmpeg 
does internally (sorry!). I did now and 
the question now is: Is the issue 
reproducible with:
$ ffmpeg -i inter.dts -ac 2 -acodec pcm_f32le outf.wav
If not, what about the following?
$ lame outf.wav

If there is also a bug in the ac3 encoder, 
it will need additional testing.

Carl Eugen

___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user


Re: [FFmpeg-user] Input 5.1 DTS, output 2.0 MP3: Atrocious Quality

2015-05-17 Thread John L


 To: ffmpeg-user@ffmpeg.org
 From: ceho...@ag.or.at
 Date: Sat, 16 May 2015 11:15:29 +
 Subject: Re: [FFmpeg-user] Input 5.1 DTS, output 2.0 MP3: Atrocious Quality
 
 Moritz Barsnick barsnick at gmx.net writes:
 
  $ ffmpeg -loglevel debug -i inter.dts -ac 2 -c:a libmp3lame -f null -
  $ ffmpeg -loglevel debug -i inter.dts -ac 2 -c:a pcm_s16le -f null -
  You can insert other arbitrary codecs at will.
  
  The former shows a matrix:
  1.00 0.00 0.707107 0.00 0.707107 0.00
  0.00 1.00 0.707107 0.00 0.00 0.707107
  [auto-inserted resampler 0  at  0xb713840] ch:6 chl:5.1(side) 
  fmt:fltp r:48000Hz - ch:2 chl:stereo
  fmt:fltp r:48000Hz
  
  while the latter shows:
  0.414214 0.00 0.292893 0.00 0.292893 0.00
  0.00 0.414214 0.292893 0.00 0.00 0.292893
  [auto-inserted resampler 0  at  0xb3b55c0] ch:6 chl:5.1(side) 
  fmt:fltp r:48000Hz - ch:2 chl:stereo
  fmt:s16 r:48000Hz
  
  I think this may be the described behavior.
 
 If this really is the issue, it should be reproducible 
 with at least one of the command lines I proposed 
 (namely for -acodec pcm_f32le) and it is possible to 
 work-around the issue by forcing s16p as the mp3 
 encoding format. The mp3 encoder accepts fltp, s16p 
 and s32p.

Thanks Everyone. You've fixed the problem for me. When I cycle through the 
available format options for libmp3lame, the only one that makes bad audio is 
'fltp', both 's16p' and 's32p' produce a good file

 
 But I would really appreciate if somebody can confirm 
 that the issue is reproducible with pcm_f32le (and 
 neither with s16le nor s32le).
 
 Carl Eugen
 

I ran the following command line and received the following:

ffmpeg -loglevel debug -i inter.dts -c:a pcm_f32le -ac 2 -y inter-f32le.wav

[AVFilterGraph @ 0xca9d20] query_formats: 4 queried, 6 merged, 3 already done, 
0 delayed
1.00 0.00 0.707107 0.00 0.707107 0.00 
0.00 1.00 0.707107 0.00 0.00 0.707107 
[auto-inserted resampler 0 @ 0xc965c0] ch:6 chl:5.1(side) fmt:fltp r:48000Hz - 
ch:2 chl:stereo fmt:flt r:48000Hz
-
the resulting wav file is significantly distorted, but qualitatively doesn't 
'feel' as harsh

And as you expected, both s16le nor s32le result in acceptable files for both:
ffmpeg -loglevel debug -i inter.dts -c:a pcm_s16le -ac 2 -y inter-s16le.wav
ffmpeg -loglevel debug -i inter.dts -c:a pcm_s32le -ac 2 -y inter-s32le.wav

I quickly re-encoded movies that were known to suffer from this issue using 
'-c:a libmp3lame -sample_fmt s16p' and they all result in acceptable audio 
levels.

So OFFICIALLY my problem is resolved. But I'm still curious why it would behave 
in such a way that fltp-fltp would be allowed to blow out levels so badly (i'm 
also scared to go down that rabbit hole)

Thank you to all who have contributed. I appreciate your help tremendously.
  
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user


Re: [FFmpeg-user] Input 5.1 DTS, output 2.0 MP3: Atrocious Quality

2015-05-16 Thread John L
 
 Instead, take the 5.1 and _DOWNMIX_ all tracks to a single stereo for
 the phone/tablet by declaring -acodec  -ac 2. No intermediate
 steps should be required. Consider also - Do you need pcm_s32le ?
 pcm_s16le is usual.

I fail to see how that is any different than what I am doing now. I was under 
the impression that the flags -acodec and -c:a were the same. Regardless using 
-acodec reults in identical clipping and noise generation dts-mp3. 
For reference here is the command I used:
ffmpeg -i inter.dts -acodec libmp3lame -ac 2 inter-new.mp3
The resulting mp3 file still has horrendous crackling and noise.


What I thought I stated quite clearly in my OP is the following:
5.1DTS-2.0MP3 results in horrible noise and clipping in the resulting mp3 file
5.1DTS2.0PCM-2.0MP3 does not generate the same atrocious noise. please 
reference the files I've included in the dropbox link in my OP.

inter.dts was the ripped 5.1 audio

inter-test.mp3 was encoded to 2.0mp3 format directly from 5.1dts and when 
played back on my laptop(s) (Windows, Linux, Mac; in Windows MP, ffplay, 
mplayer, vlc, xine, and more), Phones (s5,s3,iphone,htc one), tablet, ipod and 
my Sansa MP3 player all has horrific noise.

inter.mp3 was generated by converting the 5.1DTS to 2.0PCM and then the 2.0PCM 
to 2.0MP3, sounds just fine when played back on all of my devices.

I am fully aware that there should be NO NEED to use an intermediary wave 
format to downsample to stereo audio from 5.1 for a conversion to mp3. But 
that's exactly why I'm writing this problem into the group because it is NOT 
working as expected.
  
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user


Re: [FFmpeg-user] Input 5.1 DTS, output 2.0 MP3: Atrocious Quality

2015-05-16 Thread Carl Eugen Hoyos
John L orionfyre at hotmail.com writes:

 ffmpeg version 2.5.6-0ubuntu0.15.04.1

Please test current FFmpeg git head, see 
http://ffmpeg.org/download.html
(Please do not test 2.6)

 ffmpeg -i inter.dts -ac 2 -c libmp3lame inter-test.mp3
 This audio sample has the exact same audio defects as 
 in the shrunken video 
 
 Converting it to a stereo wave format, and then 
 converting into an mp3:
 ffmpeg -i inter.dts -ac 2 -c pcm_s32le inter.wav  
 ffmpeg -i inter.wav -c libmp3lame inter.mp3
 both inter.wav and inter.mp3 are confirmed to be 
 GOOD stereo copies of the audio with no defects.

Please test the following:
$ ffmpeg -i inter.dts -ac 2 out16.wav
$ ffmpeg -i inter.dts -ac 2 -acodec pcm_s32le out32.wav
$ ffmpeg -i inter.dts -ac 2 -ab 640k out.ac3
$ ffmpeg -i inter.dts -ac 2 -ab 320k out.mp2

Iiuc, out32.wav sounds ok. Do the other three files 
sound ok for you or not?

 Until I have a solution I've already edited my 
 services to perform this intermediary wave step 
 work-around on all conversions.

You can do the intermediate step within FFmpeg, 
just play with -af aformat=s32.

Thank you, Carl Eugen

___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user


Re: [FFmpeg-user] Input 5.1 DTS, output 2.0 MP3: Atrocious Quality

2015-05-16 Thread Bazza
On Sat, 16 May 2015 07:52:12 + (UTC), Carl Eugen Hoyos
ceho...@ag.or.at wrote:


Please test the following:
$ ffmpeg -i inter.dts -ac 2 out16.wav
$ ffmpeg -i inter.dts -ac 2 -acodec pcm_s32le out32.wav
$ ffmpeg -i inter.dts -ac 2 -ab 640k out.ac3
$ ffmpeg -i inter.dts -ac 2 -ab 320k out.mp2

Carl, I did test some of this stuff. It seemed that attempts to
downmix via -ac 2 would work OK for WAV (pcm_s16le) but anytime
converting to other formats (AC3, or MP3s) generated significant
signal overload. However, the channel mixing DID occur. 
A workaround  was to include -af volume=-10dB.

However, although I'm not the poster with the problem, 
I've just done your suggestions and, for me ...

- MP3 suffers overload
- WAVs are OK
- AC3 suffers overload
- AAC are OK
- MP2 are OK
But I'll let him speak ...

___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user


Re: [FFmpeg-user] Input 5.1 DTS, output 2.0 MP3: Atrocious Quality

2015-05-16 Thread Carl Eugen Hoyos
Bazza lamia at jeack.com.au writes:

 Please test the following:
 $ ffmpeg -i inter.dts -ac 2 out16.wav
 $ ffmpeg -i inter.dts -ac 2 -acodec pcm_s32le out32.wav
 $ ffmpeg -i inter.dts -ac 2 -ab 640k out.ac3
 $ ffmpeg -i inter.dts -ac 2 -ab 320k out.mp2
 
 Carl, I did test some of this stuff.

 - MP3 suffers overload
 - WAVs are OK
 - AC3 suffers overload
 - AAC are OK
 - MP2 are OK

Sorry, I am apparently extremely dim-witted:
Did you test the four lines above?
Which of them sound ok, which of them do 
not sound ok?

Thank you, Carl Eugen

___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user


Re: [FFmpeg-user] Input 5.1 DTS, output 2.0 MP3: Atrocious Quality

2015-05-16 Thread Andy Furniss

John L wrote:


Instead, take the 5.1 and _DOWNMIX_ all tracks to a single stereo
for the phone/tablet by declaring -acodec  -ac 2. No
intermediate steps should be required. Consider also - Do you need
pcm_s32le ? pcm_s16le is usual.


I fail to see how that is any different than what I am doing now. I
was under the impression that the flags -acodec and -c:a were the
same. Regardless using -acodec reults in identical clipping and noise
generation dts-mp3. For reference here is the command I used: ffmpeg
-i inter.dts -acodec libmp3lame -ac 2 inter-new.mp3 The resulting mp3
file still has horrendous crackling and noise.


What I thought I stated quite clearly in my OP is the following:
5.1DTS-2.0MP3 results in horrible noise and clipping in the
resulting mp3 file 5.1DTS2.0PCM-2.0MP3 does not generate the same
atrocious noise. please reference the files I've included in the
dropbox link in my OP.

inter.dts was the ripped 5.1 audio

inter-test.mp3 was encoded to 2.0mp3 format directly from 5.1dts and
when played back on my laptop(s) (Windows, Linux, Mac; in Windows MP,
ffplay, mplayer, vlc, xine, and more), Phones (s5,s3,iphone,htc one),
tablet, ipod and my Sansa MP3 player all has horrific noise.

inter.mp3 was generated by converting the 5.1DTS to 2.0PCM and then
the 2.0PCM to 2.0MP3, sounds just fine when played back on all of my
devices.

I am fully aware that there should be NO NEED to use an intermediary
wave format to downsample to stereo audio from 5.1 for a conversion
to mp3. But that's exactly why I'm writing this problem into the
group because it is NOT working as expected.


IIRC this has come up before. The issue seems to be that sometimes -ac 2
normalises and sometimes it doesn't (depending on what codec is used).

You can see whether or not the matrix is normalised with -loglevel debug.

FWIW dts may contain meta data specifying a matrix typically (and by
default if there is none) this will be partially normalised.

To use this you put -request_channels 2 before -i infile.dts.


___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user


Re: [FFmpeg-user] Input 5.1 DTS, output 2.0 MP3: Atrocious Quality

2015-05-16 Thread Bazza
On Sat, 16 May 2015 09:17:59 + (UTC), Carl Eugen Hoyos
ceho...@ag.or.at wrote:

Bazza lamia at jeack.com.au writes:

 Please test the following:
 $ ffmpeg -i inter.dts -ac 2 out16.wav
 $ ffmpeg -i inter.dts -ac 2 -acodec pcm_s32le out32.wav
 $ ffmpeg -i inter.dts -ac 2 -ab 640k out.ac3
 $ ffmpeg -i inter.dts -ac 2 -ab 320k out.mp2
 
 Carl, I did test some of this stuff.

 - MP3 suffers overload
 - WAVs are OK
 - AC3 suffers overload
 - AAC are OK
 - MP2 are OK

Sorry, I am apparently extremely dim-witted:
Did you test the four lines above?
Which of them sound ok, which of them do 
not sound ok?
Thank you, Carl Eugen

Tested them all Carl. It's not quite a case of sounding OK
it's that they are patently just wrong. I'm using a Windows
/Zeranoe build. Observing results through Adobe's Audition.
Results are independant of bit rate (as you specify),I tried 
those (and some other rates). All fail.
Also, it appears to be independant of the codecs 16 Vs 32 etc.
The audio signals in John's sample have 6 mono. Most of those
are up to the clipping level when viewed separately.

When he combines them (let's say via declaring -ac 2) the
channels (all 6) do indeed mix but the 'numbers' are summed
greater than the streams capability - hence severe clipping and
overload. This appears to happen in the case of AC3 and MP3
(which is John's complaint).

In doing a bit of reading, it seems to be the case that L,R,
FL and FR are usually attenuated by 3dB per signal. Maybe that
'routine' is being bypassed (or not even called) in AC3 or MP3
situations. This is a pure guess but the numbers do add up
when we drop a volume by 10 dB. Luckily his levels nearly clip.

Now, I must add, Adobe's Audition does not like viewing AC3 
and AAC stuff directly so I do a re-convert from the AC3 and 
AAC back into WAV (just to view) but, no doubts about it, does 
not look good. Output in the non-behaving file format is just 
too high a level. FFMPEG generates no complaints so that's good.



___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user


Re: [FFmpeg-user] Input 5.1 DTS, output 2.0 MP3: Atrocious Quality

2015-05-16 Thread Bazza
On Sat, 16 May 2015 09:17:59 + (UTC), Carl Eugen Hoyos
ceho...@ag.or.at wrote:

Sorry, I am apparently extremely dim-witted:
Did you test the four lines above?
Which of them sound ok, which of them do 
not sound ok?

Seem to have not explicitly answered the Q. Sorry.

$ ffmpeg -i inter.dts -ac 2 out16.wav
$ ffmpeg -i inter.dts -ac 2 -acodec pcm_s32le out32.wav
$ ffmpeg -i inter.dts -ac 2 -ab 640k out.ac3
$ ffmpeg -i inter.dts -ac 2 -ab 320k out.mp2


1 = Good
2 = Good
3 = Bad
4 = Good
and 1 you didn't list, AC3 = Bad


___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user


Re: [FFmpeg-user] Input 5.1 DTS, output 2.0 MP3: Atrocious Quality

2015-05-16 Thread Carl Eugen Hoyos
Moritz Barsnick barsnick at gmx.net writes:

 $ ffmpeg -loglevel debug -i inter.dts -ac 2 -c:a libmp3lame -f null -
 $ ffmpeg -loglevel debug -i inter.dts -ac 2 -c:a pcm_s16le -f null -
 You can insert other arbitrary codecs at will.
 
 The former shows a matrix:
 1.00 0.00 0.707107 0.00 0.707107 0.00
 0.00 1.00 0.707107 0.00 0.00 0.707107
 [auto-inserted resampler 0  at  0xb713840] ch:6 chl:5.1(side) 
 fmt:fltp r:48000Hz - ch:2 chl:stereo
 fmt:fltp r:48000Hz
 
 while the latter shows:
 0.414214 0.00 0.292893 0.00 0.292893 0.00
 0.00 0.414214 0.292893 0.00 0.00 0.292893
 [auto-inserted resampler 0  at  0xb3b55c0] ch:6 chl:5.1(side) 
 fmt:fltp r:48000Hz - ch:2 chl:stereo
 fmt:s16 r:48000Hz
 
 I think this may be the described behavior.

If this really is the issue, it should be reproducible 
with at least one of the command lines I proposed 
(namely for -acodec pcm_f32le) and it is possible to 
work-around the issue by forcing s16p as the mp3 
encoding format. The mp3 encoder accepts fltp, s16p 
and s32p.

But I would really appreciate if somebody can confirm 
that the issue is reproducible with pcm_f32le (and 
neither with s16le nor s32le).

Carl Eugen

___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user


Re: [FFmpeg-user] Input 5.1 DTS, output 2.0 MP3: Atrocious Quality

2015-05-16 Thread Moritz Barsnick
On Sat, May 16, 2015 at 13:07:01 +0200, Moritz Barsnick wrote:
 [auto-inserted resampler 0 @ 0xb713840] ch:6 chl:5.1(side) fmt:fltp r:48000Hz 
 - ch:2 chl:stereo fmt:fltp r:48000Hz
 [auto-inserted resampler 0 @ 0xb3b55c0] ch:6 chl:5.1(side) fmt:fltp r:48000Hz 
 - ch:2 chl:stereo fmt:s16 r:48000Hz

 (Unfortunately, my math tells me that the former matrix is bound to
 cause overflows with value-restricted numerical formats. There's
 something I don't seem to understand there. And is LFE really ignored
 when downmixing?)

Ah, I see the difference now. In one case, it's outputting to floating
point, so no clipping is expected. In the other case (depending on
encoder obviously), it's assuming integer output.

Moritz
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user


Re: [FFmpeg-user] Input 5.1 DTS, output 2.0 MP3: Atrocious Quality

2015-05-16 Thread Carl Eugen Hoyos
Bazza lamia at jeack.com.au writes:

 $ ffmpeg -i inter.dts -ac 2 out16.wav
 $ ffmpeg -i inter.dts -ac 2 -acodec pcm_s32le out32.wav
 $ ffmpeg -i inter.dts -ac 2 -ab 640k out.ac3
 $ ffmpeg -i inter.dts -ac 2 -ab 320k out.mp2
 
 1 = Good
 2 = Good
 3 = Bad
 4 = Good
 and 1 you didn't list, AC3 = Bad

Since your answer makes no sense (is ac3 doubly bad?), 
maybe you could map 1, 2, 3, 4 to out.mp2, out.ac3 and 
the two wav files?

Carl Eugen

___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user


Re: [FFmpeg-user] Input 5.1 DTS, output 2.0 MP3: Atrocious Quality

2015-05-16 Thread Bazza
On Sat, 16 May 2015 10:25:09 + (UTC), Carl Eugen Hoyos
ceho...@ag.or.at wrote:

Since your answer makes no sense (is ac3 doubly bad?), 
maybe you could map 1, 2, 3, 4 to out.mp2, out.ac3 and 
the two wav files?

They say a picture is worth 1000 words etc so I'll do it this way.

This is John's problem. Bad sound when 'downing' 5.1 to stereo.
In his case, an attempt to use libmp3lame. Ignoring bitrates, the
problem seems to boil down to whether the '-ac 2' option is being
fully honoured (in channel numbers AND levels). 
The simple command 'ffmpeg -i inter.dts -ac 2 -ab 320k out.mp3',
for an MP3 file, will produce this result. Plainly distorted. -)
The links are captured PNG image files from Adobe's Audition.
http://www.datafilehost.com/d/ef36d01a


You asked for 4 tests to be carried out. 
Here they are. In order.

1). 
 $ ffmpeg -i inter.dts -ac 2 out16.wav
Conversions to WAV types are OK and will downmix. 
This one did. Sounds are fine
http://www.datafilehost.com/d/85290f50

2). 
 $ ffmpeg -i inter.dts -ac 2 -acodec pcm_s32le out32.wav
Likewise for this other (32) codec. Performed as expected.
http://www.datafilehost.com/d/fb55d8fe

3).
 $ ffmpeg -i inter.dts -ac 2 -ab 640k out.ac3
The process FAILS in this case(s). For AC3 and AAC.
For these types of outputs, Audition does not recognize
the file types so, to get around the problem of display,
the AC3 and AAC types were converted back into a WAV type.
The channels are there. The output level is just overloaded.
The resultant output is virtually identical to John's initial
problem wherein (I guess) the input channels are 'unweighted'
http://www.datafilehost.com/d/932be2b6

4).
 $ ffmpeg -i inter.dts -ac 2 -ab 320k out.mp2
I initially thought that the MP2 was similarly irregular but
now, I think I got myself confused with all the test files.
This MP2 conversion appears to be OK. It too, is not importable
into Audition so like (3) above, it had to be rendered to WAV.
However, it seems to behave properly as expected. 
http://www.datafilehost.com/d/859a9402

This is as far as I can go. 
I'd like to believe that '-ac 2' was universal -)
It is, in the sense that all channels are mixed.
The volume option is a workaround. 

___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user


Re: [FFmpeg-user] Input 5.1 DTS, output 2.0 MP3: Atrocious Quality

2015-05-15 Thread Marcus Johnson
Maybe that's because you're converting lossy audio to another lossy audio
format?
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user


Re: [FFmpeg-user] Input 5.1 DTS, output 2.0 MP3: Atrocious Quality

2015-05-15 Thread Bazza
On Fri, 15 May 2015 23:04:06 -0500, John L orionf...@hotmail.com
wrote:

Backstory: I have a system in place to automagically convert video files to 
smaller formats/versions on request to have a sort of mobile version for my 
father who travels extensively. The purpose is so that he can fit 
significantly more videos on his tablet than if they were the high quality 
rips.

It all boils down to:
ffmpeg -i [input-file] -ac 2 -c:v libx264 -c:a libmp3lame -b:v 1024k -preset 
fast [output-file]

I was under the impression everything was hunky dory until I took a bunch of 
the shrunken movies on my phone on a roadtrip. A good many of the videos were 
as good as can be expected, and nothing was egregiously wrong. However on a 
few videos the audio was absolutely atrocious, blown out, clipping, and just 
noise from seemingly nowhere. 

One of the worst was Intersteller which was completely unwatchable after the 
first two minutes with all the blown out crescendos, pops, cracks, static, and 
voices of the deep adulterating the audio stream. All video files affected by 
this were 5.1DTS sources, but not all 5.1DTS were affected.

When talking with my father he said it was a frequent enough occurrence that 
he suspected it was just because I had shrunk the file so small and was an 
artifact of that. He did confirm that most videos that were affected weren't 
as bad as the Interstellar conversion.



~/testing$ ffmpeg -version
ffmpeg version 2.5.6-0ubuntu0.15.04.1 Copyright (c) 2000-2015 the FFmpeg 
developers
built with gcc 4.9.2 (Ubuntu 4.9.2-10ubuntu13)
configuration: --prefix=/usr --extra-version=0ubuntu0.15.04.1 
--build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu 
--shlibdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu 
--enable-gpl --enable-shared --disable-stripping --enable-avresample 
--enable-avisynth --enable-ladspa --enable-libass --enable-libbluray 
--enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite 
--enable-libfontconfig --enable-libfreetype --enable-libfribidi 
--enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame 
--enable-libopenjpeg --enable-libopus --enable-libpulse 
--enable-libschroedinger --enable-libshine --enable-libspeex --enable-libssh 
--enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libwavpack 
--enable-libwebp --enable-lib
 xvid --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 
 --enable-libzvbi --enable-libzmq --enable-frei0r --enable-libvpx 
 --enable-libx264 --enable-libsoxr --enable-gnut
 ls --enable-openal --enable-libopencv --enable-librtmp --enable-libx265
libavutil  54. 15.100 / 54. 15.100
libavcodec 56. 13.100 / 56. 13.100
libavformat56. 15.102 / 56. 15.102
libavdevice56.  3.100 / 56.  3.100
libavfilter 5.  2.103 /  5.  2.103
libavresample   2.  1.  0 /  2.  1.  0
libswscale  3.  1.101 /  3.  1.101
libswresample   1.  1.100 /  1.  1.100
libpostproc53.  3.100 / 53.  3.100


To troubleshoot I copied out a particularly bad snippet of audio
ffmpeg -i Int*.mkv -vn -c copy -ss 1:30 -t 0:30 inter.dts

Yes. That snippet has about 6 tracks. 
Some of them are clipping (all on their own).

This audio clip is confirmed to be a good 5.1dts stream

Good? Well OK -)

ffmpeg -i inter.dts -ac 2 -c libmp3lame inter-test.mp3
This audio sample has the exact same audio defects as in the shrunken video 

Correct. All tracks (some of which had reached maximum encodable
levels) are now being added/summed into 1 single (now) overloaded
stream.

Instead, take the 5.1 and _DOWNMIX_ all tracks to a single stereo for
the phone/tablet by declaring -acodec  -ac 2. No intermediate
steps should be required. Consider also - Do you need pcm_s32le ?
pcm_s16le is usual.

 


___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user