Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How do I check a video file audio track is what it pretends?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Multimedia
View previous topic :: View next topic  
Author Message
VinzC
Advocate
Advocate


Joined: 17 Apr 2004
Posts: 4691
Location: Theux (Belgium)

PostPosted: Sat Feb 08, 2014 11:46 pm    Post subject: How do I check a video file audio track is what it pretends? Reply with quote

Hi.

I have a video file which is supposed to deliver 6 CHannels but mplayer desperately plays it in stereo only. Any attempt at forcing 6 channels results in mplayer pooping with an error message about “unsupported sample type”.
mplayer -ao alsa:device=spdif -afm hwac3, -channels 6 -af channels=6,lavcac3enc=1:640:3 file.mp4:
...
AUDIO: 48000 Hz, 6 ch, floatle, 149.6 kbit/1.62% (ratio: 18697->1152000)
...
[ac3_fixed @ 0x7faffcde3b80]Specified sample format s16 is invalid or not supported
...

mplayer -af scaletempo,format=ac3le,channels=6,lavcac3enc=1:448:3 file.mp4:
...
AUDIO: 48000 Hz, 6 ch, floatle, 149.6 kbit/1.62% (ratio: 18697->1152000)
...
[format] Sample format little-endian AC3 not yet supported
[libaf] Reinitialization did not work, audio filter 'format' returned error code -2
...

But this plays stereo
mplayer -af format=s32le,channels=6 file.mp4:
...
AUDIO: 48000 Hz, 6 ch, floatle, 149.6 kbit/1.62% (ratio: 18697->1152000)
Codec audio sélectionné : [ffaac] afm : ffmpeg (FFmpeg AAC (MPEG-2/MPEG-4 Audio))
...
AO: [alsa] 48000Hz 2ch s32le (4 bytes per sample)
...


midentify file.mp4 | grep AUDIO:
ID_AUDIO_FORMAT=MP4A
ID_AUDIO_BITRATE=149576
ID_AUDIO_RATE=48000
ID_AUDIO_NCH=6
ID_AUDIO_BITRATE=149576
ID_AUDIO_RATE=48000
ID_AUDIO_NCH=6
ID_AUDIO_CODEC=ffaac


FTR I have a DTS compatible amp' and am using my PC's SPDIF output. I have many video files which play successfully in DTS and AC3.

So I basically want to make sure the audio track is indeed what it pretends to be, eventually eliminating bad encoding. And since I know mplayer can reencode audio on the fly, is there a way to convert the audio format to one that qould be accepted by my amplifier through the SPDIF channel?

