[FFmpeg-user] Read mp4 video from pipe

kolychev kolychev at speechpro.com
Fri Jun 17 12:21:30 CEST 2016


Hi,

I need to read video from pipe, cut into frames and send them to pipe.
I have a video file video.mp4. Everything works fine with this command:

$ ffmpeg -i video.mp4 -r 25 -f image2pipe -vcodec mjpeg -q:v 1 pipe: > 
result

ffmpeg version 3.0.2 Copyright (c) 2000-2016 the FFmpeg developers
   built with gcc 5.3.0 (GCC)
   configuration: --prefix=/usr --disable-debug --disable-static 
--disable-stripping --enable-avisynth --enable-avresample 
--enable-fontconfig --enable-gnutls --enable-gpl --enable-ladspa 
--enable-libass --enable-libbluray --enable-libdcadec 
--enable-libfreetype --enable-libfribidi --enable-libgsm 
--enable-libiec61883 --enable-libmodplug --enable-libmp3lame 
--enable-libopencore_amrnb --enable-libopencore_amrwb 
--enable-libopenjpeg --enable-libopus --enable-libpulse 
--enable-libschroedinger --enable-libsoxr --enable-libspeex 
--enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab 
--enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 
--enable-libx265 --enable-libxvid --enable-netcdf --enable-shared 
--enable-version3 --enable-x11grab
   libavutil      55. 17.103 / 55. 17.103
   libavcodec     57. 24.102 / 57. 24.102
   libavformat    57. 25.100 / 57. 25.100
   libavdevice    57.  0.101 / 57.  0.101
   libavfilter     6. 31.100 /  6. 31.100
   libavresample   3.  0.  0 /  3.  0.  0
   libswscale      4.  0.100 /  4.  0.100
   libswresample   2.  0.101 /  2.  0.101
   libpostproc    54.  0.100 / 54.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video.mp4':
   Metadata:
     major_brand     : isom
     minor_version   : 0
     compatible_brands: isom3gp4
     creation_time   : 2016-06-16 16:21:33
   Duration: 00:00:04.50, start: 0.000000, bitrate: 11419 kb/s
     Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), 
yuv420p, 1280x720, 11747 kb/s, 30.49 fps, 30 tbr, 90k tbn, 180k tbc 
(default)
     Metadata:
       creation_time   : 2016-06-16 16:21:33
       handler_name    : VideoHandle
     Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 
stereo, fltp, 114 kb/s (default)
     Metadata:
       creation_time   : 2016-06-16 16:21:33
       handler_name    : SoundHandle
[swscaler @ 0x5593935a9ba0] deprecated pixel format used, make sure you 
did set range correctly
Output #0, image2pipe, to 'pipe:':
   Metadata:
     major_brand     : isom
     minor_version   : 0
     compatible_brands: isom3gp4
     encoder         : Lavf57.25.100
     Stream #0:0(eng): Video: mjpeg, yuvj420p(pc), 1280x720, q=2-31, 200 
kb/s, 25 fps, 25 tbn, 25 tbc (default)
     Metadata:
       creation_time   : 2016-06-16 16:21:33
       handler_name    : VideoHandle
       encoder         : Lavc57.24.102 mjpeg
     Side data:
       unknown side data type 10 (24 bytes)
Stream mapping:
   Stream #0:0 -> #0:0 (h264 (native) -> mjpeg (native))
Press [q] to stop, [?] for help
Past duration 0.716942 too large
Past duration 0.900276 too large
frame=  110 fps=0.0 q=1.0 Lsize=   10221kB time=00:00:04.40 
bitrate=19029.1kbits/s dup=0 drop=22 speed=9.86x
video:10221kB audio:0kB subtitle:0kB other streams:0kB global 
headers:0kB muxing overhead: 0.000000%



But it fails if i use this commad:

$ cat video.mp4 | ffmpeg -i pipe: -r 25 -f image2pipe -vcodec mjpeg -q:v 
1 pipe: > result

ffmpeg version 3.0.2 Copyright (c) 2000-2016 the FFmpeg developers
   built with gcc 5.3.0 (GCC)
   configuration: --prefix=/usr --disable-debug --disable-static 
