Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm attempting to use ffmpeg to transcode an input video from whatever format it's in to an mp4 with h.264 video and MP3 audio and have the output go directly to FMS 4.5 using rtmp so the video will stream right after being transcoded. My ffmpeg command is:

ffmpeg -re -y -i /videos/to/be/transcoded/001 -c:v libx264 -b:v 480k -c:a libmp3lame -b:a 128k -f mp4 "rtmp://localhost/live/livestream"

Output:

ffmpeg version 1.2.1 Copyright (c) 2000-2013 the FFmpeg developers
  built on May 10 2013 15:14:14 with gcc 4.4.6 (GCC) 20120305 (Red Hat 4.4.6-4)
  configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --enable-shared --enable-runtime-cpudetect --enable-gpl --enable-version3 --enable-postproc --enable-avfilter --enable-pthreads --enable-x11grab --enable-vdpau --disable-avisynth --enable-frei0r --enable-libopencv --enable-libdc1394 --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --extra-cflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC' --disable-stripping
  libavutil      52. 18.100 / 52. 18.100
  libavcodec     54. 92.100 / 54. 92.100
  libavformat    54. 63.104 / 54. 63.104
  libavdevice    54.  3.103 / 54.  3.103
  libavfilter     3. 42.103 /  3. 42.103
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/global/xcodes/1/transcodeTest/vidInput/001':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2013-03-31 19:51:36
  Duration: 00:01:19.18, start: 0.000000, bitrate: 708 kb/s
    Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 640x360, 610 kb/s, 25 fps, 25 tbr, 50 tbn, 50 tbc
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 95 kb/s
    Metadata:
      creation_time   : 2013-03-31 19:51:37
      handler_name    : IsoMedia File Produced by Google, 5-11-2011
[libx264 @ 0x1a82ec0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x1a82ec0] profile High, level 3.0
[libx264 @ 0x1a82ec0] 264 - core 130 - H.264/MPEG-4 AVC codec - Copyleft 2003-2013 - 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=24 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=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=480 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[mp4 @ 0x1a826c0] muxer does not support non seekable output
Output #0, mp4, to 'rtmp://172.30.3.20/live/livestream':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    encoder         : Lavf54.63.104
    Stream #0:0(und): Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 640x360, q=-1--1, 480 kb/s, 90k tbn, 25 tbc
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: mp3 (i[0][0][0] / 0x0069), 44100 Hz, stereo, fltp, 128 kb/s
    Metadata:
      creation_time   : 2013-03-31 19:51:37
      handler_name    : IsoMedia File Produced by Google, 5-11-2011
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> libx264)
  Stream #0:1 -> #0:1 (aac -> libmp3lame)
Could not write header for output file #0 (incorrect codec parameters ?): Operation not permitted

The error I keep getting is "Could not write header for output file #0 (incorrect codec parameters?): Operation not permitted". But if I run this same command and have ffmpeg output to a new video file I don't get this error.

What's going wrong, and how can I avoid this error?

share|improve this question
add comment

1 Answer

I think this is the problem:

mp4 requires a seekable output, since it writes a MOOV atom at the start of the file once it finishes encoding the file. Therefore, this is not a suitable format for feeding data to rtmp.

Noice this error in your output:

[mp4 @ 0x1a826c0] muxer does not support non seekable output

Try using FLV for the container instead of MP4. Replace -f mp4 with -f flv in your command.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.