[I tried Paul Bredbury's .asoundrc but it didn't work. No idea if it's sufficient to save the file as is though.]

Thanks in advance for any hint or suggestion.
_________________
Gentoo addict: tomorrow I quit, I promise!... Just one more emerge...
GNU/Linux user #369763
“Wow! I feel root”
Back to top
View user's profile Send private message
Wintershade
n00b
n00b


Joined: 21 Jul 2007
Posts: 29
Location: Croatia

PostPosted: Mon Feb 10, 2014 9:53 pm    Post subject: Reply with quote

Hi man! this may be a shot in the dark but...

have you tried any other video file with multichannel audio?
Also, what does ffmpeg -i <your file> say?

mplayer is notorious for giving wrong information when identifying stuff, at least for me...
_________________
Only the best is good enough.

My make.conf file
Back to top
View user's profile Send private message
VinzC
Advocate
Advocate


Joined: 17 Apr 2004
Posts: 4691
Location: Theux (Belgium)

PostPosted: Wed Feb 12, 2014 8:28 pm    Post subject: Reply with quote

Hi Wintershade, thanks. Didn't mention it but, yes, I did give ffmpeg a try (or of some sort like ffplay) and it did play stereo only -- I can see from the LEDs on my amp' when it switches to surround mode, it didn't. I'm still puzzled because I think I compiled mplayer with ffmpeg backend so both might want to give the very same results.
_________________
Gentoo addict: tomorrow I quit, I promise!... Just one more emerge...
GNU/Linux user #369763
“Wow! I feel root”
Back to top
View user's profile Send private message
Wintershade
n00b
n00b


Joined: 21 Jul 2007
Posts: 29
Location: Croatia

PostPosted: Wed Feb 12, 2014 9:19 pm    Post subject: Reply with quote

Please post the output of ffmpeg -i <your file>.

Also...
Quote:
I think I compiled mplayer with ffmpeg backend

what exactly do you mean by this? I've just checked the USE flags for mplayer (both amd64 and ~amd64) and I haven't seen ffmpeg in that list...

what does emerge --info mplayer say?
_________________
Only the best is good enough.

My make.conf file
Back to top
View user's profile Send private message
Fitzcarraldo
l33t
l33t


Joined: 30 Aug 2008
Posts: 661
Location: United Kingdom

PostPosted: Wed Feb 12, 2014 11:43 pm    Post subject: Reply with quote

VinzC wrote:
How do I check a video file audio track is what it pretends?

Have you tried using MediaInfo?

Code:
# emerge mediainfo

Code:
$ mediainfo -f ~/Videos/avatar2009aug0820a-tsr_h1080p.mov | sed -n '/Audio$/,/Other/p'
Audio
Count                                    : 222
Count of stream of this kind             : 1
Kind of stream                           : Audio
Kind of stream                           : Audio
Stream identifier                        : 0
StreamOrder                              : 1
ID                                       : 2
ID                                       : 2
Format                                   : AAC
Format/Info                              : Advanced Audio Codec
Commercial name                          : AAC
Format profile                           : LC
Codec ID                                 : 40
Codec                                    : AAC LC
Codec                                    : AAC LC
Codec/Family                             : AAC
Codec/CC                                 : 40
Duration                                 : 129171
Duration                                 : 2mn 9s
Duration                                 : 2mn 9s 171ms
Duration                                 : 2mn 9s
Duration                                 : 00:02:09.171
Source duration                          : 129173
Source duration                          : 2mn 9s
Source duration                          : 2mn 9s 173ms
Source duration                          : 2mn 9s
Source duration                          : 00:02:09.173
Bit rate mode                            : CBR
Bit rate mode                            : Constant
Bit rate                                 : 448000
Bit rate                                 : 448 Kbps
Channel count                            : 6
Channel count                            : 6 channels
Channel positions                        : Front: L C R, Side: L R, LFE
Channel positions                        : 3/2/0.1
ChannelLayout                            : C L R Ls Rs LFE
Sampling rate                            : 48000
Sampling rate                            : 48.0 KHz
Samples count                            : 6200208
Frame count                              : 6055
Source frame count                       : 6055
Compression mode                         : Lossy
Compression mode                         : Lossy
Delay                                    : 3597417
Delay                                    : 59mn 57s
Delay                                    : 59mn 57s 417ms
Delay                                    : 59mn 57s
Delay                                    : 00:59:57.417
Delay_DropFrame                          : No
Delay, origin                            : Container
Delay, origin                            : Container
Delay relative to video                  : 0
Video0 delay                             : 0
Stream size                              : 7501687
Stream size                              : 7.15 MiB (4%)
Stream size                              : 7 MiB
Stream size                              : 7.2 MiB
Stream size                              : 7.15 MiB
Stream size                              : 7.154 MiB
Stream size                              : 7.15 MiB (4%)
Proportion of this stream                : 0.04309
Source stream size                       : 7501687
Source stream size                       : 7.15 MiB (4%)
Source stream size                       : 7 MiB
Source stream size                       : 7.2 MiB
Source stream size                       : 7.15 MiB
Source stream size                       : 7.154 MiB
Source stream size                       : 7.15 MiB (4%)
Source_StreamSize_Proportion             : 0.04309
Language                                 : en
Language                                 : English
Language                                 : English
Language                                 : en
Language                                 : eng
Language                                 : en
Encoded date                             : UTC 2009-08-18 16:44:12
Tagged date                              : UTC 2009-08-20 13:39:59

Other

_________________
Fitzcarraldo's blog
Back to top
View user's profile Send private message
Wintershade
n00b
n00b


Joined: 21 Jul 2007
Posts: 29
Location: Croatia

PostPosted: Thu Feb 13, 2014 12:29 am    Post subject: Reply with quote

+1 to that, Mediainfo rocks. I somehow always forget about it, probably cos I'm used to ffmpeg.
Again, it would be useful to know whether it's just this file that has issues with mplayer, or every file that has multichannel audio. Have you tried playing anything else? Were the results same, or...?
_________________
Only the best is good enough.

My make.conf file
Back to top
View user's profile Send private message
VinzC
Advocate
Advocate


Joined: 17 Apr 2004
Posts: 4691
Location: Theux (Belgium)

PostPosted: Thu Feb 13, 2014 7:34 pm    Post subject: Reply with quote

I didn't even know of mediainfo :oops: . Here's what it tells about the audio part:
mediainfo:
Audio
ID                                       : 2
Format                                   : AAC
Format/Info                              : Advanced Audio Codec
Format profile                           : LC
Codec ID                                 : 40
Duration                                 : 1h 30mn
Bit rate mode                            : Variable
Bit rate                                 : 150 Kbps
Maximum bit rate                         : 167 Kbps
Channel count                            : 6 channels
Channel positions                        : Front: L C R, Side: L R, LFE
Sampling rate                            : 48.0 KHz
Compression mode                         : Lossy
Stream size                              : 97.3 MiB (5%)
Language                                 : English
Encoded date                             : UTC 2014-01-09 07:11:42
Tagged date                              : UTC 2014-01-10 01:18:42

So it really looks like there's something going wrong somewhere. Melikes to know what could, possibly :D .

Wintershade wrote:
Have you tried playing anything else? Were the results same, or...?

Oh, yes, I did. I tried mplayer2, vlc; same thing. As for «playing something else», as in «other video files with surround audio», yes I did. And it's not the first surround experience in fact. I have quite a few other files that play surround sound and my amp switches appropriately.
_________________
Gentoo addict: tomorrow I quit, I promise!... Just one more emerge...
GNU/Linux user #369763
“Wow! I feel root”
Back to top
View user's profile Send private message
Wintershade
n00b
n00b


Joined: 21 Jul 2007
Posts: 29
Location: Croatia

PostPosted: Thu Feb 13, 2014 8:44 pm    Post subject: Reply with quote

VinzC wrote:
As for «playing something else», as in «other video files with surround audio», yes I did. And it's not the first surround experience in fact. I have quite a few other files that play surround sound and my amp switches appropriately.


So if I understand this correctly, on other files, surround sound plays as it should?
If that's the case, then your video file is the problem. I've had quite a few bad experiences with poorly encoded video (and audio) files.
This thread on ffmpeg.org might give you a bit of info and ideas where to search next. FFmpeg documentation can also provide you with bits of insight on how to map your audio channels properly, now that you have the information from mediainfo.

Also, try this...
Code:
ffmpeg -i <your file> -acodec copy -vcodec copy <new file>.mkv


Be sure to convert it to .mkv. It's arguably the best container for modern video. Even if your video already is in .mkv, try it.
What this command will do, essentially, is repack your video and audio into another file, and put it in the .mkv container. It won't transcode anything (hence the copy in the line - it's literally a direct stream copy), so don't worry about any quality loss. You'll probably have to do this in any case, especially if you'll have to remap audio channels, as mentioned above.
_________________
Only the best is good enough.

