Re: troubles with transcode / export_tcaud / lavc - Specifie…

Page principale

Répondre à ce message
Auteur: Scott MacKenzie
Date:  
À: dmo-discussion
Sujet: Re: troubles with transcode / export_tcaud / lavc - Specified sample_fmt is not supported
Hi,

On 14/05/12 15:51, Christian Marillat wrote:
> Scott MacKenzie<scottcm@???> writes:
>
>> On 13/05/12 17:13, Christian Marillat wrote:
>>> Scott MacKenzie<scottcm@???> writes:
>>>
>>>> Hi,
>>>
>>> Hi,
>>>
>>>> I've had a broken transcode installation for some months.
>>>>
>>>> I'm trying to use transcode with option '-y ...,tcaud -E 48000 -N
>>>> 0x2000' and I'm getting a response of
>>>> [ac3@<location>] Specified sample_fmt is not supported.
>>>
>>> I already seens this bug :
>>>
>>> http://ffmpeg.org/trac/ffmpeg/ticket/363
>>>
>>> (If the problem is the same) From comment 5, transcode need to be fixed.
>>>
>>> Christian
>>>
>>
>> https://bitbucket.org/france/transcode-tcforge/issue/2/export_tcaud-sample_fmt-not-supported
>
> Thanks. Fixed in unstable.
>
> Christian
>


I see what you did there. You took my simple edit to highlight the
issue and assumed it was a fix .. well its not, that one line will just
produce garbage audio output as it assumes the input is float, which it
isn't.

I'm assuming you did this so I'd be spurned on to find a real fix :)

..and so I've attached my -preliminary- patch which goes a long way but
probably needs a more expert eye and also some clean up. It's the best
I can do on short notice.

The reference for the above changes is
http://git.alsa-project.org/?p=alsa-plugins.git;a=commit;h=40c129a160f37fe9488b2828d6299f99c269703e


Regards,

Scott.

--
transcode_117_fix_export_tcaud_encode_with_ffmpeg_lav53plus_v1.patch
--- a/export/aud_aux.c    2011-11-20 03:50:27.000000000 +1100
+++ b/export/aud_aux.c    2012-05-14 18:45:13.000000000 +1000
@@ -319,24 +319,34 @@
  {
      int init_ret = TC_EXPORT_ERROR;
  #ifdef HAVE_FFMPEG
-    unsigned long codeid = 0;
+//  unsigned long codeid = 0;
      int ret = 0;


      TC_INIT_LIBAVCODEC;


      switch (o_codec) {
        case   0x50:
-        codeid = CODEC_ID_MP2;
+//      codeid = CODEC_ID_MP2;
+        mpa_codec = avcodec_find_encoder(CODEC_ID_MP2);
          break;
        case 0x2000:
-        codeid = CODEC_ID_AC3;
+//      codeid = CODEC_ID_AC3;
+#if LIBAVCODEC_VERSION_MAJOR > 52
+        mpa_codec = avcodec_find_encoder_by_name("ac3_fixed");
+        if (mpa_codec == NULL)
+          mpa_codec = avcodec_find_encoder_by_name("ac3");
+        if (mpa_codec == NULL)
+          mpa_codec = avcodec_find_encoder(CODEC_ID_AC3);
+        break;
+#endif
+        mpa_codec = avcodec_find_encoder(CODEC_ID_AC3);
          break;
        default:
          tc_warn("cannot init ffmpeg with %x", o_codec);
      }


      //-- get it --
-    mpa_codec = avcodec_find_encoder(codeid);
+//  mpa_codec = avcodec_find_encoder(codeid);
      if (!mpa_codec) {
        tc_log_warn("encode_ffmpeg", "mpa codec not found !");
        return(TC_EXPORT_ERROR);
@@ -355,6 +365,10 @@
      mpa_ctx.bit_rate    = vob->mp3bitrate * 1000;  // bitrate dest.
      mpa_ctx.channels    = vob->dm_chan;            // channels
      mpa_ctx.sample_rate = vob->a_rate;
+    mpa_ctx.sample_fmt  = AV_SAMPLE_FMT_S16;
+#if LIBAVCODEC_VERSION_MAJOR > 52
+    mpa_ctx.channel_layout = CH_LAYOUT_STEREO;
+#endif


      //-- open codec --
      //----------------
@@ -363,7 +377,8 @@
      TC_UNLOCK_LIBAVCODEC;
      if (ret < 0) {
          tc_warn("tc_audio_init_ffmpeg: could not open %s codec !",
-                (codeid == CODEC_ID_MP2) ?"mpa" :"ac3");
+//              (codeid == CODEC_ID_MP2) ?"mpa" :"ac3");
+                (o_codec == 0x50) ?"mpa" :"ac3");
          return(TC_EXPORT_ERROR);
      }