[MPlayer-dev-eng] [PATCH] Switch audio streams in AVI files

Jochen Leopold jochen.leopold at fh-hagenberg.at
Fri Sep 30 17:16:53 CEST 2005


Hi,
I'll have a look at the patch again. Maybe I can make it work for AVIs 
the same way.
For my first tries, I looked at the code of the mpeg switching but I  
just couldn't get it work for AVIs.

So I made a differend solution.

Now I know the source a lot better and I will try it again if you want.

LAva_at


Guillaume POIRIER schrieb:

>Hi,
>
>On 9/30/05, Jochen Leopold <jochen.leopold at fh-hagenberg.at> wrote:
>  
>
>>I extended the source code to enable audio switching during the playback
>>of AVI files.
>>
>>
>>There are two files affected:
>> - libmpdemux/demux_avi.c
>> - mplayer.c
>>
>>I had to add a initialisation routine in mplayer.c for the switched
>>audio streams.
>>It was the only possibility to allow switching between different types
>>of audio streams.
>>    
>>
>
>Did you look at the way it was done for AVI and Mkv? It does seem to
>me like your solution is overkill.
>
>You should have a look at the patch you should be able to find searching for
>
>Date: Feb 24, 2005 8:01 PM
>Subject: [MPlayer-dev-eng] [Patch] Online audio stream switching
>
>I'm gonna forward to you the patch so that you can have a look at it.
>
>
>  
>
>>Maybe you find a better solution for this problem.
>>    
>>
>
>I won't be too surprise if it was indeed possible.
>
>
>  
>
>>LAva_at
>>
>>
>>
>>Index: mplayer.c
>>===================================================================
>>RCS file: /cvsroot/mplayer/main/mplayer.c,v
>>retrieving revision 1.872
>>diff -u -r1.872 mplayer.c
>>--- mplayer.c   19 Sep 2005 16:33:38 -0000      1.872
>>+++ mplayer.c   30 Sep 2005 13:25:11 -0000
>>@@ -1045,6 +1045,7 @@
>> int osd_show_percentage = 0;
>> int osd_show_tv_channel = 25;
>> int osd_show_ontop = 0;
>>+int osd_show_audioid = 0;     //LAva Extended
>>    
>>
>
>What the H**l is that spam for? You are not supposed to put your name
>everywhere like that! the AUTHORS file is made for that!
>
>
>  
>
>> int osd_show_rootwin = 0;
>> int osd_show_framedropping = 0;
>> int osd_show_status = 0;
>>@@ -2332,7 +2333,114 @@
>>     float aq_sleep_time=0;
>>
>> /*========================== PLAY AUDIO ============================*/
>>+/*LAVA Extended */
>>    
>>
>
>same here.
>
>
>  
>
>>+if(sh_audio){
>>+  //================== Init AUDIO (codec) ==========================
>>+  if (sh_audio->inited==-2) {
>>+    sh_audio->inited=0;
>>+
>>+    // Go through the codec.conf and find the best codec...
>>+    current_module="init_audio_codec";
>>+    mp_msg(MSGT_CPLAYER,MSGL_INFO,"==========================================================================\n");
>>+
>>+    if(!init_best_audio_codec(sh_audio,audio_codec_list,audio_fm_list)){
>>+        sh_audio=d_audio->sh=NULL; // failed to init :(
>>+    } else {
>>+      inited_flags|=INITED_ACODEC;
>>+    }
>>+    mp_msg(MSGT_CPLAYER,MSGL_INFO,"==========================================================================\n");
>>
>>+    if(sh_audio){
>>+      //const ao_info_t *info=audio_out->info;
>>+      current_module="af_preinit";
>>+      ao_data.samplerate=force_srate?force_srate:sh_audio->samplerate*playback_speed;
>>+      ao_data.channels=audio_output_channels?audio_output_channels:sh_audio->channels;
>>+      ao_data.format=audio_output_format?audio_output_format:sh_audio->sample_format;
>>+      #if 1
>>+      if(!preinit_audio_filters(sh_audio,
>>+        // input:
>>+        (int)(sh_audio->samplerate*playback_speed),
>>+        sh_audio->channels, sh_audio->sample_format,
>>+        // output:
>>+        &ao_data.samplerate, &ao_data.channels, &ao_data.format)){
>>+          mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_AudioFilterChainPreinitError);
>>+      }
>>+      #endif
>>+      current_module="ao2_init";
>>+      if(!(audio_out=init_best_audio_out(audio_driver_list,
>>+        0, // plugin flag
>>+        force_srate?force_srate:ao_data.samplerate,
>>+        audio_output_channels?audio_output_channels:ao_data.channels,
>>+        audio_output_format?audio_output_format:ao_data.format,0))){
>>+          // FAILED:
>>+          mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CannotInitAO);
>>+          uninit_player(INITED_ACODEC); // close codec
>>+          sh_audio=d_audio->sh=NULL; // -> nosound
>>+      } else {
>>+        // SUCCESS:
>>+        inited_flags|=INITED_AO;
>>+        mp_msg(MSGT_CPLAYER,MSGL_INFO,"AO: [%s] %dHz %dch %s (%d bps)\n",
>>+          audio_out->info->short_name,
>>+          ao_data.samplerate, ao_data.channels,
>>+          af_fmt2str_short(ao_data.format),
>>+          af_fmt2bits(ao_data.format)/8 );
>>+        mp_msg(MSGT_CPLAYER,MSGL_V,"AO: Description: %s\nAO: Author: %s\n",
>>+          audio_out->info->name, audio_out->info->author);
>>+        if(strlen(audio_out->info->comment) > 0)
>>+          mp_msg(MSGT_CPLAYER,MSGL_V,"AO: Comment: %s\n", audio_out->info->comment);
>>+
>>+        // init audio filters:
>>+               #if 1
>>+        current_module="af_init";
>>+        if(!build_afilter_chain(sh_audio, &ao_data)) {
>>+          mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_NoMatchingFilter);
>>+  //      mp_msg(MSGT_CPLAYER,MSGL_ERR,"Couldn't find matching filter / ao format! -> NOSOUND\n");
>>+  //      uninit_player(INITED_ACODEC|INITED_AO); // close codec & ao
>>+  //      sh_audio=d_audio->sh=NULL; // -> nosound
>>    
>>
>
>if it's commented it's probably useless and should be removed.
>
>
>  
>
>>+        }
>>+        #endif
>>+      }
>>+      mixer.audio_out = audio_out;
>>+      mixer.volstep = volstep;
>>+    }
>>+
>>+    current_module="av_init";
>>+
>>+    if(sh_video) sh_video->timer=0;
>>+    if(sh_audio) sh_audio->delay=-audio_delay;
>>+
>>+    if(!sh_audio){
>>+      mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_NoSound);
>>+      mp_msg(MSGT_CPLAYER,MSGL_V,"Freeing %d unused audio chunks.\n",d_audio->packs);
>>+      ds_free_packs(d_audio); // free buffered chunks
>>+      d_audio->id=-2;         // do not read audio chunks
>>+      //uninit_player(INITED_AO); // close device
>>+    } else {
>>+      if(demux_seek(demuxer,-1,0)){
>>+        if(demux_seek(demuxer,0.8,0)) {
>>+          /* FIXME there should be real seeking for vobsub */
>>+          if(sh_video) sh_video->pts=d_video->pts;
>>+          if (vo_vobsub)
>>+            vobsub_seek(vo_vobsub,sh_video->pts);
>>+          fflush(stdout);
>>+          if(sh_video){
>>+            current_module="seek_video_reset";
>>+            resync_video_stream(sh_video);
>>+            if(vo_config_count) video_out->control(VOCTRL_RESET,NULL);
>>+          }
>>+
>>+          if(sh_audio){
>>+            current_module="seek_audio_reset";
>>+            audio_out->reset(); // stop audio, throwing away buffered data
>>+          }
>>+        }
>>+        d_audio=demuxer->audio;
>>+        osd_show_audioid=25;
>>+      }
>>+    }
>>+  }
>>+}
>>+/* LAva END */
>>    
>>
>
>spam, spam, spam, spam! :-)
>
>Please submit a patch with less spam. Commenting your code is good,
>but it has to make sense when it gets re-read. That sure does not make
>much sense to me.
>
>(don't take it personally, I'm just trying to help you clean up your
>patch so that it can eventually make its way to the CVS ASAP.
>
>[..]
>
>
>Guillaume
>--
>Reading doesn't hurt, really!
>  -- Dominik 'Rathann' Mierzejewski
>
>_______________________________________________
>MPlayer-dev-eng mailing list
>MPlayer-dev-eng at mplayerhq.hu
>http://mplayerhq.hu/mailman/listinfo/mplayer-dev-eng
>  
>




More information about the MPlayer-dev-eng mailing list