[FFmpeg-user] Specifying input and output formats with pipes

Rhodri James rhodri at kynesim.co.uk
Tue Jul 19 18:08:03 CEST 2011


On Tue, 19 Jul 2011 16:42:44 +0100, belcampo <belcampo at zonnet.nl> wrote:

> On 07/19/11 17:00, Rhodri James wrote:
>> Hi folks,
>>
>> I have a mildly convoluted transcoding requirement that I'm having
>> difficulty translating into command-line parameters to ffmpeg.
>>
>> I'm using ffmpeg as part of a Unix pipe chain, so the input is coming on
>> stdin and the output must go via stdout. My input stream is MPEG-4/2
>> wrapped in an H.222 transport stream. For a first step I wanted
>> MPEG-4/10 output, so I hauled out libx264:

OK, so I completely confused myself describing this: what I have is
PES-wrapped MPEG-4/2, and what I initially wanted was MPEG-4/10 in a
transport stream.  That should make my command line make a whole lot
more sense.

>>
>>> ffmpeg -i pipe: -f mpegts -vcodec libx264 pipe: 2>ffmpeg.log
>>
>> That appeared to work, as far as I can tell, though ffmpeg was very
>> sniffy about the headers. My test clip is too short to show anything
>> much (thanks everso, dear customer), but something is getting through
>> the experience. So far, so tentatively good.
>>
>> Now, for obscure and hopefully temporary reasons, I need to wrap that
>> H.264 output in MP4. How on earth do I do that? All I can glean from the
>> docs is that I should give my output file a ".mp4" suffix and all will
>> be well, but of course my "output file" is a pipe. There doesn't seem to
>> be any option to tell ffmpeg I want both H.264 transcode and MP4  
>> wrapping.

> The docs should also have told that -f mp4 makes this work, the  
> extension-thing is 'guessing'. With mp4 it's not that difficult but a  
> .mpg extension could mean ps or ts, for program or transport-stream.

The docs keep leaving me thinking "-f" is forcing _input_ format,
but that's a separate matter.  Unfortunately replacing "-f mpegts" with
"-f mp4" fails for me.  Here's the (trimmed) log:


ffmpeg version 0.7-rc1, Copyright (c) 2000-2011 the FFmpeg developers
   built on Jul  6 2011 19:37:39 with gcc 4.5.2
   configuration: --enable-gpl --enable-libx264
   libavutil    50. 40. 1 / 50. 40. 1
   libavcodec   52.120. 0 / 52.120. 0
   libavformat  52.108. 0 / 52.108. 0
   libavdevice  52.  4. 0 / 52.  4. 0
   libavfilter   1. 77. 0 /  1. 77. 0
   libswscale    0. 13. 0 /  0. 13. 0
[*snip whinging about incomplete headers*]
Input #0, mpeg, from 'pipe:':
   Duration: N/A, bitrate: N/A
     Stream #0.0[0x1e0]: Video: mpeg4, yuv420p, 320x240 [PAR 1:1 DAR 4:3],  
30k tbr, 90k tbn, 30k tbc
[buffer @ 0x211f0e0] w:320 h:240 pixfmt:yuv420p
[libx264 @ 0x211ec20] Default settings detected, using medium profile
[libx264 @ 0x211ec20] using SAR=1/1
[libx264 @ 0x211ec20] MB rate (9000000) > level limit (983040)
[libx264 @ 0x211ec20] using cpu capabilities: MMX2 SSE2Fast SSSE3  
FastShuffle SSE4.2
[libx264 @ 0x211ec20] profile High, level 5.1
[libx264 @ 0x211ec20] 264 - core 106 Ubuntu_2:0.106.1741-3 - H.264/MPEG-4  
AVC codec - Copyleft 2003-2010 - http://www.videolan.org/x264.html -  
options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7  
psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1  
8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=1  
sliced_threads=0 nr=0 decimate=1 interlaced=0 constrained_intra=0  
bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0  
weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0  
rc_lookahead=40 rc=abr mbtree=1 bitrate=200 ratetol=1.0 qcomp=0.60  
qpmin=10 qpmax=51 qpstep=4 ip_ratio=1.40 aq=1:1.00
[mp4 @ 0x211dbe0] muxer does not support non seekable output
Output #0, mp4, to 'pipe:':
   Metadata:
     encoder         : Lavf52.108.0
     Stream #0.0: Video: libx264, yuv420p, 320x240 [PAR 1:1 DAR 4:3],  
q=2-31, 200 kb/s, 90k tbn, 30k tbc
Stream mapping:
   Stream #0.0 -> #0.0
Could not write header for output file #0 (incorrect codec parameters ?)

-- 
Rhodri James
Kynesim Ltd


More information about the ffmpeg-user mailing list