Generating all P frame intra refresh H264 with x264 - ffmpeg

I am trying to generate a periodic intra refresh h264 stream with only P frames using ffmpeg and x264 but I always get an I frame at the start.
Is there a way with x264 to create a P frame only stream?
Commands I am using:
ffmpeg -f lavfi -re -i testsrc=duration=5:size=1920x1080:rate=30000/1001 -s 1920x1080 -pix_fmt yuv420p -f rawvideo out.yuv
x264 --input-res 1920x1080 --intra-refresh out.yuv --b-pyramid none -b 0 --ref 0 -o out.264
Verification:
ffprobe -show_frames out.264 |grep pict_type=I
Or just looking at the x264 output e.g.
yuv [info]: 1920x1080p 0:0 # 25/1 fps (cfr)
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
x264 [info]: profile High, level 4.0, 4:2:0, 8-bit
x264 [info]: frame I:1 Avg QP:13.63 size: 12189
x264 [info]: frame P:149 Avg QP:13.59 size: 874
x264 [info]: mb I I16..4: 78.7% 18.6% 2.7%
x264 [info]: mb P I16..4: 2.3% 0.1% 0.0% P16..4: 3.2% 0.3% 0.0% 0.0% 0.0% skip:94.1%
x264 [info]: 8x8 transform intra:7.6% inter:91.5%
x264 [info]: coded y,uvDC,uvAC intra: 1.3% 18.9% 3.6% inter: 0.1% 1.1% 0.1%
x264 [info]: i16 v,h,dc,p: 86% 6% 1% 7%
x264 [info]: i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 42% 22% 36% 0% 0% 0% 0% 0% 0%
x264 [info]: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 29% 30% 32% 3% 1% 3% 0% 3% 0%
x264 [info]: i8c dc,h,v,p: 28% 7% 55% 9%
x264 [info]: Weighted P-Frames: Y:0.0% UV:0.0%
x264 [info]: kb/s:189.96
encoded 150 frames, 66.76 fps, 189.96 kb/s

Thanks to #Gyan and #nobody555 this works:
ffmpeg -f lavfi -re -i testsrc=duration=60:size=1920x1080:rate=30000/1001 -s 1920x1080 -pix_fmt yuv420p -f rawvideo -|x264 --input-res 1920x1080 --intra-refresh -o - -|ffmpeg -r "30000/1001" -fflags +genpts -i - -c copy -movflags frag_keyframe+empty_moov -f mp4 -|ffmpeg -i - -ss 200ms -c copy -f mpegts out.ts -y

Related

How to repair corrupted .mkv

Situation
I have accidentally overwrote .mkv file and luckily restored it by using PhotoRec.
Now I have a large size (4.9GB, about 1 hour) file named "f1.mkv" but cannot play it.
To be precise, only about the first second of the video is played, after which the screen remains still and only the current time on the timeline continues to advance.
If I try to jump ahead a few minutes, I get a dialog box that says "Output stream cannot be retrieved".
I'm using ubuntu20.04 desktop and its default media player.
What I have tried
Play it using VLC -> Same result as above
ffmpeg -i f1.mkv -> No error, showing apparently correct information as below:
Input #0, matroska,webm, from 'f1.mkv':
Metadata:
ENCODER : Lavf58.29.100
Duration: 00:56:20.67, start: 0.000000, bitrate: 12264 kb/s
Stream #0:0: Video: h264 (Constrained Baseline), yuv420p(tv, bt709, progressive), 1920x1080, 30 fps, 30 tbr, 1k tbn, 2k tbc (default)
Metadata:
DURATION : 00:56:20.666000000
Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp (default)
Metadata:
title : Track1
DURATION : 00:56:20.672000000
Stream #0:2: Audio: aac (LC), 48000 Hz, stereo, fltp (default)
Metadata:
title : Track2
DURATION : 00:56:20.650000000
ffmpeg -i f1.mkv f1.mp4 -> Huge amount of errors as below
[h264 # 0x55d7ff486440] Invalid NAL unit 0, skipping.
Last message repeated 77 times
[matroska,webm # 0x55d7ff42d6c0] Length 5 indicated by an EBML number's first byte 0x0a at pos 2105851 (0x2021fb) exceeds max length 4.
[h264 # 0x55d7ff486440] Invalid NAL unit 0, skipping.
Last message repeated 22 times
[h264 # 0x55d7ff486440] negative number of zero coeffs at 108 45
[h264 # 0x55d7ff486440] error while decoding MB 108 45
[h264 # 0x55d7ff486440] data partitioning is not implemented. Update your FFmpeg version to the newest one from Git. If the problem still occurs, it means that your file has a feature which has not been implemented.
[h264 # 0x55d7ff486440] If you want to help, upload a sample of this file to ftp://upload.ffmpeg.org/incoming/ and contact the ffmpeg-devel mailing list. (ffmpeg-devel#ffmpeg.org)
[h264 # 0x55d7ff486440] non-existing PPS 5 referenced
[h264 # 0x55d7ff486440] decode_slice_header error
[h264 # 0x55d7ff486440] Frame num change from 4 to 22
[h264 # 0x55d7ff486440] decode_slice_header error
[h264 # 0x55d7ff486440] Frame num change from 4 to 22
[h264 # 0x55d7ff486440] decode_slice_header error
...
[matroska,webm # 0x55d7ff42d6c0] 0x00 at pos 429923807 (0x19a01ddf) invalid as first byte of an EBML number
frame= 153 fps= 17 q=29.0 size= 1024kB time=00:00:05.52 bitrate=1518.2kbits/s dup=60 drop=0 speed=0.614xf108855296.mkv: corrupt decoded frame in stream 0
More than 1000 frames duplicated
frame=70202 fps=421 q=29.0 size= 92160kB time=00:39:00.22 bitrate= 322.6kbits/s dup=70093 drop=0 speed= 1[h264 # 0x55d7ff5cdb80] out of range intra chroma pred mode
[h264 # 0x55d7ff5cdb80] error while decoding MB 64 42
[h264 # 0x55d7ff5cdb80] concealing 3105 DC, 3105 AC, 3105 MV errors in P frame
[matroska,webm # 0x55d7ff42d6c0] Element at 0x9f1f763c ending at 0xa0cc7e77 exceeds containing master element ending at 0x9f24b2cb
frame=70328 fps=393 q=29.0 size= 92160kB time=00:39:04.34 bitrate= 322.0kbits/s dup=70093 drop=123 speed=1f108855296.mkv: corrupt decoded frame in stream 0
frame=70334 fps=393 q=-1.0 Lsize= 93350kB time=00:39:04.38 bitrate= 326.2kbits/s dup=70093 drop=130 speed=13.1x
video:92446kB audio:74kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.896887%
[libx264 # 0x55d7ff4560c0] frame I:283 Avg QP:14.61 size:305979
[libx264 # 0x55d7ff4560c0] frame P:17727 Avg QP:15.49 size: 214
[libx264 # 0x55d7ff4560c0] frame B:52324 Avg QP:21.34 size: 82
[libx264 # 0x55d7ff4560c0] consecutive B-frames: 0.8% 0.0% 0.0% 99.2%
[libx264 # 0x55d7ff4560c0] mb I I16..4: 8.0% 48.9% 43.2%
[libx264 # 0x55d7ff4560c0] mb P I16..4: 0.0% 0.0% 0.0% P16..4: 0.3% 0.0% 0.0% 0.0% 0.0% skip:99.6%
[libx264 # 0x55d7ff4560c0] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 0.2% 0.0% 0.0% direct: 0.0% skip:99.8% L0:24.6% L1:75.1% BI: 0.3%
[libx264 # 0x55d7ff4560c0] 8x8 transform intra:48.9% inter:55.1%
[libx264 # 0x55d7ff4560c0] coded y,uvDC,uvAC intra: 86.3% 73.0% 64.4% inter: 0.0% 0.1% 0.0%
[libx264 # 0x55d7ff4560c0] i16 v,h,dc,p: 33% 53% 10% 3%
[libx264 # 0x55d7ff4560c0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 12% 21% 15% 7% 9% 6% 10% 7% 13%
[libx264 # 0x55d7ff4560c0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 30% 9% 5% 7% 6% 8% 5% 9%
[libx264 # 0x55d7ff4560c0] i8c dc,h,v,p: 47% 34% 12% 6%
[libx264 # 0x55d7ff4560c0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 # 0x55d7ff4560c0] ref P L0: 88.0% 3.6% 6.7% 1.7%
[libx264 # 0x55d7ff4560c0] ref B L0: 74.5% 24.6% 0.8%
[libx264 # 0x55d7ff4560c0] ref B L1: 98.8% 1.2%
[libx264 # 0x55d7ff4560c0] kb/s:323.02
[aac # 0x55d7ff459440] Qavg: 29327.965
Now I can see f1.mp4 for few more seconds with stuttering screen.
Is there I can do more?

FFMPEG when live streaming sends a message and exits after some frames were sent

when doing an streaming with FFMPEG all works perfectly until I get these messages and then, ffmpeg.exe exits:
av_interleaved_write_frame(): Unknown error
frame= 1224 fps=3.4 q=13.0 size= 2758kB time=00:01:21.94 bitrate= 275.8kbits/s speed=0.226x
av_interleaved_write_frame(): Unknown error
[flv # 000001e310e8a1c0] Failed to update header with correct duration.
[flv # 000001e310e8a1c0] Failed to update header with correct filesize.
Error writing trailer of rtmp://example.com/s/2b32abdc-130c-43e5-997e-079e69d1fd7f: Error number -10053 occurred
frame= 1224 fps=3.4 q=13.0 Lsize= 2758kB time=00:01:21.98 bitrate= 275.6kbits/s speed=0.226x
video:2481kB audio:221kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.084671%
[libx264 # 000001e310ad6080] frame I:41 Avg QP:10.29 size: 57664
[libx264 # 000001e310ad6080] frame P:1183 Avg QP:13.52 size: 148
[libx264 # 000001e310ad6080] mb I I16..4: 100.0% 0.0% 0.0%
[libx264 # 000001e310ad6080] mb P I16..4: 0.1% 0.0% 0.0% P16..4: 0.2% 0.0% 0.0% 0.0% 0.0% skip:99.7%
[libx264 # 000001e310ad6080] coded y,uvDC,uvAC intra: 10.9% 7.1% 5.4% inter: 0.0% 0.1% 0.0%
[libx264 # 000001e310ad6080] i16 v,h,dc,p: 84% 6% 6% 4%
[libx264 # 000001e310ad6080] i8c dc,h,v,p: 91% 6% 3% 1%
[libx264 # 000001e310ad6080] kb/s:248.98
[aac # 000001e310a46d40] Qavg: 108.454
Conversion failed!
Normally, the messages I received are similar to this:
frame= 1196 fps=3.4 q=13.0 size= 2692kB time=00:01:20.08 bitrate= 275.4kbits/s speed=0.227x
Which are the expected messages. Sometimes, I received this message, but this does not cause ffmpeg.exe to exit:
Input #0, matroska,webm, from 'pipe:':
Metadata:
encoder : Chrome
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0(eng): Audio: opus, 48000 Hz, mono, fltp (default)
Stream #0:1(eng): Video: h264 (Constrained Baseline), yuv420p(progressive), 1920x1080, SAR 1:1 DAR 16:9, 30.30 fps, 14.99 tbr, 1k tbn, 60 tbc (default)
What may be happening? maybe it is a problem of the RTMP server? or something is wrong with FFMPEG?
This version of FFMPEG.EXE is for windows. The programming language is C# from where I am launching FFMPEG.EXE process.
As I told, this happens after several frames sent to the server. Only once, this problem occured after a few frames sent. That is why I suspect that the RTMP server is the problem.
EDIT: This is the command:
FFMPEG -i - -c:v libx264 -preset ultrafast -tune zerolatency -max_muxing_queue_size 1000 -bufsize 5000 -r 15 -g 30 -keyint_min 30 -x264opts keyint=30 -crf 25 -pix_fmt yuv420p -profile:v baseline -level 3 -c:a aac -b:a 22k -ar 22050 -f flv rtmp://rtmp.xxxx.yyyy
Regards
Jaime

error while converting yuv to mp4 using ffmpeg

I am trying to convert a yuv file to mp4 using:
ffmpeg -f rawvideo -vcodec rawvideo -s 1920x1080 -r 25 -pix_fmt yuv420p -i inputfile.yuv -c:v libx264 -preset ultrafast -qp 0 output.mp4
but i am getting following error:
[rawvideo # 0000023f70bf8d20] Invalid buffer size, packet size 2649600 < expected frame_size 3110400
Error while decoding stream #0:0: Invalid argument
frame= 251 fps= 22 q=-1.0 Lsize= 373766kB time=00:00:10.00 bitrate=306186.8kbits/s speed=0.861x
video:373763kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000738%
[libx264 # 0000023f70bfaae0] frame I:2 Avg QP: 0.00 size:1412854
[libx264 # 0000023f70bfaae0] frame P:249 Avg QP: 0.00 size:1525733
[libx264 # 0000023f70bfaae0] mb I I16..4: 100.0% 0.0% 0.0%
[libx264 # 0000023f70bfaae0] mb P I16..4: 57.0% 0.0% 0.0% P16..4: 43.0% 0.0% 0.0% 0.0% 0.0% skip: 0.0%
[libx264 # 0000023f70bfaae0] coded y,uvDC,uvAC intra: 100.0% 100.0% 100.0% inter: 100.0% 100.0% 100.0%
[libx264 # 0000023f70bfaae0] i16 v,h,dc,p: 45% 52% 3% 0%
[libx264 # 0000023f70bfaae0] i8c dc,h,v,p: 1% 90% 9% 0%
[libx264 # 0000023f70bfaae0] kb/s:304966.66

What is wrong with my FFMPEG command for streaming? [duplicate]

Goal is to create stream for facebook from image and audio file.
This is my command:
ffmpeg \
-re -y \
-loop 1 \
-f image2 \
-i ./maxresdefault.jpg \
-i ./audio-loop.mp3 \
-ar 44100 \
-b:a 128k \
-vcodec libx264 \
-vf scale=800:600 \
-b:v 1000k -minrate 1000k -maxrate 1000k -bufsize 500k \
-f flv 'rtmp://rtmp-api.facebook.com:80/rtmp/...'
I get error like:
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
Stream #1:0 -> #0:1 (mp3 (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
[flv # 0x1637d00] Packets are not in the proper order with respect to DTSkbits/s
av_interleaved_write_frame(): Invalid argument <<< --------
[flv # 0x1637d00] Failed to update header with correct duration.
[flv # 0x1637d00] Failed to update header with correct filesize.
frame= 57 fps= 22 q=-1.0 Lsize= 1325kB time=00:01:21.60 bitrate= 133.0kbits/s
video:26kB audio:1276kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.749549%
[libx264 # 0x1644760] frame I:1 Avg QP:17.89 size: 26318
[libx264 # 0x1644760] frame P:14 Avg QP:10.39 size: 7242
[libx264 # 0x1644760] frame B:42 Avg QP:13.38 size: 118
[libx264 # 0x1644760] consecutive B-frames: 1.8% 0.0% 0.0% 98.2%
[libx264 # 0x1644760] mb I I16..4: 6.7% 61.2% 32.1%
[libx264 # 0x1644760] mb P I16..4: 0.2% 0.1% 0.3% P16..4: 29.3% 2.3% 4.9% 0.0% 0.0% skip:62.9%
[libx264 # 0x1644760] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 8.3% 0.0% 0.0% direct: 0.0% skip:91.7% L0: 5.1% L1:94.9% BI: 0.0%
[libx264 # 0x1644760] 8x8 transform intra:58.0% inter:41.3%
[libx264 # 0x1644760] coded y,uvDC,uvAC intra: 69.4% 65.4% 52.4% inter: 4.5% 4.2% 2.9%
[libx264 # 0x1644760] i16 v,h,dc,p: 13% 57% 11% 18%
[libx264 # 0x1644760] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 27% 10% 4% 6% 7% 7% 6% 8%
[libx264 # 0x1644760] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 40% 28% 9% 3% 5% 4% 4% 3% 3%
[libx264 # 0x1644760] i8c dc,h,v,p: 58% 24% 16% 3%
[libx264 # 0x1644760] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 # 0x1644760] ref P L0: 93.5% 0.6% 4.8% 1.1%
[libx264 # 0x1644760] ref B L0: 69.3% 29.3% 1.5%
[libx264 # 0x1644760] ref B L1: 95.5% 4.5%
[libx264 # 0x1644760] kb/s:465.47
Conversion failed!
I've been searching for about 4 hours. I believe it's something to do with Sound.
I was having the same problem, ended up switching my audio encoding to libvo_aacenc instead of libmp3lame...
I have not tested if the audio still works however the stream is no longer dying.

Error using ffmpeg image2pipe with phantomjs to render video from webpage screenshots

I am trying to use phantomjs with ffmpeg to complie videos from screenshots of a webpage as described here:
https://groups.google.com/forum/#!msg/phantomjs/wluVGGjhL90/oGBXqh7QP44J
I have the following test.js file:
var page = require('webpage').create();
page.clipRect = { top: 0, left: 0, width: 900, height: 800};
page.viewportSize = { width: 900, height: 800};
var url = 'http://dl.dropbox.com/u/621993/voronoi/voronoi.html';
var frames = 100;
page.open(url, function(){
setInterval(function(){
page.render('/dev/stdout');
if( frames == 0 ){
phantom.exit();
}
frames--;
}, 100);
});
Then I run this command, taken from the link above:
$ phantomjs test.js |ffmpeg -c:v png -f image2pipe -r 10 -sameq -i - -y test.mp4
Including -sameq causes an error in ffmpeg, so I took it out and ran:
$ phantomjs test.js |ffmpeg -c:v png -f image2pipe -r 10 -i - -y test.mp4
I get the following output from ffmpeg:
ffmpeg version 2.0 Copyright (c) 2000-2013 the FFmpeg developers
built on Jul 22 2013 09:14:18 with llvm-gcc 4.2.1 (LLVM build 2336.11.00)
configuration: --prefix=/Volumes/Ramdisk/sw --enable-gpl --enable-pthreads --enable-version3 --enable-libspeex --enable-libvpx --disable-decoder=libvpx --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-avfilter --enable-libopencore_amrwb --enable-libopencore_amrnb --enable-filters --enable-libgsm --arch=x86_64 --enable-runtime-cpudetect
libavutil 52. 38.100 / 52. 38.100
libavcodec 55. 18.102 / 55. 18.102
libavformat 55. 12.100 / 55. 12.100
libavdevice 55. 3.100 / 55. 3.100
libavfilter 3. 79.101 / 3. 79.101
libswscale 2. 3.100 / 2. 3.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 3.100 / 52. 3.100
Input #0, image2pipe, from 'pipe:':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: png, rgba, 900x800 [SAR 2835:2835 DAR 9:8], 10 fps, 10 tbr, 10 tbn, 10 tbc
No pixel format specified, yuv444p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
[libx264 # 0x7f8973803800] using SAR=1/1
[libx264 # 0x7f8973803800] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 # 0x7f8973803800] profile High 4:4:4 Predictive, level 3.1, 4:4:4 8-bit
[libx264 # 0x7f8973803800] 264 - core 133 - 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=4 threads=6 lookahead_threads=1 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=10 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'test.mp4':
Metadata:
encoder : Lavf55.12.100
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv444p, 900x800 [SAR 1:1 DAR 9:8], q=-1--1, 10240 tbn, 10 tbc
Stream mapping:
Stream #0:0 -> #0:0 (png -> libx264)
pipe:: Input/output error0 size= 65kB time=00:00:04.10 bitrate= 130.5kbits/s
frame= 93 fps= 15 q=-1.0 Lsize= 71kB time=00:00:09.10 bitrate= 63.8kbits/s
video:69kB audio:0kB subtitle:0 global headers:0kB muxing overhead 2.696543%
[libx264 # 0x7f8973803800] frame I:1 Avg QP:15.17 size: 50212
[libx264 # 0x7f8973803800] frame P:24 Avg QP: 8.91 size: 575
[libx264 # 0x7f8973803800] frame B:68 Avg QP: 9.69 size: 87
[libx264 # 0x7f8973803800] consecutive B-frames: 2.2% 0.0% 3.2% 94.6%
[libx264 # 0x7f8973803800] mb I I16..4: 64.2% 19.6% 16.1%
[libx264 # 0x7f8973803800] mb P I16..4: 2.8% 0.2% 0.1% P16..4: 0.5% 0.0% 0.0% 0.0% 0.0% skip:96.3%
[libx264 # 0x7f8973803800] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 3.1% 0.0% 0.0% direct: 0.0% skip:96.9% L0:76.4% L1:23.6% BI: 0.0%
[libx264 # 0x7f8973803800] 8x8 transform intra:13.9% inter:54.0%
[libx264 # 0x7f8973803800] coded y,u,v intra: 7.4% 4.8% 5.2% inter: 0.1% 0.1% 0.1%
[libx264 # 0x7f8973803800] i16 v,h,dc,p: 68% 31% 2% 0%
[libx264 # 0x7f8973803800] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 48% 20% 32% 0% 0% 0% 0% 0% 0%
[libx264 # 0x7f8973803800] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 30% 31% 20% 3% 3% 3% 5% 3% 4%
[libx264 # 0x7f8973803800] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 # 0x7f8973803800] ref P L0: 91.9% 0.0% 7.4% 0.7%
[libx264 # 0x7f8973803800] ref B L0: 20.5% 79.5%
[libx264 # 0x7f8973803800] ref B L1: 99.9% 0.1%
[libx264 # 0x7f8973803800] kb/s:60.16
The output test.mp4 file is a blank 10 second video - just a black screen. From what i can tell, I am getting a pipe:: Input/output error from ffmpeg.
I am pretty new to ffmpeg and I have tried changing some parameters and video codecs in the ffmpeg call, but have not found a solution yet. Can anyone advise?
I got this to work by adding -pix_fmt yuv420p to the command:
$ phantomjs test.js | ffmpeg -y -c:v png -f image2pipe -r 10 -i - -c:v libx264 -pix_fmt yuv420p -movflags +faststart test.mp4
Otherwise the output will use a chroma subsampling type (yuv444p in this case) that is not compatible with "dumb" players like QuickTime which require yuv420p – YUV color space with 4:2:0 chroma subsampling.
Adding -movflags +faststart as an input option will allow the video to begin playing by the viewer before it is completely downloaded. Useful if the video will be viewed in a browser.
Default encoding settings for libx264 will be used in this example resulting in H.264 video. See the FFmpeg and x264 Encoding Guide for more information on controlling quality and encoding speed.
I'm using user1690179's command but the mp4 is corrupted.
I'm able to fix it with
./ffmpeg -i test.mp4 -c copy repaired.mp4
Maybe that's because of the pipe:: Input/output error?
Maybe phantomjs doesn't end gracefully?
i don't know much about phantomjs but if you plan on using regular node.js with ffmpeg and request/spawn i have done something similar. It incorporates the use of request to pipe in images for the snapshot url and ffmpeg through spawn for the mjpeg
ffmpeg jpeg stream to webm only creates a file .webm with 1 frame (snapshot) or empty .webm file (mjpeg)
I was having trouble with making webm files from jpeg snapshot and mjpeg stream.. but the answer provided took care of it.
I hope someone finds it useful as this question is pretty old... and perhaps this method is better at serving the task.

Resources