我需要提取原始视频并将其通过管道传输到另一个程序。这可以在终端中完美运行:
ffmpeg -i SampleVideo_1280x720_5mb.mp4 -s 1920x1080 -c:v rawvideo -pix_fmt yuv420p -f rawvideo - | ffplay -f rawvideo -pix_fmt yuv420p -s 1920x1080 -
但是,当我尝试从脚本运行此命令时,它将失败。这是脚本的非常简化的版本:
#!/bin/bash
c='ffmpeg -i SampleVideo_1280x720_5mb.mp4 -s 1920x1080 -c:v rawvideo -pix_fmt yuv420p -f rawvideo - | ffplay -f rawvideo -pix_fmt yuv420p -s 1920x1080 -'
$c
输出
~/ets/videos$ ./test.sh
ffmpeg version N-91403-gd24c9e5 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.10) 20160609
configuration: --extra-cflags='-fPIC -I/home/jlbeaussart/ffmpeg_build/include' --extra-ldflags=-L/home/jlbeaussart/ffmpeg_build/lib --extra-libs='-lpthread -lm' --enable-gpl --enable-libaom --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-shared --enable-libcaca --enable-libxvid --enable-libxml2 --enable-opencl --enable-opengl --enable-cuvid --enable-ffnvcodec --enable-libdrm --enable-nvenc --enable-nvdec --enable-vaapi --enable-vdpau --enable-nonfree
libavutil 56. 18.102 / 56. 18.102
libavcodec 58. 20.104 / 58. 20.104
libavformat 58. 17.101 / 58. 17.101
libavdevice 58. 4.101 / 58. 4.101
libavfilter 7. 25.100 / 7. 25.100
libswscale 5. 2.100 / 5. 2.100
libswresample 3. 2.100 / 3. 2.100
libpostproc 55. 2.100 / 55. 2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'SampleVideo_1280x720_5mb.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
creation_time : 1970-01-01T00:00:00.000000Z
encoder : Lavf53.24.2
Duration: 00:00:29.57, start: 0.000000, bitrate: 1421 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 1032 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
creation_time : 1970-01-01T00:00:00.000000Z
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 383 kb/s (default)
Metadata:
creation_time : 1970-01-01T00:00:00.000000Z
handler_name : SoundHandler
[NULL @ 0x18d5d40] Unable to find a suitable output format for '|'
|: Invalid argument