0

I've successfully written the RTP-payload into an amr-file and it works fine, according to the answer written in this question.

https://stackoverflow.com/questions/61961965/convert-rtp-payload-payload-type-107-amr-wb-16khz-1channel-to-wav 

Now I tried to write a multichannel file according to chapter 5.2 according to document RFC 4867, but I failed. No decoder accepts the file. I've got 2 channels (stereo).

I've already checked the correctness of the voice data in the file. And they seem correct. First I put the header according to chapter 5.2:

https://www.rfc-editor.org/rfc/rfc4867#section-5.2

The magic number I checked and it's correct. Then I add the chan-desc-field and it should be as far as I understood:

b'\x00\x00\x00\x02'

In the audiofile I read the same values. Is this correct? The audiodata is saved according to 5.3 (1st paragraph):

1.pack_chan1 1.pack_chan2, 2.pack_chan1 2.pack_chan2, etc

Now clicking on the amr-file (or awb), the decoder says, that an error has occurred. On the contrary, when I just write one channel in a file, according to chapter 5.1 and 5.3, everything works fine. It can be played with windows VLC-MEDIA PLAYER and Linux Ubuntu's Videos.

Where is my mistake?

Thanks and regards

Update: Chapter 3.5 of RFC4867, second paragraph says, that usually, codecs do not support encoding of multi-channel audio content into a single bitstream, they can be used to separately encode and decode each of the individual channels.

So what can I do to produce the stereo sound with the 2 channels?

Community
  • 1
  • 1
Uwe_98
  • 697
  • 1
  • 8
  • 21
  • 1
    check if it is a amr file header issue or amr data issue. – mail2subhajit Jul 08 '20 at 16:30
  • @mail2subhajit It should be a file header issue, because I've done the following: I put exactly the same data of one channel in both channels. This data was already working in 1-channel mode, so it cannot be wrong. At this point the only issue that remains is the file header ones. If You look in the documentation RFC4867, which link I have posted, I cannot understand where I was wrong. – Uwe_98 Jul 09 '20 at 08:39
  • 1
    you can check the error logs of the VLC player, when you are trying to play the .amr file. it should give you some clue. – mail2subhajit Jul 09 '20 at 17:32
  • @mail2subhajit I've found some hint in the document RFC4867, chapter 3.5, second paragraph. It says: "Although AMR and AMR-WB codecs themselves do not support encoding of multi-channel audio content into a single bit stream, they can be used to separately encode and decode each of the individual channels". So this would mean that theoretically the file could be ok? – Uwe_98 Jul 13 '20 at 12:37
  • @mail2subhajit Ok, now I've done so. It says: _**avcodec debug**: detected format: amr **avcodec error**: Could not open C:\Users\Operatore\Documents\stereo.amr: **Operation not permitted**_. In the single channel version, which is working, it says: _**avcodec debug**: detected format: amr **main debug**: selecting program id=0 **avcodec debug**: adding es: audio codec = sawb (73729) **avcodec debug**: AVFormat(ffmpeg Lavf58.3.100) supported stream **avcodec debug**: - format = amr (3GPP AMR)_ – Uwe_98 Jul 15 '20 at 15:58
  • @mail2subhajit : Here are the links to the log-files: Stereo 2channels (not working) [link](https://drive.google.com/file/d/1neByCO5cDILB3JgbFI4V9Qwfykov6e8h/view) and the Single Channel decoding VLC logfile (working): [link](https://drive.google.com/file/d/1qzSyyqwRzw0aIY3p4rLwtX-DFJMoZRH_/view?usp=sharing) . Interesting lines: 79+. If You had some idea it would be great. Thanks in advance. – Uwe_98 Jul 15 '20 at 16:24
  • @mail2subhajit: ..and here are the 2 logs from the attempt with ffmpy that wraps ffmpeg in linux: Successful monochannel: [link](https://drive.google.com/file/d/1pJg6zOnpPAvW1kzRzUCAsdqbN7t1B2ng/view?usp=sharing) , failed bichannel converting: [link](https://drive.google.com/file/d/1QS83QjIlDI9IEuVLA3-vbNtHE_XGvO8u/view?usp=sharing) . Even with the help of the logs I cannot be sure if the problem is the file-header of the data. Have You got an' idea? Thanks. – Uwe_98 Jul 15 '20 at 22:44
  • from these logs I can see - "Operation not permitted " which is hard to understand. – mail2subhajit Jul 16 '20 at 21:36
  • 1
    Can you covert a stereo wav file to amr file through ffmpeg cmdline and play this amr file to check the logs and compare the header data. hope it helps. – mail2subhajit Jul 16 '20 at 21:37

0 Answers0