redirect to 2 fifo files

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

redirect to 2 fifo files

Zoltan Kerenyi Nagy
Hi All,

I'd like to send my laptop's sound to 2 fifo-s at the same time in order to
read from that fifos later. For some reason if I read from those fifos,
nothing happens:

ffmpeg -i fifo1 -s 0 -t 5 out1.wav
ffmpeg -i fifo2 -s 0 -t 5 out2.wav

This is how I create the 2 fifos:

#!/bin/bash

mkfifo fifo2 2>/dev/null
mkfifo fifo2 2>/dev/null

ffmpeg -f alsa -i hw:0,0 -f wav pipe:1 > fifo1 -f wav pipe:1 > fifo2

exit 0

Thanks,

Zoli
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: redirect to 2 fifo files

Moritz Barsnick
On Mon, Jan 28, 2019 at 16:18:12 +0100, Zoltan Kerenyi Nagy wrote:
> This is how I create the 2 fifos:
>
> #!/bin/bash
>
> mkfifo fifo2 2>/dev/null
> mkfifo fifo2 2>/dev/null

You're creating the same fifo twice, by the way

> ffmpeg -f alsa -i hw:0,0 -f wav pipe:1 > fifo1 -f wav pipe:1 > fifo2

This should give some sort of syntax error from bash. You can't use the
redirect operator ">" twice per command.

You want to write directly to the fifos:

$ ffmpeg -f alsa -i hw:0,0 -f wav fifo1 -f wav fifo2

Cheers,
Moritz
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: redirect to 2 fifo files

Zoltan Kerenyi Nagy
If this tiny mistake is the root of the problem, than Ill buy you a beer
:-) Im checking this out as soon as I got home

On 2019. Jan 28., Mon at 19:11, Moritz Barsnick <[hidden email]> wrote:

> On Mon, Jan 28, 2019 at 16:18:12 +0100, Zoltan Kerenyi Nagy wrote:
> > This is how I create the 2 fifos:
> >
> > #!/bin/bash
> >
> > mkfifo fifo2 2>/dev/null
> > mkfifo fifo2 2>/dev/null
>
> You're creating the same fifo twice, by the way
>
> > ffmpeg -f alsa -i hw:0,0 -f wav pipe:1 > fifo1 -f wav pipe:1 > fifo2
>
> This should give some sort of syntax error from bash. You can't use the
> redirect operator ">" twice per command.
>
> You want to write directly to the fifos:
>
> $ ffmpeg -f alsa -i hw:0,0 -f wav fifo1 -f wav fifo2
>
> Cheers,
> Moritz
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: redirect to 2 fifo files

Zoltan Kerenyi Nagy
fifo1 and fifo2 are not really pipes or fifo-s

This way it asks me if I want to overwrite them:
#!/bin/bash
set -x

mkfifo fifo1 2>/dev/null
mkfifo fifo2 2>/dev/null

ffmpeg -f alsa -i hw:0,0 -f wav fifo1 -f wav fifo2

exit 0

On Mon, 28 Jan 2019 at 19:20, Zoltan Kerenyi Nagy <
[hidden email]> wrote:

> If this tiny mistake is the root of the problem, than Ill buy you a beer
> :-) Im checking this out as soon as I got home
>
> On 2019. Jan 28., Mon at 19:11, Moritz Barsnick <[hidden email]> wrote:
>
>> On Mon, Jan 28, 2019 at 16:18:12 +0100, Zoltan Kerenyi Nagy wrote:
>> > This is how I create the 2 fifos:
>> >
>> > #!/bin/bash
>> >
>> > mkfifo fifo2 2>/dev/null
>> > mkfifo fifo2 2>/dev/null
>>
>> You're creating the same fifo twice, by the way
>>
>> > ffmpeg -f alsa -i hw:0,0 -f wav pipe:1 > fifo1 -f wav pipe:1 > fifo2
>>
>> This should give some sort of syntax error from bash. You can't use the
>> redirect operator ">" twice per command.
>>
>> You want to write directly to the fifos:
>>
>> $ ffmpeg -f alsa -i hw:0,0 -f wav fifo1 -f wav fifo2
>>
>> Cheers,
>> Moritz
>> _______________________________________________
>> ffmpeg-user mailing list
>> [hidden email]
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>>
>> To unsubscribe, visit link above, or email
>> [hidden email] with subject "unsubscribe".
>
>
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: redirect to 2 fifo files

Zoltan Kerenyi Nagy
Anyhow your solution only creates files, not named pipes (fifo).
I'd like to create 2 fifos with the same data coming from the analog input.
The documentation says that I need to utilize pipe:1 which means output.
I just cant figure out how can I write to 2 fifos at the same time





*#!/bin/bashmkfifo fifo1 2>/dev/nullmkfifo fifo2 2>/dev/nullffmpeg -f alsa
-i hw:0,0 -f wav pipe:1 > fifo1 fifo2exit 0*

I'd use up fifo1 for recording into segments ,and fifo2 to streaming.

On Mon, 28 Jan 2019 at 20:06, Zoltan Kerenyi Nagy <
[hidden email]> wrote:

