I'd like to use the output of ffmpeg in order to encrypt the video with openssl:

I tried to use name pipe without sucess. With the command:

mkfifo myfifo
ffmpeg -f alsa -ac 2 -i plughw:0,0 -f video4linux2 -s vga -i /dev/video0 myfifo

I get the error

[NULL @ 0x563c02ce5c00] Unable to find a suitable output format for 'myfifo'
myfifo: Invalid argument

The idea is to later encrypt the stdout of ffmpeg with

dd if=myfifo | openssl enc -des3 -out video.mp4

How can I pipe the output of ffmpeg to openssl

PS: I know that encryption with ffmpeg is possible but prefer to use openssl with a pipe.

  • have you tried pipe:1 as output file name? And you should probables set options for output format and such. – Alex Stragies Dec 11 '16 at 0:18
  • use a named pipe – μολὼν.λαβέ Dec 11 '16 at 4:19

ffmpeg tries to guess the video format based on the filename extension. Either "set options for output format and such" as @alex-stragies states, or use a filename extension for your fifo that ffmpeg knows about.

If openssl is to be run detached, also give it the encrypting password on the command line.

When using a pipe or fifo as output, ffmpeg can't go back and forth in the output file, so the chosen format has to be something that does'nt need random acces while writing. For example, if you try to create an mp4 with x264 video and aac audio (ffmpeg -c:v libx264 -c:a aac), ffmpeg will die with [mp4 @ 0xc83d00] muxer does not support non seekable output.

    ( umask 066 ; echo password >/tmp/myfilepasswd )
    mkfifo /tmp/schproutz-vid
    openssl enc -des3 -out video.enc \
        -in /tmp/schproutz-vid \
        -pass file:/tmp/myfilepasswd &
    sleep 1
    ffmpeg -f alsa -ac 2 -i plughw:0,0 \
        -f video4linux2 \
        -s vga -i /dev/video0 \
        -f ogg /tmp/schproutz-vid

Once you get this to work, you can easily remove the fifo and use a pipe between ffmpeg and openssl :

    ffmpeg -f alsa -ac 2 -i plughw:0,0 \
        -f video4linux2 \
        -s vga -i /dev/video0 \
        -f ogg - |
    openssl enc -des3 \
        -pass file:/tmp/myfilepasswd \
        > outputfile.enc

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.