Skip to main content
Topic: Re: how to extract the raw aac from MPEG2 TS? (Read 1592 times) previous topic - next topic - Topic derived from how to extract the ra...
0 Members and 1 Guest are viewing this topic.

Re: how to extract the raw aac from MPEG2 TS?

Reply #25
Wow ... that stubborn thing was quite a pita ... :D

However, I managed to extract the audio stream into a playable format without any re-encoding, using a combination of ffmpeg and yamb.

Step1:
Extract audio stream from the original ts file with ffmpeg and put it into m4a container
Code: [Select]
ffmpeg -i bruno.ts -map 0:a -acodec copy "bruno_audio_ffmpeg.m4a"
-> result cannot be played back in MPC-HC


Step2:
Demux the resulting file with YAMB to raw audio stream (bruno_ffmpeg_yamb.m4a)
-> result plays back fine in MPC-HC, but cannot be scrubbed


Step3: remux the yamb output with ffmpeg to Quicktime container
Code: [Select]
ffmpeg -i bruno_audio_ffmpeg.m4a -map 0:a -acodec copy -f mov "bruno_ffmpeg_yamb_QT.mov"
-> result plays back fine in MPC-HC, and can be scrubbed


Step4: repeat Step 1
Remux ffmpeg's QT output to m4a using ffmpeg
Code: [Select]
ffmpeg -i bruno_ffmpeg_yamb_QT.mov -map 0:a -acodec copy "bruno_audio_final.m4a"
-> result plays back fine in MPC-HC, and can be scrubbed


Interestingly, Step3 resulted in a change of the format tag from "LATM/AAC" to "MPEG-4/ADPCM", but it is still the original stream inside with a variable bitrate of ~128kb/s, since no transcoding was involved at any stage.

You can grab the result here.

:)

Let me know, if it plays back fine on your end as well or if you encounter any issues.

Cheers,
Maggi

Re: Re: how to extract the raw aac from MPEG2 TS?

Reply #26
Step2:
Demux the resulting file with YAMB to raw audio stream (bruno_ffmpeg_yamb.m4a)
Does YAMB output a "raw audio stream" and yet give it the suffix "m4a"?

It is easier to ask than to download 8 GB, so:
* What happens if ffmpeg tries to output raw aac, like:
ffmpeg -i bruno.ts -map 0:a -acodec copy "bruno_audio_ffmpeg.aac"
* Bitstream filters are only for "the other direction"?
* There is a "latm" option mentioned at https://ffmpeg.org/ffmpeg-formats.html#Format-Options ... ?

Re: how to extract the raw aac from MPEG2 TS?

Reply #27
Step2:
Demux the resulting file with YAMB to raw audio stream (bruno_ffmpeg_yamb.m4a)
Does YAMB output a "raw audio stream" and yet give it the suffix "m4a"?
Damn good catch, Porcus ... ;)

No, there was no extension, but I was lazy and added m4a so that MPC-HC would open it for me.
The actual output was named "bruno_ffmpeg_track1" and when I manually drag it onto MPC-HC, I get this basic information
Code: [Select]
Audio: AAC(LATM) 48000Hz stereo [A: aac (latm) he-aac, 48000 Hz, stereo]
MediaInfo reports:
Code: [Select]
General 
Complete name : bruno_ffmpeg_track1
Format : LATM
File size : 69.5 MiB
Overall bit rate mode : Variable

Audio
Format : AAC
Format/Info : Advanced Audio Codec
Format profile : HE-AAC / LC
Format settings : NBC
Codec ID : 5
Bit rate mode : Variable
Channel(s) : 2 channels
Channel positions : Front: L R
Sampling rate : 48.0 kHz / 24.0 kHz
Frame rate : 23.438 FPS (1024 SPF)
Compression mode : Lossy
Which are both exactly the same as from the file I manually added the m4a extension to.

* What happens if ffmpeg tries to output raw aac, like:
ffmpeg -i bruno.ts -map 0:a -acodec copy "bruno_audio_ffmpeg.aac"
It results in a file that cannot be played back at all and has severly broken meta data.

MediaInfo says:
Code: [Select]
General 
Complete name : bruno_ffmpeg.aac
Format : ADTS
Format/Info : Audio Data Transport Stream
File size : 70.2 MiB
Overall bit rate mode : Variable
Comment : q¾ë•mGð­\àÙï#ÕóG£¤ôF/õœà°•sEj)ýÈÕ…d½#õˆ4.ᓸ™ñòÂОÈFàHzÿ]„`ÀŽTMۍ§ / ðý;µC‹î7¿ší—z™G• ÷i(åöJØoÁxôÚš–8wrJÕ¶+%͐t`á