My make.conf file
Back to top
View user's profile Send private message
beandog
Developer
Developer


Joined: 04 May 2003
Posts: 2014
Location: /usa/utah

PostPosted: Mon Feb 17, 2014 4:21 am    Post subject: Reply with quote

Wintershade wrote:


Also, try this...
Code:
ffmpeg -i <your file> -acodec copy -vcodec copy <new file>.mkv


Be sure to convert it to .mkv. It's arguably the best container for modern video. Even if your video already is in .mkv, try it.
What this command will do, essentially, is repack your video and audio into another file, and put it in the .mkv container. It won't transcode anything (hence the copy in the line - it's literally a direct stream copy), so don't worry about any quality loss. You'll probably have to do this in any case, especially if you'll have to remap audio channels, as mentioned above.


Or just use mkvtoolnix:

Code:
mkvmerge -o file.mkv file.mp4

_________________
If it ain't broke, tweak it. packages | dvds | blurays | blog | home
Back to top
View user's profile Send private message
VinzC
Advocate
Advocate


Joined: 17 Apr 2004
Posts: 4691
Location: Theux (Belgium)

PostPosted: Thu Feb 20, 2014 9:13 pm    Post subject: Reply with quote

Thanks again guys. I converted the video container to Matroska but unfortunately nothing has changed :( . Here's what I get when I play the file, be it (no matter before or after converting this said):
Code:
...
Selected audio codec: AAC (Advanced Audio Coding) [libavcodec]
AUDIO: 48000 Hz, 6 ch, floatle, 128.0 kbit/1.39% (ratio: 16000->1152000)
[AO_ALSA] Format floatle is not supported by hardware, trying default.
AO: [alsa] 48000Hz 2ch s16le (2 bytes per sample)
Starting playback...

My amp still plays stereo sound although the MKV file is detected as 6CH:
midentify:
ID_VIDEO_ID=0
ID_AUDIO_ID=0
ID_AID_0_LANG=eng
ID_CLIP_INFO_NAME0=MAJOR_BRAND
ID_CLIP_INFO_VALUE0=isom
ID_CLIP_INFO_NAME1=MINOR_VERSION
ID_CLIP_INFO_VALUE1=1
ID_CLIP_INFO_NAME2=COMPATIBLE_BRANDS
ID_CLIP_INFO_VALUE2=isomavc1
ID_CLIP_INFO_NAME3=ENCODER
ID_CLIP_INFO_VALUE3=Lavf54.63.104
ID_CLIP_INFO_N=4
ID_FILENAME=/tmp/file.mkv
ID_DEMUXER=lavfpref
ID_VIDEO_FORMAT=H264
ID_VIDEO_BITRATE=0
ID_VIDEO_WIDTH=1888
ID_VIDEO_HEIGHT=784
ID_VIDEO_FPS=23.976
ID_VIDEO_ASPECT=2.4082
ID_AUDIO_FORMAT=MP4A
ID_AUDIO_BITRATE=0
ID_AUDIO_RATE=48000
ID_AUDIO_NCH=6
ID_START_TIME=0.00
ID_LENGTH=5456.70
ID_SEEKABLE=1
ID_CHAPTERS=0
ID_VIDEO_CODEC=ffh264
ID_AUDIO_BITRATE=0
ID_AUDIO_RATE=48000
ID_AUDIO_NCH=6
ID_AUDIO_CODEC=ffaac

And with mediainfo
Code:
Audio
ID                                       : 2
Format                                   : AAC
Format/Info                              : Advanced Audio Codec
Format profile                           : LC
Codec ID                                 : A_AAC
Duration                                 : 1h 30mn
Channel count                            : 6 channels
Channel positions                        : Front: L C R, Side: L R, LFE
Sampling rate                            : 48.0 KHz
Compression mode                         : Lossy
Delay relative to video                  : 1mn 5s
Language                                 : English
Default                                  : Yes
Forced                                   : No
Encoded date                             : UTC 2014-01-09 07:11:42
HANDLER_NAME                             : Sound Media Handler

Is there something my amplifier is responsible for? (It's a rather "old" amp by the way, a Denon AVR1800.)

EDIT: Trusting mplayer's ability to downsample in realtime I ran mplayer -af s16le <my video file>, still playing in stereo. Losing my religion on this one!
_________________
Gentoo addict: tomorrow I quit, I promise!... Just one more emerge...
GNU/Linux user #369763
“Wow! I feel root”


Last edited by VinzC on Sat Feb 22, 2014 9:53 am; edited 1 time in total
Back to top
View user's profile Send private message
Nicias
Guru
Guru


Joined: 06 Dec 2005
Posts: 400

PostPosted: Fri Feb 21, 2014 8:14 pm    Post subject: Reply with quote

You can check to see if that six channels are different. I think this will produce six files with the six different channels:
Code:
for x in {0..5} ; do  ffmpeg -i <your file> -map 0:a -map_channel 0.1.$x -acodec mp3 out-$x.mp3; done
assuming your file has audio on stream 1. (see the output of ffprobe)
Back to top
View user's profile Send private message
VinzC
Advocate
Advocate


Joined: 17 Apr 2004
Posts: 4691
Location: Theux (Belgium)

PostPosted: Sat Feb 22, 2014 10:56 am    Post subject: Reply with quote

Thanks a lot Nicias. Indeed they're all different, kind of feels relieving :D . Now it looks like it all boils down to telling mplayer to convert "floatle" samples to something like "s16le" or "s32le" on-the-fly, right?
_________________
Gentoo addict: tomorrow I quit, I promise!... Just one more emerge...
GNU/Linux user #369763
“Wow! I feel root”
Back to top
View user's profile Send private message
VinzC
Advocate
Advocate


Joined: 17 Apr 2004
Posts: 4691
Location: Theux (Belgium)

PostPosted: Mon Feb 24, 2014 10:55 pm    Post subject: Reply with quote

Hey, know what? I upgraded media-libs/x264, recompiled ffmpeg and mplayer2 and now — tadaaaaa — it works and I get surround sound:
mplayer2 -channels 6 -af scaletempo,lavcac3enc=1:640:3 file.mp4:
...
Selected audio codec: AAC (Advanced Audio Coding) [libavcodec]
AUDIO: 48000 Hz, 6 ch, floatle, 149.6 kbit/1.62% (ratio: 18697->1152000)
[ac3 @ 0x7effd3faeb80]Channel layout not specified
[ac3 @ 0x7effd3faeb80]No channel layout specified. The encoder will guess the layout, but it might be incorrect.
[AO_ALSA] Format ac3be is not supported by hardware, trying default.
AO: [alsa] 48000Hz 2ch ac3le (2 bytes per sample)
...

At least now I have surround sound despite the possibly "incorrect" guessing. Note: these settings still do not work with mplayer.
_________________
Gentoo addict: tomorrow I quit, I promise!... Just one more emerge...
GNU/Linux user #369763
“Wow! I feel root”
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Multimedia All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum