[Libav-user] mjr to opus audio conversion - corrupted results

Talgorn François-Xavier fxtalgorn at yahoo.fr
Wed Jul 8 21:37:36 CEST 2015

Before going any further in your code, I noticed that you don't register installed codecs with the
avcodec_register_all() function.

The av_register_all() call at line 91 "Initialize libavformat and register all the muxers, demuxers and protocols. " but not the codecs.

It is likely that it won't solve your issues but this is a first step to check.
If after having registered codecs with avcodec_register_all() the ogg codec is still not found, I assume that your libav install have not been compiled with this codec (I'm not 100% sure of it).

For your synch issues, I would recommend not to set the ts manually as in lines 186-187 but use  av_packet_rescale_ts() function instead.
This is only a general hint.

Le 8 juil. 2015 à 15:04, Mateusz Koslacz <mateusz.koslacz at 4vod.tv> a écrit :

> Hi,
> In our project we use janus-gateway (http://janus.conf.meetecho.com/) as a webRTC gateway and also as a stream recorder. We are on the tests stage of our project, and after very long development time we have ecountered a bug that is a blocker for whole project. After real tests of recording streams using janus we realized that audio and video are out of sync in recordings, despite of fact, that live they are perfectly in sync.
> Janus records two *.mjr files for each recording - one for video, and one for audio. Janus also provides own converter to convert this files to *.webm for video and *.opus for audio. After that, we use ffmpeg to merge this files. By recording stopwatch view on the stream we concluded, that video has correct length and speed, so most probably this is something wrong with audio recording or converting.
> Firstly, janus was using libogg for converting *.mjr audio to *.opus. Regarding described issues author decided to switch to libav audio processing. You can check how it's done in this file https://github.com/meetecho/janus-gateway/blob/pprec-opus-libav/postprocessing/pp-opus.c starting from 90 line.
> Returned data is a lil bit smaller than data obtained using libogg:
> -rw-r--r-- 1 mateusz mateusz  17987445 lip  8 11:58 rec-2215547545-audio-nolibogg.opus
> -rw-r--r-- 1 mateusz mateusz 221841174 lip  8 11:56 rec-2215547545-video.webm
> -rw-r--r-- 1 mateusz mateusz  18074102 lip  8 11:52 rec-2215547545-audio-libogg.opus
> Unfortunately, returned data is somehow corrupted - ffprobe results for libav processing output:
> [ogg @ 0x4336540] Codec not found
> rec-2215547545-audio-nolibogg.opus: End of file
> and for compare, for libogg version:
> Input #0, ogg, from 'rec-2215547545-audio-libogg.opus':
>   Duration: 01:20:32.98, start: 0.000000, bitrate: 29 kb/s
>     Stream #0:0: Audio: opus, 48000 Hz, stereo, fltp
> Moreover, no player can play this file - VLC just does nothing, and Rythmbox says "Can't play file: {null}".
> Is this because of improper use of libav api, or maybe it is some libav bug? How could we possibly overcome this problems?
> For more details you can read our whole conversation with janus author here:
> https://groups.google.com/forum/#!topic/meetecho-janus/lMCtBm7VbMY
> Regards,
> Mateusz Koślacz
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20150708/7d8df668/attachment.html>

More information about the Libav-user mailing list