Ffmpeg Audio Stereo to Mono using only left channel

127

Solution 1

You can modify a video file directly without having to re-encode the video stream. However the audio stream will have to be re-encoded.

Left channel to mono:

ffmpeg -i video.mp4 -map_channel 0.1.0 -c:v copy mono.mp4

Left channel to stereo:

ffmpeg -i video.mp4 -map_channel 0.1.0 -map_channel 0.1.0 -c:v copy stereo.mp4

If you want to use the right channel, write 0.1.1 instead of 0.1.0.

Working with ffmpeg version 3.1.3.

Solution 2

The following is a confirmed working example with ffmpeg version 2.4.1-tessus:

ffmpeg -i stereo.wav -map_channel 0.0.0 left.wav

More info on FFMPEG's Audio Channel Page.

Solution 3

Using the -map_channel option as suggested here did not work for me on 4.3.1, using a video from my mobile phone:

mapchan: stream #0.1 is not an audio stream

Solution (working with ffmpeg 4.3.1)

The ffmpeg wiki article Manipulating audio channels recommends using the pan audio filter as the shortest option for this:

ffmpeg -i video.mp4 -af "pan=mono|c0=FL" mono.mp4

To get the right channel included as mono, replace FL with FR.

Solution 4

Manipulating audio channels with ffmpeg

Chapter Mute a channel

This example will mute the first channel (the left channel) but keep the second channel as is:

ffmpeg -i stereo.wav -map_channel -1 -map_channel 0.0.1 output.wav

in your case its need to mute right channel. right?

Solution 5

I solved the problem using the last version of Ffmpeg (2.0.1). The following command line makes the work:

/home/eric/buildsys/ffmpeg-2.0.1/ffmpeg -i 00402.MTS -s 1280x720 -ss 0:00:05.38608 -vcodec libxvid -qscale:v 2 -acodec ac3 -ar 48000 -ab 256k -t 0:00:06.61391 -af pan=1:c0=c0 m001_mono.avi

Btw, this post was very instructive!

Share:
127

Related videos on Youtube

Raveel Sabir
Author by

Raveel Sabir

Updated on September 18, 2022

Comments

  • Raveel Sabir
    Raveel Sabir almost 2 years

    I used pusher for my project. I configure broadcasting as per laravel docs. When I fired my event pusher does not work for me. But when I send data from pusher console then pusher receive this data. I also try vinkla/pusher. Its work fine but laravel event broadcasting not work. It's not broadcast my messages. Please help me.

    Here is my Event

     <?php
            
            namespace App\Events;
            
            use Illuminate\Broadcasting\Channel;
            use Illuminate\Queue\SerializesModels;
            use Illuminate\Broadcasting\PrivateChannel;
            use Illuminate\Broadcasting\PresenceChannel;
            use Illuminate\Foundation\Events\Dispatchable;
            use Illuminate\Broadcasting\InteractsWithSockets;
            use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
            
            class ChatNotification implements  ShouldBroadcast
            {
                use Dispatchable, InteractsWithSockets, SerializesModels;
            
                public $message;
                /**
                 * Create a new event instance.
                 *
                 * @return void
                 */
            
                public function __construct($message)
                {
                 $this->message=$message;
            
                }
            
                /**
                 * Get the channels the event should broadcast on.
                 *
                 * @return Channel|array
                 */
                public function broadcastOn()
                {
                    dd($this->message);
                    $GroupId=$this->message->fk_group_id;
                    if(!empty($GroupId) && !is_null($GroupId)){
            
                        return new PresenceChannel('Room.'.$GroupId);
                    }else{
                        return new PrivateChannel('Chat.'.$this->message->to_id);
                    }
                }
            }
    
  • Eric
    Eric over 10 years
    Unrecognized option 'map_channel'.
  • slhck
    slhck over 10 years
    @Eric I'm guessing (since you haven't included the output) that your ffmpeg version is too old, or it's actually from Libav and not FFmpeg. Try with a newer one: ffmpeg.org/download.html
  • Prakash V Holkar
    Prakash V Holkar about 10 years
    @ArcherGodson - Can we UnMute the muted channel back by modifying same ffmpeg coammnd
  • Arun
    Arun almost 8 years
    BTW for anyone needing the extra step of going back to stereo but having both channels stay full volume (i.e., basically copying the left channel overtop the right channel), you can do ffmpeg -i inputfile.wav -map_channel 0.0.0 -map_channel 0.0.0 outputfile.wav
  • Pyrolistical
    Pyrolistical almost 7 years
    aka how to fix shadowplay right channel corruption bug
  • termil0r
    termil0r over 5 years
    Worth to mention is that when using with -c:a copy audio will not be modified even though you'd like to have direct copy of single channel.