Luis Gonzalez
Luis Gonzalez

Reputation: 538

FFMPEG how to combine -filter_complex with h264 and output to stdout

I need to stream some ffmpeg output that is generated with ffmpeg (audio to video); for this I'm using -filter_complex avectorscope.

I am testing the pipe with ffplay, something like this works:

ffmpeg -i video.mp4 -f h264 - | ffplay -

and something like this also works fine (writing to a file):

ffmpeg -i input.mp3 -filter_complex "[0:a]avectorscope=s=1920x1080,format=yuv420p[v]" \
-map "[v]" -map 0:a -vcodec libx264 avectorscope.mp4

But what I really need is something like this:

ffmpeg -i input.mp3 -filter_complex "[0:a]avectorscope=s=1920x1080,format=yuv420p[v]" \
-map "[v]" -map 0:a -vcodec libx264 -f h264 | ffplay -

but when I try that I get this error:

Automatic encoder selection failed for output stream #0:1. Default encoder for format h264 (codec none) is probably disabled. Please choose an encoder manually. Error selecting an encoder for stream 0:1 pipe:: Invalid data found when processing input

So I can encode it to a file but not encode it to a pipe with the same flags.

I also tried with other format (-f flv and -f mpegts) and they also work (for ffplay), but it doesn't work with other tools that require h264 stream as input.

I hope someone can help!

Upvotes: 0

Views: 887

Answers (1)

Gyan
Gyan

Reputation: 93048

-f h264 represents a raw H.264 bitstream so audio can't be included.

Use a container with multiplexing e.g. nut

ffmpeg -i input.mp3 -filter_complex "[0:a]avectorscope=s=1920x1080,format=yuv420p[v]" \ -map "[v]" -map 0:a -vcodec libx264 -f nut | ffplay -f nut -

Upvotes: 1

Related Questions