> fifo1 and fifo2 are not really pipes or fifo-s
>
> This way it asks me if I want to overwrite them:
> #!/bin/bash
> set -x
>
> mkfifo fifo1 2>/dev/null
> mkfifo fifo2 2>/dev/null
>
> ffmpeg -f alsa -i hw:0,0 -f wav fifo1 -f wav fifo2
>
> exit 0
>
> On Mon, 28 Jan 2019 at 19:20, Zoltan Kerenyi Nagy <
> [hidden email]> wrote:
>
>> If this tiny mistake is the root of the problem, than Ill buy you a beer
>> :-) Im checking this out as soon as I got home
>>
>> On 2019. Jan 28., Mon at 19:11, Moritz Barsnick <[hidden email]> wrote:
>>
>>> On Mon, Jan 28, 2019 at 16:18:12 +0100, Zoltan Kerenyi Nagy wrote:
>>> > This is how I create the 2 fifos:
>>> >
>>> > #!/bin/bash
>>> >
>>> > mkfifo fifo2 2>/dev/null
>>> > mkfifo fifo2 2>/dev/null
>>>
>>> You're creating the same fifo twice, by the way
>>>
>>> > ffmpeg -f alsa -i hw:0,0 -f wav pipe:1 > fifo1 -f wav pipe:1 > fifo2
>>>
>>> This should give some sort of syntax error from bash. You can't use the
>>> redirect operator ">" twice per command.
>>>
>>> You want to write directly to the fifos:
>>>
>>> $ ffmpeg -f alsa -i hw:0,0 -f wav fifo1 -f wav fifo2
>>>
>>> Cheers,
>>> Moritz
>>> _______________________________________________
>>> ffmpeg-user mailing list
>>> [hidden email]
>>> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>>>
>>> To unsubscribe, visit link above, or email
>>> [hidden email] with subject "unsubscribe".
>>
>>
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: redirect to 2 fifo files

Moritz Barsnick
On Mon, Jan 28, 2019 at 20:38:48 +0100, Zoltan Kerenyi Nagy wrote:
> Anyhow your solution only creates files, not named pipes (fifo).

You can tell ffmpeg to "overwrite" them by using "-y". It should just
reuse them, not actually delete them and replace them with files.
(Works for me.)

> I'd like to create 2 fifos with the same data coming from the analog input.
> The documentation says that I need to utilize pipe:1 which means output.
> I just cant figure out how can I write to 2 fifos at the same time

In theory, you should be able to do
$ ... -f wav pipe:3 -f wav pipe:4 3>fifo1 4>fifo2

but I didn't get this to work.

Moritz
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: redirect to 2 fifo files

Zoltan Kerenyi Nagy
 $ ... -f wav pipe:3 -f wav pipe:4 3>fifo1 4>fifo2

That's impossible since:
pipe:1 stdout
pipe:2: sterr
pipe:0 stdin

I got it working this way:
https://pastebin.com/neYPWejt

The only thing have left is the video representation of the audio, which is
a bonus to my sleep recorder experimental application





On Tue, 29 Jan 2019 at 01:33, Moritz Barsnick <[hidden email]> wrote:

> On Mon, Jan 28, 2019 at 20:38:48 +0100, Zoltan Kerenyi Nagy wrote:
> > Anyhow your solution only creates files, not named pipes (fifo).
>
> You can tell ffmpeg to "overwrite" them by using "-y". It should just
> reuse them, not actually delete them and replace them with files.
> (Works for me.)
>
> > I'd like to create 2 fifos with the same data coming from the analog
> input.
> > The documentation says that I need to utilize pipe:1 which means output.
> > I just cant figure out how can I write to 2 fifos at the same time
>
> In theory, you should be able to do
> $ ... -f wav pipe:3 -f wav pipe:4 3>fifo1 4>fifo2
>
> but I didn't get this to work.
>
> Moritz
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: redirect to 2 fifo files

Moritz Barsnick
On Tue, Jan 29, 2019 at 07:18:21 +0100, Zoltan Kerenyi Nagy wrote:
>  $ ... -f wav pipe:3 -f wav pipe:4 3>fifo1 4>fifo2
>
> That's impossible since:
> pipe:1 stdout
> pipe:2: sterr
> pipe:0 stdin

That's not impossible. File descriptors 0, 1, 2 are predefined by the
operating system. A process can use further file descriptors, and in
this case I defined them as 3 and 4, and bash can handle their
redirection.

> I got it working this way:
> https://pastebin.com/neYPWejt

I don't see two outputs being used.

Did you try my hint with "-f wav fifo1" and the addition of "-y"? It
works fine for me.

> The only thing have left is the video representation of the audio, which is
> a bonus to my sleep recorder experimental application

Cheers,
Moritz
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: redirect to 2 fifo files

Zoltan Kerenyi Nagy
I tried your version without -y. I will try it later today thanks though.

On 2019. Jan 29., Tue at 10:06, Moritz Barsnick <[hidden email]> wrote:

> On Tue, Jan 29, 2019 at 07:18:21 +0100, Zoltan Kerenyi Nagy wrote:
> >  $ ... -f wav pipe:3 -f wav pipe:4 3>fifo1 4>fifo2
> >
> > That's impossible since:
> > pipe:1 stdout
> > pipe:2: sterr
> > pipe:0 stdin
>
> That's not impossible. File descriptors 0, 1, 2 are predefined by the
> operating system. A process can use further file descriptors, and in
> this case I defined them as 3 and 4, and bash can handle their
> redirection.
>
> > I got it working this way:
> > https://pastebin.com/neYPWejt
>
> I don't see two outputs being used.
>
> Did you try my hint with "-f wav fifo1" and the addition of "-y"? It
> works fine for me.
>
> > The only thing have left is the video representation of the audio, which
> is
> > a bonus to my sleep recorder experimental application
>
> Cheers,
> Moritz
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".