Ruslan Sharipov
Ruslan Sharipov

Reputation: 733

Send .mov file to ffmpeg via pipe (stdin)

If specify file in -i option, ffmpeg successfully handles file: http://pastebin.com/cn4w4aR2

But, if send file to ffmpeg via pipe (to stdin), i receive error stream 1, offset 0x24: partial file:

    serafim@serafim:~/Downloads/mov $ cat RecordedVideo-6sec.MOV | ffmpeg -i pipe:0 -codec copy -bsf h264_mp4toannexb -f hls -hls_list_size 0 -hls_time 5 -y index.m3u8
ffmpeg version 2.3.3 Copyright (c) 2000-2014 the FFmpeg developers
  built on Aug 25 2014 19:47:15 with Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/2.3.3 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --enable-vda --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid
  libavutil      52. 92.100 / 52. 92.100
  libavcodec     55. 69.100 / 55. 69.100
  libavformat    55. 48.100 / 55. 48.100
  libavdevice    55. 13.102 / 55. 13.102
  libavfilter     4. 11.100 /  4. 11.100
  libavresample   1.  3.  0 /  1.  3.  0
  libswscale      2.  6.100 /  2.  6.100
  libswresample   0. 19.100 /  0. 19.100
  libpostproc    52.  3.100 / 52.  3.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fc6a4816800] stream 1, offset 0x24: partial file
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fc6a4816800] Could not find codec parameters for stream 0 (Video: h264 (avc1 / 0x31637661), 720x1280, 1068 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:0':
  Metadata:
    major_brand     : qt
    minor_version   : 0
    compatible_brands: qt
    creation_time   : 2014-10-12 10:51:18
  Duration: 00:00:04.06, bitrate: N/A
    Stream #0:0(und): Video: h264 (avc1 / 0x31637661), 720x1280, 1068 kb/s, 24.61 fps, 120 tbr, 600 tbn, 1200 tbc (default)
    Metadata:
      creation_time   : 2014-10-12 10:51:18
      handler_name    : Core Media Data Handler
      encoder         : H.264
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 64 kb/s (default)
    Metadata:
      creation_time   : 2014-10-12 10:51:18
      handler_name    : Core Media Data Handler
[mpegts @ 0x7fc6a481b800] Using AVStream.codec.time_base as a timebase hint to the muxer is deprecated. Set AVStream.time_base instead.
    Last message repeated 1 times
[adts @ 0x7fc6a481e200] Using AVStream.codec.time_base as a timebase hint to the muxer is deprecated. Set AVStream.time_base instead.
Output #0, hls, to 'index.m3u8':
  Metadata:
    major_brand     : qt
    minor_version   : 0
    compatible_brands: qt
    encoder         : Lavf55.48.100
    Stream #0:0(und): Video: h264 (avc1 / 0x31637661), 720x1280, q=2-31, 1068 kb/s, 24.61 fps, 600 tbn, 600 tbc (default)
    Metadata:
      creation_time   : 2014-10-12 10:51:18
      handler_name    : Core Media Data Handler
      encoder         : H.264
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, 64 kb/s (default)
    Metadata:
      creation_time   : 2014-10-12 10:51:18
      handler_name    : Core Media Data Handler
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fc6a4816800] stream 1, offset 0x28: partial file
pipe:0: Invalid data found when processing input
frame=    0 fps=0.0 q=-1.0 Lsize=N/A time=00:00:00.00 bitrate=N/A
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

How send .mov file to ffmpeg via pipe?

Upvotes: 4

Views: 2348

Answers (1)

Multimedia Mike
Multimedia Mike

Reputation: 13256

Most likely problem: The QuickTime does not have its moov atom up front. Sometimes, the term "quickstart" is used to describe a QuickTime file that has its moov atom at the head of the file rather than the tail. A QuickTime demuxer needs to be able to read this atom first before it can interpret the data in the remainder of the file (the mdat atom).

If the input data comes from a file, the filesystem can seek randomly around the file to locate the necessary data. However, in piping via stdin, there is no such (backwards) seeking allowed.

The solution will be to use the qt-faststart utility included with FFmpeg to rearrange the QuickTime file, or rethink your solution so that it doesn't rely on non-seekable pipes.

Upvotes: 5

Related Questions