Audio
Format : AAC
Format/Info : Advanced Audio Codec
Format version : Version 4
Format profile : HE-AAC / LC
Format settings : NBC
Codec ID : 2
Bit rate mode : Variable
Channel(s) : 21 channels
Channel positions : Front: 12, Side: 7, Back: C, LFE
Sampling rate : 48.0 kHz / 24.0 kHz
Frame rate : 23.438 FPS (1024 SPF)
Compression mode : Lossy
Stream size : 70.2 MiB (100%)
 

* Bitstream filters are only for "the other direction"?
dunno and tbh, I couldn't be bothered to dig for other approaches, after I started making progress with ffmpeg & yamb
;)

* There is a "latm" option mentioned at https://ffmpeg.org/ffmpeg-formats.html#Format-Options ... ?
I've seen that option too, but as I understand it, this is only used for muxing into TS and I wanted to demux the audio stream, so I didn't pay any further attention to it.

Feel free to ask more...  8)

Cheers !
Maggi


Re: Re: how to extract the raw aac from MPEG2 TS?

Reply #29
Yo can check it out with ffmpeg using the hash multiplexer:

ffmpeg -i audio -f hash -hash sha512 audio.txt
ffmpeg -i video -vn -f hash -hash sha512 video.txt

If both hashes are the same then the audio track is the same, this is true unless the file was decoded to lossless as then the decodec file can have the same hash. The commands are different due the need to discard the video part from the video file, and if there where various audio tracks then a selection track switch is needed.

Re: Re: how to extract the raw aac from MPEG2 TS?

Reply #30
Yo can check it out with ffmpeg using the hash multiplexer:

ffmpeg -i audio -f hash -hash sha512 audio.txt
ffmpeg -i video -vn -f hash -hash sha512 video.txt

If both hashes are the same then the audio track is the same, this is true unless the file was decoded to lossless as then the decodec file can have the same hash. The commands are different due the need to discard the video part from the video file, and if there where various audio tracks then a selection track switch is needed.
Yo can check it out with ffmpeg using the hash multiplexer:

ffmpeg -i audio -f hash -hash sha512 audio.txt
ffmpeg -i video -vn -f hash -hash sha512 video.txt

If both hashes are the same then the audio track is the same, this is true unless the file was decoded to lossless as then the decodec file can have the same hash. The commands are different due the need to discard the video part from the video file, and if there where various audio tracks then a selection track switch is needed.
can you try to do it, i'm not good at it
please

Re: how to extract the raw aac from MPEG2 TS?

Reply #31
So at least with my build:
* No "latm" in the output of "ffmpeg -demuxers".
* But "latm" is listed in the output of "ffmpeg -muxers".  And of "ffmpeg -formats".

I take that to mean that ffmpeg considers this "write-only".

* There is a "latm" option mentioned at https://ffmpeg.org/ffmpeg-formats.html#Format-Options ... ?
I've seen that option too, but as I understand it, this is only used for muxing into TS and I wanted to demux the audio stream, so I didn't pay any further attention to it.

Obviously. I only took note that it is mentioned not only in section 4 ("Muxers") but also in section 2, which claims to concern "some generic global options, which can be set on all the muxers and demuxers". But there is no demuxer for it ... at least not in my build.

Re: Re: how to extract the raw aac from MPEG2 TS?

Reply #32
thry give me the same hash, then they are the same audio track.

Re: how to extract the raw aac from MPEG2 TS?

Reply #33
Ok this is the original cd in flac

https://mega.nz/#!gwhExKTB!HoFR8Sy8Up5IJvJA7DQ10vrPYmdX4Wu2N36aFqv8TW8
AND

This is the 8gb video file from a DVD that you were testing
https://mega.nz/#!t4hwFJpb!YJhkhFW4m045ongO5lyOGeguZbIFfV3KAUwcC7nmMhQ

They have the same songs from the same Bruno Mars Concert in Brazil, Sao Paulo

Can you compare the sound quality and tell me which one sounds better to you?

Please
Let me know I'm really interested
I know which one I prefer but would like your advice as well

Thank you in advance guys
Happy listening

Re: Re: how to extract the raw aac from MPEG2 TS?

Reply #34
Yo can check it out with ffmpeg using the hash multiplexer:

ffmpeg -i audio -f hash -hash sha512 audio.txt
ffmpeg -i video -vn -f hash -hash sha512 video.txt

