user1810837
user1810837

Reputation: 13

Restreaming video containing two languages live with ffmpeg

I have a project where i need to restream a live stream which has two languages setup on the audio. Spanish on left and English on right

The stream mapping is:

Stream #0:0: Video: h264 ([7][0][0][0] / 0x0007), yuv420p, 512x288 [SAR 1:1 DAR 16:9], q=2-31, 1k tbn, 1k tbc
Stream #0:1: Audio: mp3 ([2][0][0][0] / 0x0002), 44100 Hz, stereo, s16, 18 kb/s

I need to restream this back live with just the English from the right side or just spanish from the left side, I tried looking everywhere but did not find any type of solution .

Since this needs to be done live, I can't be using other programs to separate video and audio to get it done.

This needs to be done through ffmpeg and I wonder if it even capable of doing so with original built or it would need some custom modification.

Upvotes: 1

Views: 1086

Answers (1)

llogan
llogan

Reputation: 134173

You can use the -map_channel option or the pan filter. Unfortunately you didn't specify if you want a stereo or mono output. If stereo you can simply mute a channel or duplicate a channel into both left and right channels of the output. Here are some examples assuming you want to keep a stereo output.

To copy the right channel of the input to the left and right channels of the output:

ffmpeg -i input -map_channel 0.1.1 -map_channel 0.1.1 output

To mute the left channel:

ffmpeg -i input -map_channel -1 -map_channel 0.1.1 output

To mute the left channel using pan:

ffmpeg -i input -filter:a pan="stereo:c1=c1" output

FFmpeg usage questions are better suited for superuser.com since stackoverflow is programming specific.

Upvotes: 1

Related Questions