--disable-stripping --enable-avisynth --enable-avresample 
--enable-fontconfig --enable-gnutls --enable-gpl --enable-ladspa 
--enable-libass --enable-libbluray --enable-libdcadec 
--enable-libfreetype --enable-libfribidi --enable-libgsm 
--enable-libiec61883 --enable-libmodplug --enable-libmp3lame 
--enable-libopencore_amrnb --enable-libopencore_amrwb 
--enable-libopenjpeg --enable-libopus --enable-libpulse 
--enable-libschroedinger --enable-libsoxr --enable-libspeex 
--enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab 
--enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 
--enable-libx265 --enable-libxvid --enable-netcdf --enable-shared 
--enable-version3 --enable-x11grab
   libavutil      55. 17.103 / 55. 17.103
   libavcodec     57. 24.102 / 57. 24.102
   libavformat    57. 25.100 / 57. 25.100
   libavdevice    57.  0.101 / 57.  0.101
   libavfilter     6. 31.100 /  6. 31.100
   libavresample   3.  0.  0 /  3.  0.  0
   libswscale      4.  0.100 /  4.  0.100
   libswresample   2.  0.101 /  2.  0.101
   libpostproc    54.  0.100 / 54.  0.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x555fb0419a80] stream 1, offset 0x20: 
partial file
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x555fb0419a80] Could not find codec 
parameters for stream 0 (Video: h264 (avc1 / 0x31637661), none, 
1280x720, 11747 kb/s): unspecified pixel format
Consider increasing the value for the 'analyzeduration' and 'probesize' 
options
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'pipe:':
   Metadata:
     major_brand     : isom
     minor_version   : 0
     compatible_brands: isom3gp4
     creation_time   : 2016-06-16 16:21:33
   Duration: 00:00:04.50, bitrate: N/A
     Stream #0:0(eng): Video: h264 (avc1 / 0x31637661), none, 1280x720, 
11747 kb/s, 30.49 fps, 90k tbr, 90k tbn, 180k tbc (default)
     Metadata:
       creation_time   : 2016-06-16 16:21:33
       handler_name    : VideoHandle
     Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, 
fltp, 114 kb/s (default)
     Metadata:
       creation_time   : 2016-06-16 16:21:33
       handler_name    : SoundHandle
[buffer @ 0x555fb0445fa0] Unable to parse option value "-1" as pixel 
format
     Last message repeated 1 times
[buffer @ 0x555fb0445fa0] Error setting option pix_fmt to value -1.
[graph 0 input from stream 0:0 @ 0x555fb0419880] Error applying options 
to the filter.
Error opening filters!


I've tried to set analyzeduration and probesize to max values, but it 
doesn't helps:

$ cat video.mp4 | ffmpeg -analyzeduration 2147483647 -probesize 
2147483647 -i pipe: -r 25 -f image2pipe -vcodec mjpeg -q:v 1 pipe: > 
result

I've tried to set pix_fmt to yuv420p, but this options is not supported 
by h264:

$ cat video.mp4 | ffmpeg -pix_fmt yuv420p -i pipe: -r 25 -f image2pipe 
-vcodec mjpeg -q:v 1 pipe: > result

ffmpeg version 3.0.2 Copyright (c) 2000-2016 the FFmpeg developers
   built with gcc 5.3.0 (GCC)
   configuration: --prefix=/usr --disable-debug --disable-static 
--disable-stripping --enable-avisynth --enable-avresample 
--enable-fontconfig --enable-gnutls --enable-gpl --enable-ladspa 
--enable-libass --enable-libbluray --enable-libdcadec 
--enable-libfreetype --enable-libfribidi --enable-libgsm 
--enable-libiec61883 --enable-libmodplug --enable-libmp3lame 
--enable-libopencore_amrnb --enable-libopencore_amrwb 
--enable-libopenjpeg --enable-libopus --enable-libpulse 
--enable-libschroedinger --enable-libsoxr --enable-libspeex 
--enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab 
--enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 
--enable-libx265 --enable-libxvid --enable-netcdf --enable-shared 
--enable-version3 --enable-x11grab
   libavutil      55. 17.103 / 55. 17.103
   libavcodec     57. 24.102 / 57. 24.102
   libavformat    57. 25.100 / 57. 25.100
   libavdevice    57.  0.101 / 57.  0.101
   libavfilter     6. 31.100 /  6. 31.100
   libavresample   3.  0.  0 /  3.  0.  0
   libswscale      4.  0.100 /  4.  0.100
   libswresample   2.  0.101 /  2.  0.101
   libpostproc    54.  0.100 / 54.  0.100
Option pixel_format not found.


Is there a way to read this file from pipe?

Best,

Alexander


More information about the ffmpeg-user mailing list