If both hashes are the same then the audio track is the same, this is true unless the file was decoded to lossless as then the decodec file can have the same hash. The commands are different due the need to discard the video part from the video file, and if there where various audio tracks then a selection track switch is needed.
I have tried that
I have used the original Bruno.ts (8GB) file to check if the audio quality is identical with hash multiplexer:
ffmpeg -i audio -f hash -hash sha512 audio.txt
ffmpeg -i video -vn -f hash -hash sha512 video.txt
BUT the audio hash was different from the video hash, I thought at least the same source file for both commands will give me the same hash
I don't get it

Re: Re: how to extract the raw aac from MPEG2 TS?

Reply #35
Yo can check it out with ffmpeg using the hash multiplexer:

ffmpeg -i audio -f hash -hash sha512 audio.txt
ffmpeg -i video -vn -f hash -hash sha512 video.txt

If both hashes are the same then the audio track is the same, this is true unless the file was decoded to lossless as then the decodec file can have the same hash. The commands are different due the need to discard the video part from the video file, and if there where various audio tracks then a selection track switch is needed.
I have tried that
I have used the original Bruno.ts (8GB) file to check if the audio quality is identical with hash multiplexer:
ffmpeg -i audio -f hash -hash sha512 audio.txt
ffmpeg -i video -vn -f hash -hash sha512 video.txt
BUT the audio hash was different from the video hash, I thought at least the same source file for both commands will give me the same hash
I don't get it

That is due to how the hash multiplexer works, also how I put it is confusing as audio was intended to reference thee aac file and video to reference the ts file. Those comands where not perfect but they where fit for you case as there where only one audio and on video stream in the ts file.

This calculate the hash of the decoded data: "ffmpeg -i input -f hash -hash sha512 output" it autoselects the beast audio and video streams (and the first high quality one when various streams have hightest quality at the same time), this line give different hash if the file contains only audio or audio+video, "-vn" disables the video making that ffmpeg only calculates the data of the best audio stream. A more correct comand for calculating hash of and individual audio stream is using "-map" like in "ffmpeg -i input -map a:0 -f hash -hash sha512 out" the "-a:0" mean fist audio stream (second audio stream is "-a:1" and so on).

And for the quality of the audio is a personal matter as I think that the CD is going to be compressed to boot loudness where the one in the ts is going to have more dinamic range.

 

Re: Re: how to extract the raw aac from MPEG2 TS?

Reply #36
Yo can check it out with ffmpeg using the hash multiplexer:

ffmpeg -i audio -f hash -hash sha512 audio.txt
ffmpeg -i video -vn -f hash -hash sha512 video.txt

If both hashes are the same then the audio track is the same, this is true unless the file was decoded to lossless as then the decodec file can have the same hash. The commands are different due the need to discard the video part from the video file, and if there where various audio tracks then a selection track switch is needed.
I have tried that
I have used the original Bruno.ts (8GB) file to check if the audio quality is identical with hash multiplexer:
ffmpeg -i audio -f hash -hash sha512 audio.txt
ffmpeg -i video -vn -f hash -hash sha512 video.txt
BUT the audio hash was different from the video hash, I thought at least the same source file for both commands will give me the same hash
I don't get it

That is due to how the hash multiplexer works, also how I put it is confusing as audio was intended to reference thee aac file and video to reference the ts file. Those comands where not perfect but they where fit for you case as there where only one audio and on video stream in the ts file.

This calculate the hash of the decoded data: "ffmpeg -i input -f hash -hash sha512 output" it autoselects the beast audio and video streams (and the first high quality one when various streams have hightest quality at the same time), this line give different hash if the file contains only audio or audio+video, "-vn" disables the video making that ffmpeg only calculates the data of the best audio stream. A more correct comand for calculating hash of and individual audio stream is using "-map" like in "ffmpeg -i input -map a:0 -f hash -hash sha512 out" the "-a:0" mean fist audio stream (second audio stream is "-a:1" and so on).

And for the quality of the audio is a personal matter as I think that the CD is going to be compressed to boot loudness where the one in the ts is going to have more dinamic range.
thank you my friend, that is what I have experienced
the cd to me sounds not listenable, especially in loud volume
AND
the ts file sounds more like a DSD format type of audio file where you can relax and do other stuff and you can enjoy it in the same time especially listening to it loud

The TS file has the audio separated in a very listenable way, cd gives me a headache

 
SimplePortal 1.0.0 RC1 © 2008-2018