I am trying to convert a set of jpg files to a slideshow with varying durations using ffconcat
output.txt contents:
ffconcat version 1.0
file slide_0001.jpg
duration 0.163
file slide_0002.jpg
duration 0.533
file slide_0003.jpg
duration 1.067
file slide_0004.jpg
duration 0.533
file slide_0005.jpg
etc.
FFmpeg command:
ffmpeg -i output.txt output.mkv
I also tried:
ffmpeg -i output.txt -c:v copy output.mkv
However, when converting, the colours of the images become skewed.
White becomes pink / purple and dark green becomes light green.
The same happens when choosing different codecs and containers.
Is there a way to solve this?
EDIT:
I performed the same conversion again. I attached the log output as requested.
However, in the meantime I have figured out that converting without ffconcat duration and then altering timecodes with mp4fpsmod is more efficient in terms of storage (3 vs 40 MB) and gives less issues in different players. The result is nonetheless the same: colours are still wrong, both on my workstation (Ubuntu 18.04) and laptop (macOS Mojave).
I tried to alter things with pix_fmt and -vf format as can be seen in the second log output. This did not solve the problem.
Background info:
The input jpg files are from a lecture recording made with MediaSite, which has both a video stream for the room as well as this slideshow stream for the slides.
Example of input:
Example of output:
log output MKV conversion:
$ ffmpeg -i outputnew.txt output12345.mkv
ffmpeg version 4.1 Copyright (c) 2000-2018 the FFmpeg developers
built with Apple LLVM version 10.0.0 (clang-1000.11.45.5)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.1 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gpl --enable-libmp3lame --enable-libopus --enable-libsnappy --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-opencl --enable-videotoolbox
libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
libpostproc 55. 3.100 / 55. 3.100
Input #0, concat, from 'outputnew.txt':
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: mjpeg, yuvj444p(pc, bt470bg/unknown/unknown), 1280x720, 25 tbr, 25 tbn, 25 tbc
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 # 0x7fb284802800] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 # 0x7fb284802800] profile High 4:4:4 Predictive, level 3.1, 4:4:4 8-bit
[libx264 # 0x7fb284802800] 264 - core 152 r2854 e9a5903 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=0 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=25 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, matroska, to 'output12345.mkv':
Metadata:
encoder : Lavf58.20.100
Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuvj444p(pc), 1280x720, q=-1--1, 25 fps, 1k tbn, 25 tbc
Metadata:
encoder : Lavc58.35.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
[mjpeg # 0x7fb284061200] EOI missing, emulating=00:02:12.96 bitrate= 491.3kbits/s speed=14.3x
[matroska # 0x7fb284812e00] Starting new cluster due to timestampte= 487.2kbits/s speed=14.3x
[matroska # 0x7fb284812e00] Starting new cluster due to timestampte= 333.0kbits/s speed=22.3x
[matroska # 0x7fb284812e00] Starting new cluster due to timestampte= 338.8kbits/s speed=22.7x
Last message repeated 2 times
[matroska # 0x7fb284812e00] Starting new cluster due to timestampte= 164.7kbits/s speed=41.6x
[matroska # 0x7fb284812e00] Starting new cluster due to timestampte= 122.7kbits/s speed=55.7x
Last message repeated 1 times
[matroska # 0x7fb284812e00] Starting new cluster due to timestampte= 111.2kbits/s speed=60.5x
Last message repeated 1 times
[matroska # 0x7fb284812e00] Starting new cluster due to timestampte= 105.3kbits/s speed=64.4x
[matroska # 0x7fb284812e00] Starting new cluster due to timestampte= 82.2kbits/s speed=82.7x
Last message repeated 1 times
[matroska # 0x7fb284812e00] Starting new cluster due to timestampte= 79.7kbits/s speed=85.8x
Last message repeated 2 times
[matroska # 0x7fb284812e00] Starting new cluster due to timestampte= 59.7kbits/s speed= 114x
[matroska # 0x7fb284812e00] Starting new cluster due to timestampte= 53.8kbits/s speed= 127x
[matroska # 0x7fb284812e00] Starting new cluster due to timestampte= 54.7kbits/s speed= 124x
Last message repeated 1 times
[matroska # 0x7fb284812e00] Starting new cluster due to timestampte= 47.1kbits/s speed= 143x
Last message repeated 1 times
[matroska # 0x7fb284812e00] Starting new cluster due to timestampte= 47.0kbits/s speed= 144x
Last message repeated 1 times
[matroska # 0x7fb284812e00] Starting new cluster due to timestampte= 44.6kbits/s speed= 151x
Last message repeated 1 times
[matroska # 0x7fb284812e00] Starting new cluster due to timestampte= 34.4kbits/s speed= 194x
Last message repeated 2 times
[matroska # 0x7fb284812e00] Starting new cluster due to timestampte= 32.9kbits/s speed= 204x
Last message repeated 2 times
[matroska # 0x7fb284812e00] Starting new cluster due to timestampte= 32.8kbits/s speed= 203x
[matroska # 0x7fb284812e00] Starting new cluster due to timestampte= 32.6kbits/s speed= 202x
Last message repeated 1 times
[matroska # 0x7fb284812e00] Starting new cluster due to timestampte= 28.8kbits/s speed= 229x
Last message repeated 2 times
[matroska # 0x7fb284812e00] Starting new cluster due to timestampte= 27.9kbits/s speed= 236x
[matroska # 0x7fb284812e00] Starting new cluster due to timestampte= 27.9kbits/s speed= 233x
[matroska # 0x7fb284812e00] Starting new cluster due to timestampte= 23.9kbits/s speed= 274x
[matroska # 0x7fb284812e00] Starting new cluster due to timestampte= 24.2kbits/s speed= 273x
Last message repeated 2 times
[matroska # 0x7fb284812e00] Starting new cluster due to timestampte= 24.2kbits/s speed= 274x
[matroska # 0x7fb284812e00] Starting new cluster due to timestampte= 24.0kbits/s speed= 276x
[matroska # 0x7fb284812e00] Starting new cluster due to timestampte= 24.2kbits/s speed= 273x
[matroska # 0x7fb284812e00] Starting new cluster due to timestampte= 23.6kbits/s speed= 278x
Last message repeated 1 times
[matroska # 0x7fb284812e00] Starting new cluster due to timestampte= 23.7kbits/s speed= 279x
[matroska # 0x7fb284812e00] Starting new cluster due to timestampte= 23.6kbits/s speed= 279x
[matroska # 0x7fb284812e00] Starting new cluster due to timestampte= 24.0kbits/s speed= 276x
Last message repeated 1 times
[matroska # 0x7fb284812e00] Starting new cluster due to timestampte= 23.5kbits/s speed= 281x
Last message repeated 1 times
[matroska # 0x7fb284812e00] Starting new cluster due to timestampte= 20.4kbits/s speed= 325x
[mjpeg # 0x7fb28502a000] EOI missing, emulating
[matroska # 0x7fb284812e00] Starting new cluster due to timestampte= 20.1kbits/s speed= 329x
Last message repeated 1 times
[matroska # 0x7fb284812e00] Starting new cluster due to timestampte= 20.1kbits/s speed= 330x
frame= 635 fps= 14 q=-1.0 Lsize= 37389kB time=04:22:06.76 bitrate= 19.5kbits/s speed= 343x
video:37378kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.029620%
[libx264 # 0x7fb284802800] frame I:16 Avg QP:11.98 size:154224
[libx264 # 0x7fb284802800] frame P:184 Avg QP:13.30 size: 79029
[libx264 # 0x7fb284802800] frame B:435 Avg QP:13.19 size: 48887
[libx264 # 0x7fb284802800] consecutive B-frames: 6.0% 4.4% 10.9% 78.7%
[libx264 # 0x7fb284802800] mb I I16..4: 55.7% 0.0% 44.3%
[libx264 # 0x7fb284802800] mb P I16..4: 32.4% 0.0% 21.5% P16..4: 13.3% 15.1% 11.3% 0.0% 0.0% skip: 6.4%
[libx264 # 0x7fb284802800] mb B I16..4: 17.8% 0.0% 7.2% B16..8: 19.1% 19.4% 6.5% direct:14.6% skip:15.3% L0:47.0% L1:38.9% BI:14.1%
[libx264 # 0x7fb284802800] coded y,u,v intra: 63.7% 26.1% 56.3% inter: 46.5% 24.6% 43.5%
[libx264 # 0x7fb284802800] i16 v,h,dc,p: 19% 18% 58% 4%
[libx264 # 0x7fb284802800] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 35% 20% 25% 4% 4% 3% 3% 3% 3%
[libx264 # 0x7fb284802800] Weighted P-Frames: Y:5.4% UV:5.4%
[libx264 # 0x7fb284802800] ref P L0: 43.2% 4.4% 30.8% 21.4% 0.2%
[libx264 # 0x7fb284802800] ref B L0: 64.1% 27.3% 8.6%
[libx264 # 0x7fb284802800] ref B L1: 85.3% 14.7%
[libx264 # 0x7fb284802800] kb/s:19.25
Log output mp4 conversion:
$ ffmpeg -i slide_%04d.jpg -vf format=rgba -pix_fmt yuv420p -vcodec libx264 -movflags +faststart -preset veryslow output12345.mp4
ffmpeg version 4.1 Copyright (c) 2000-2018 the FFmpeg developers
built with Apple LLVM version 10.0.0 (clang-1000.11.45.5)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.1 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gpl --enable-libmp3lame --enable-libopus --enable-libsnappy --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-opencl --enable-videotoolbox
libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
libpostproc 55. 3.100 / 55. 3.100
Input #0, image2, from 'slide_%04d.jpg':
Duration: 00:00:25.36, start: 0.000000, bitrate: N/A
Stream #0:0: Video: mjpeg, yuvj444p(pc, bt470bg/unknown/unknown), 1280x720, 25 fps, 25 tbr, 25 tbn, 25 tbc
File 'output12345.mp4' already exists. Overwrite ? [y/N] y
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[swscaler # 0x7fb7e280b000] deprecated pixel format used, make sure you did set range correctly
[libx264 # 0x7fb7e1803c00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 # 0x7fb7e1803c00] profile High, level 5.0
[libx264 # 0x7fb7e1803c00] 264 - core 152 r2854 e9a5903 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=1 ref=16 deblock=1:0:0 analyse=0x3:0x133 me=umh subme=10 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=24 chroma_me=1 trellis=2 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=8 b_pyramid=2 b_adapt=2 b_bias=0 direct=3 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=60 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 'output12345.mp4':
Metadata:
encoder : Lavf58.20.100
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1280x720, q=-1--1, 25 fps, 12800 tbn, 25 tbc
Metadata:
encoder : Lavc58.35.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
[mp4 # 0x7fb7e1801800] Starting second pass: moving the moov atom to the beginning of the file
frame= 634 fps=8.5 q=-1.0 Lsize= 2252kB time=00:00:25.24 bitrate= 731.0kbits/s speed=0.337x
video:2245kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.307448%
[libx264 # 0x7fb7e1803c00] frame I:5 Avg QP:19.12 size: 49393
[libx264 # 0x7fb7e1803c00] frame P:131 Avg QP:22.18 size: 9379
[libx264 # 0x7fb7e1803c00] frame B:498 Avg QP:23.78 size: 1652
[libx264 # 0x7fb7e1803c00] consecutive B-frames: 3.2% 1.6% 3.3% 29.7% 7.9% 16.1% 7.7% 16.4% 14.2%
[libx264 # 0x7fb7e1803c00] mb I I16..4: 45.7% 37.9% 16.4%
[libx264 # 0x7fb7e1803c00] mb P I16..4: 6.0% 5.3% 1.3% P16..4: 19.9% 1.9% 3.7% 0.3% 0.1% skip:61.5%
[libx264 # 0x7fb7e1803c00] mb B I16..4: 0.3% 0.4% 0.1% B16..8: 17.5% 1.0% 0.2% direct: 0.3% skip:80.2% L0:52.3% L1:46.9% BI: 0.8%
[libx264 # 0x7fb7e1803c00] 8x8 transform intra:43.0% inter:48.9%
[libx264 # 0x7fb7e1803c00] direct mvs spatial:99.2% temporal:0.8%
[libx264 # 0x7fb7e1803c00] coded y,uvDC,uvAC intra: 16.9% 25.8% 16.6% inter: 1.1% 1.9% 1.2%
[libx264 # 0x7fb7e1803c00] i16 v,h,dc,p: 61% 28% 6% 6%
[libx264 # 0x7fb7e1803c00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 20% 9% 50% 3% 4% 3% 3% 3% 5%
[libx264 # 0x7fb7e1803c00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 18% 23% 19% 5% 7% 6% 6% 5% 10%
[libx264 # 0x7fb7e1803c00] i8c dc,h,v,p: 46% 40% 13% 1%
[libx264 # 0x7fb7e1803c00] Weighted P-Frames: Y:5.3% UV:5.3%
[libx264 # 0x7fb7e1803c00] ref P L0: 33.2% 3.1% 11.6% 7.3% 8.8% 6.4% 6.5% 3.1% 3.2% 2.6% 2.4% 2.5% 2.8% 2.8% 2.3% 1.4%
[libx264 # 0x7fb7e1803c00] ref B L0: 42.0% 15.1% 12.0% 5.4% 4.9% 4.3% 4.0% 1.9% 2.0% 1.8% 1.7% 1.8% 1.7% 1.1% 0.5%
[libx264 # 0x7fb7e1803c00] ref B L1: 83.5% 16.5%
[libx264 # 0x7fb7e1803c00] kb/s:725.10
Player:
QuickTime, VLC and Kodi on both Linux and Mac.
EDIT 2:
Input files: https://drive.google.com/open?id=1kbBkSDSwe6ywgQ8lkjqkh-MKCzGA4bj8
I think you need to delete the first line and add quote marks in your text file:
file 'slide_0001.jpg'
duration 0.163
file 'slide_0002.jpg'
duration 0.533
file 'slide_0003.jpg'
duration 1.067
file 'slide_0004.jpg'
duration 0.533
file 'slide_0005.jpg'
etc.
The command should be:
ffmpeg -f concat -i png.txt -vf fps=25 output.mp4
I've tested this and it works.
This was bug #7625. It was fixed on 2018-12-18:
lavc/mjpegdec: Interpret three-component Adobe transform 0 also as RGB
Download a recent build from the git master branch and the fix will be included. For old versions a workaround proposed by Gyan in the bug report comments is to use a filter: mergeplanes=0x010200:format=gbrp.
After spending almost half a day on this, I have managed to find a (not so pretty) solution to my problem:
Step 1
cd to folder with slides.
Convert images from .jpg to .png using ImageMagick to prevent colour problems
mogrify -format png *.jpg
Step 2
Convert and put .png images into mp4 file using FFmpeg
ffmpeg -i slide_%04d.png -c:v libx264 -vf mergeplanes=0x010200:format=gbrp -pix_fmt yuv420p -preset veryslow output.mp4
Step 3
Using mp4fpsmod, alter the timecode of the newly created file
mp4fpsmod -t timecode.txt output.mp4 -o timedoutput.mp4
Example of timecode.txt
# timecode format v2
163
696
1763
2296
2829
3363
The resulting file has a size of around 5 MB, whereas the original .jpg files have a size of 122 MB, which is great.
Remaining problems
The file plays well in QuickTime, but unfortunately not in VLC.
I will create a new question for this, because I need VLC to play this file together with an mp4 video and be able to scroll through the videos simultaneously.
However, if you read this and know the answer, please do not hesitate to comment here.
EDIT: Incorporated changes as suggested by user llogan solving the colour issues.
Related
I am trying to download a livestream from this traffic camera source: https://vss1live.dot.ga.gov/lo/alph-cam-002.stream/playlist.m3u8
The ffmpeg I am using is:
ffmpeg -i https://vss1live.dot.ga.gov/lo/alph-cam-002.stream/playlist.m3u8 -preset slow -codec:a libfdk_aac -b:a 128k -codec:v libx264 -pix_fmt yuv420p -b:v 4500k -minrate 4500k -maxrate 9000k -bufsize 9000k -vf scale=-1:720 test.mp4
And here are the logs when I quit the recording:
ffmpeg version 5.0.1 Copyright (c) 2000-2022 the FFmpeg developers
built with Apple clang version 13.1.6 (clang-1316.0.21.2)
configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/5.0.1 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox --enable-neon
libavutil 57. 17.100 / 57. 17.100
libavcodec 59. 18.100 / 59. 18.100
libavformat 59. 16.100 / 59. 16.100
libavdevice 59. 4.100 / 59. 4.100
libavfilter 8. 24.100 / 8. 24.100
libswscale 6. 4.100 / 6. 4.100
libswresample 4. 3.100 / 4. 3.100
libpostproc 56. 3.100 / 56. 3.100
[hls # 0x1417050e0] Skip ('#EXT-X-VERSION:3')
[hls # 0x1417050e0] Opening 'https://vss1live.dot.ga.gov/lo/alph-cam-002.stream/chunklist_w259023283.m3u8' for reading
[hls # 0x1417050e0] Skip ('#EXT-X-VERSION:3')
[hls # 0x1417050e0] Skip ('#EXT-X-DISCONTINUITY-SEQUENCE:0')
[hls # 0x1417050e0] Opening 'https://vss1live.dot.ga.gov/lo/alph-cam-002.stream/media_w259023283_61526.ts' for reading
[hls # 0x1417050e0] Opening 'https://vss1live.dot.ga.gov/lo/alph-cam-002.stream/media_w259023283_61527.ts' for reading
Input #0, hls, from 'https://vss1live.dot.ga.gov/lo/alph-cam-002.stream/playlist.m3u8':
Duration: N/A, start: 65276.905822, bitrate: N/A
Program 0
Metadata:
variant_bitrate : 142637
Stream #0:0: Data: timed_id3 (ID3 / 0x20334449)
Metadata:
variant_bitrate : 142637
Stream #0:1: Video: h264 (Baseline) ([27][0][0][0] / 0x001B), yuvj420p(pc, bt709), 480x270 [SAR 1:1 DAR 16:9], 15 fps, 15 tbr, 90k tbn
Metadata:
variant_bitrate : 142637
Stream mapping:
Stream #0:1 -> #0:0 (h264 (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[swscaler # 0x120248000] [swscaler # 0x120258000] deprecated pixel format used, make sure you did set range correctly
[swscaler # 0x120248000] [swscaler # 0x120278000] deprecated pixel format used, make sure you did set range correctly
[swscaler # 0x120248000] [swscaler # 0x120288000] deprecated pixel format used, make sure you did set range correctly
[swscaler # 0x120248000] [swscaler # 0x120298000] deprecated pixel format used, make sure you did set range correctly
[swscaler # 0x120248000] [swscaler # 0x1202a8000] deprecated pixel format used, make sure you did set range correctly
[swscaler # 0x120248000] [swscaler # 0x1202b8000] deprecated pixel format used, make sure you did set range correctly
[swscaler # 0x120248000] [swscaler # 0x1202c8000] deprecated pixel format used, make sure you did set range correctly
[swscaler # 0x120248000] [swscaler # 0x1202d8000] deprecated pixel format used, make sure you did set range correctly
[swscaler # 0x120248000] [swscaler # 0x1202e8000] deprecated pixel format used, make sure you did set range correctly
[swscaler # 0x120248000] [swscaler # 0x1202f8000] deprecated pixel format used, make sure you did set range correctly
[swscaler # 0x120248000] [swscaler # 0x120308000] deprecated pixel format used, make sure you did set range correctly
[libx264 # 0x14169ff30] using SAR=1/1
[libx264 # 0x14169ff30] using cpu capabilities: ARMv8 NEON
[libx264 # 0x14169ff30] profile High, level 3.1, 4:2:0, 8-bit
[libx264 # 0x14169ff30] 264 - core 163 r3060 5db6aa6 - H.264/MPEG-4 AVC codec - Copyleft 2003-2021 - http://www.videolan.org/x264.html - options: cabac=1 ref=5 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=8 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=2 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=15 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=3 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=15 scenecut=40 intra_refresh=0 rc_lookahead=50 rc=abr mbtree=1 bitrate=4500 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=9000 vbv_bufsize=9000 nal_hrd=none filler=0 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'test.mp4':
Metadata:
encoder : Lavf59.16.100
Stream #0:0: Video: h264 (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 4500 kb/s, 15 fps, 15360 tbn
Metadata:
variant_bitrate : 142637
encoder : Lavc59.18.100 libx264
Side data:
cpb: bitrate max/min/avg: 9000000/0/4500000 buffer size: 9000000 vbv_delay: N/A
[https # 0x13201ce00] Opening 'https://vss1live.dot.ga.gov/lo/alph-cam-002.stream/media_w259023283_61528.ts' for reading
[https # 0x131814200] Opening 'https://vss1live.dot.ga.gov/lo/alph-cam-002.stream/chunklist_w259023283.m3u8' for reading
[hls # 0x1417050e0] Skip ('#EXT-X-VERSION:3')
[hls # 0x1417050e0] Skip ('#EXT-X-DISCONTINUITY-SEQUENCE:0')
[https # 0x131814200] Opening 'https://vss1live.dot.ga.gov/lo/alph-cam-002.stream/chunklist_w259023283.m3u8' for reading
[hls # 0x1417050e0] Skip ('#EXT-X-VERSION:3')
[hls # 0x1417050e0] Skip ('#EXT-X-DISCONTINUITY-SEQUENCE:0')
[https # 0x13201ce00] Opening 'https://vss1live.dot.ga.gov/lo/alph-cam-002.stream/media_w259023283_61529.ts' for reading
[tls # 0x131606060] Error in the pull function.
[tls # 0x131606060] IO error: End of file
[hls # 0x1417050e0] Opening 'https://vss1live.dot.ga.gov/lo/alph-cam-002.stream/media_w259023283_61529.ts' for reading
^Cav_interleaved_write_frame(): Immediate exit requested93 bitrate=4697.0kbits/s speed=1.77x
Error writing trailer of test.mp4: Immediate exit requested
frame= 610 fps= 23 q=4.0 Lsize= 20224kB time=00:00:36.13 bitrate=4585.1kbits/s speed=1.35x
video:20500kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Error closing file test.mp4: Immediate exit requested
[libx264 # 0x14169ff30] frame I:3 Avg QP: 2.13 size:192240
[libx264 # 0x14169ff30] frame P:156 Avg QP: 0.44 size: 66488
[libx264 # 0x14169ff30] frame B:451 Avg QP: 1.32 size: 28629
[libx264 # 0x14169ff30] consecutive B-frames: 1.1% 0.3% 1.5% 97.0%
[libx264 # 0x14169ff30] mb I I16..4: 21.7% 26.6% 51.7%
[libx264 # 0x14169ff30] mb P I16..4: 2.9% 3.1% 11.0% P16..4: 9.3% 4.1% 3.4% 0.0% 0.0% skip:66.1%
[libx264 # 0x14169ff30] mb B I16..4: 0.1% 0.4% 1.6% B16..8: 14.6% 4.0% 2.1% direct: 3.2% skip:73.9% L0:53.1% L1:41.6% BI: 5.3%
[libx264 # 0x14169ff30] final ratefactor: -0.00
[libx264 # 0x14169ff30] 8x8 transform intra:19.0% inter:11.1%
[libx264 # 0x14169ff30] direct mvs spatial:98.2% temporal:1.8%
[libx264 # 0x14169ff30] coded y,uvDC,uvAC intra: 91.5% 77.2% 76.6% inter: 11.8% 12.2% 11.9%
[libx264 # 0x14169ff30] i16 v,h,dc,p: 17% 54% 10% 19%
[libx264 # 0x14169ff30] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 16% 42% 15% 3% 5% 3% 7% 3% 6%
[libx264 # 0x14169ff30] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 16% 32% 13% 5% 9% 5% 9% 4% 7%
[libx264 # 0x14169ff30] i8c dc,h,v,p: 38% 44% 13% 5%
[libx264 # 0x14169ff30] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 # 0x14169ff30] ref P L0: 83.7% 3.3% 8.8% 2.4% 1.8% 0.0%
[libx264 # 0x14169ff30] ref B L0: 79.9% 19.0% 0.8% 0.3%
[libx264 # 0x14169ff30] ref B L1: 99.0% 1.0%
[libx264 # 0x14169ff30] kb/s:4693.84
Exiting normally, received signal 2.
Except the video doesn't seem to be playable by VLC or Quicktime. Given that the stream can end at any moment thus ending the file, how do I make the file actually playable?
the Goal:
I am trying to record a specific X display on a remote server with a command line tool.
the Problem:
The output file contains a pure black video stream for the whole duration of the recording.
My Approach:
I am connecting to a remote server via x2go. The Server runs Ubuntu 16.04.2 with Xfce Desktop Environment. The Display I try to record is :50 (which gets created when I connect to the x2go server). I can control the remote server totally fine through x2go.
My commands for recording via ffmpeg (or avconv/recordmydesktop, which use ffmpeg underneath) all look more or less the same and are like this:
ffmpeg -f x11grab -r 25 -s 1854x1176 -i :50.0 -c:v libx264 screencast.mkv
Sample output:
user#machine:~/$ ffmpeg -f x11grab -r 25 -s 1854x1176 -i :50.0+0,0 -c:v libx264 -vb 4000k -an screencast.mkv
ffmpeg version N-86766-g264f6c6 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609
configuration: --prefix=/home/user/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/user/ffmpeg_build/include --extra-ldflags=-L/home/user/ffmpeg_build/lib --bindir=/home/user/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree
libavutil 55. 67.100 / 55. 67.100
libavcodec 57.100.104 / 57.100.104
libavformat 57. 75.100 / 57. 75.100
libavdevice 57. 7.100 / 57. 7.100
libavfilter 6. 95.100 / 6. 95.100
libswscale 4. 7.101 / 4. 7.101
libswresample 2. 8.100 / 2. 8.100
libpostproc 54. 6.100 / 54. 6.100
[x11grab # 0x1fd9b40] XFixes not available, cannot draw the mouse.
[x11grab # 0x1fd9b40] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, x11grab, from ':50.0+0,0':
Duration: N/A, start: 1500041497.684675, bitrate: N/A
Stream #0:0: Video: rawvideo (BGR[0] / 0x524742), bgr0, 1854x1176, 25 fps, 1000k tbr, 1000k tbn, 1000k tbc
File 'screencast.mkv' already exists. Overwrite ? [y/N] y
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 # 0x1fe3040] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 # 0x1fe3040] profile High 4:4:4 Predictive, level 4.2, 4:4:4 8-bit
[libx264 # 0x1fe3040] 264 - core 148 r2643 5c65704 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - 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=12 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=4000 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, matroska, to 'screencast.mkv':
Metadata:
encoder : Lavf57.75.100
Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuv444p, 1854x1176, q=-1--1, 4000 kb/s, 25 fps, 1k tbn, 25 tbc
Metadata:
encoder : Lavc57.100.104 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/4000000 buffer size: 0 vbv_delay: -1
[swscaler # 0x1fe94e0] Warning: data is not aligned! This can lead to a speedloss
frame= 179 fps= 36 q=-1.0 Lsize= 16kB time=00:00:07.04 bitrate= 18.8kbits/s speed=1.43x
video:14kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 12.869934%
[libx264 # 0x1fe3040] frame I:1 Avg QP: 6.00 size: 518
[libx264 # 0x1fe3040] frame P:45 Avg QP: 0.44 size: 81
[libx264 # 0x1fe3040] frame B:133 Avg QP: 0.94 size: 73
[libx264 # 0x1fe3040] consecutive B-frames: 0.6% 1.1% 0.0% 98.3%
[libx264 # 0x1fe3040] mb I I16..4: 0.0% 100.0% 0.0%
[libx264 # 0x1fe3040] mb P I16..4: 0.0% 0.0% 0.0% P16..4: 0.0% 0.0% 0.0% 0.0% 0.0% skip:100.0%
[libx264 # 0x1fe3040] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 0.0% 0.0% 0.0% direct: 0.0% skip:100.0%
[libx264 # 0x1fe3040] final ratefactor: -23.85
[libx264 # 0x1fe3040] 8x8 transform intra:100.0%
[libx264 # 0x1fe3040] coded y,u,v intra: 0.0% 0.0% 0.0% inter: 0.0% 0.0% 0.0%
[libx264 # 0x1fe3040] i16 v,h,dc,p: 0% 0% 100% 0%
[libx264 # 0x1fe3040] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 0% 0% 100% 0% 0% 0% 0% 0% 0%
[libx264 # 0x1fe3040] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 # 0x1fe3040] kb/s:15.56
Using: Ubuntu 16.04.2 LTS
I have successfully accomplished to capture the display :50 with "simplescreenrecorder", but that tool has no command line interface. It uses ffmpeg also, so it somehow should be possible to caputure the display but I can´t get it to work properly.
Issue is resolved.
I simply swapped x2go for a combination of xvfb and x11vnc and everything is working just fine. Below is the approach, which is working perfectly fine for me. Hope it´s helpful, otherwise I could provide additional info.
user#machine:~/$ Xvfb :50 -screen 0 2560x1440x24 -ac +extension GLX +extension RANDR +render -noreset &> /dev/null &
user#machine:~/$ export DISPLAY=:50
user#machine:~/$ startxfce4 &> /dev/null &
user#machine:~/$ x11vnc -display :50 --forever -noxdamage -nopw -rfbport 5900 -scale 1920x1080 &"
and connect to the vnc server with xvnc4viewer (example below/can be seen in x11vnc startup log)
user#machine:~/$ xvnc4viewer -viewonly -FullScreen hostname:0
I think I've managed to find the cause. I need to setup a similar system and using a software other than x2go is not an option. Anyway to those searching for a possible solution pay attention to the following message:
[x11grab # 0x1fd9b40] XFixes not available, cannot draw the mouse.
The xfixes extension is required by FFmpeg to record the screen through the xcblib and aparently, xfixes is disabled by default on recent x2goserver versions due to a bug. You can enable it editing the x2goagent.options file (normally /etc/x2go/x2goagent.options) and removing the following parameter:
# Disable XFIXES.
# Workaround for https://bugs.launchpad.net/ubuntu/+source/libxfixes/+bug/985202
#
X2GO_NXAGENT_DEFAULT_OPTIONS+=" -extension XFIXES"
You can leave it as
X2GO_NXAGENT_DEFAULT_OPTIONS+=""
As for the bug itself I have no idea if it will bite me. If its not a KDE machine then I think it should be ok.
I am trying to create a video out of one image and copy audio on top. Following this (last section), I tried:
$ ffmpeg -loop 1 -i img.jpg -i audio.mp3 -c:v libx264 -c:a copy -shortest h264.mp4
ffmpeg version 2.5.2 Copyright (c) 2000-2014 the FFmpeg developers
built on Feb 23 2015 10:29:52 with Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/2.5.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libmp3lame --enable-libxvid --enable-libfreetype --enable-libtheora --enable-libvorbis --enable-libvpx --enable-librtmp --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-aacenc --enable-libass --enable-ffplay --enable-libspeex --enable-libschroedinger --enable-libfdk-aac --enable-libopus --enable-frei0r --enable-libopenjpeg --disable-decoder=jpeg2000 --extra-cflags='-I/usr/local/Cellar/openjpeg/1.5.1_1/include/openjpeg-1.5 ' --enable-nonfree --enable-vda
libavutil 54. 15.100 / 54. 15.100
libavcodec 56. 13.100 / 56. 13.100
libavformat 56. 15.102 / 56. 15.102
libavdevice 56. 3.100 / 56. 3.100
libavfilter 5. 2.103 / 5. 2.103
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
Input #0, image2, from 'img.jpg':
Duration: 00:00:00.04, start: 0.000000, bitrate: 123986 kb/s
Stream #0:0: Video: mjpeg, yuvj440p(pc, bt470bg/unknown/unknown), 1440x900 [SAR 72:72 DAR 8:5], 25 fps, 25 tbr, 25 tbn, 25 tbc
[mp3 # 0x7f94d2034600] Estimating duration from bitrate, this may be inaccurate
Input #1, mp3, from 'audio.mp3':
Metadata:
genre : Other
Duration: 00:00:03.25, start: 0.000000, bitrate: 130 kb/s
Stream #1:0: Audio: mp3, 44100 Hz, mono, s16p, 128 kb/s
[swscaler # 0x7f94d2800000] deprecated pixel format used, make sure you did set range correctly
No pixel format specified, yuvj444p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
[libx264 # 0x7f94d281b200] using SAR=1/1
[libx264 # 0x7f94d281b200] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
[libx264 # 0x7f94d281b200] profile High 4:4:4 Predictive, level 4.0, 4:4:4 8-bit
[libx264 # 0x7f94d281b200] 264 - core 142 r2455 021c0dc - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - 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=25 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 'h264.mp4':
Metadata:
encoder : Lavf56.15.102
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuvj444p(pc), 1440x900 [SAR 1:1 DAR 8:5], q=-1--1, 25 fps, 12800 tbn, 25 tbc
Metadata:
encoder : Lavc56.13.100 libx264
Stream #0:1: Audio: mp3 (i[0][0][0] / 0x0069), 44100 Hz, mono, 128 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
Stream #1:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 64 fps= 30 q=28.0 size= 332kB time=00:00:00.48 bitrate=5670.9kbits/frame= 80 fps= 30 q=28.0 size= 344kB time=00:00:01.12 bitrate=2514.2kbits/frame= 96 fps= 30 q=28.0 size= 356kB time=00:00:01.76 bitrate=1655.1kbits/frame= 112 fps= 30 q=28.0 size= 367kB time=00:00:02.40 bitrate=1252.1kbits/frame= 129 fps= 31 q=28.0 size= 378kB time=00:00:03.08 bitrate=1006.5kbits/frame= 134 fps= 26 q=-1.0 Lsize= 386kB time=00:00:03.28 bitrate= 963.5kbits/s
video:331kB audio:51kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.120110%
[libx264 # 0x7f94d281b200] frame I:1 Avg QP:19.84 size:329471
[libx264 # 0x7f94d281b200] frame P:34 Avg QP:16.64 size: 189
[libx264 # 0x7f94d281b200] frame B:99 Avg QP:25.33 size: 48
[libx264 # 0x7f94d281b200] consecutive B-frames: 1.5% 0.0% 0.0% 98.5%
[libx264 # 0x7f94d281b200] mb I I16..4: 2.8% 70.0% 27.3%
[libx264 # 0x7f94d281b200] mb P I16..4: 0.0% 0.0% 0.0% P16..4: 1.2% 0.0% 0.0% 0.0% 0.0% skip:98.8%
[libx264 # 0x7f94d281b200] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 0.0% 0.0% 0.0% direct: 0.0% skip:100.0% L0: 1.6% L1:98.4% BI: 0.0%
[libx264 # 0x7f94d281b200] 8x8 transform intra:70.0% inter:95.0%
[libx264 # 0x7f94d281b200] coded y,u,v intra: 96.4% 73.8% 72.9% inter: 0.0% 0.0% 0.0%
[libx264 # 0x7f94d281b200] i16 v,h,dc,p: 37% 4% 1% 58%
[libx264 # 0x7f94d281b200] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 29% 27% 8% 3% 5% 5% 8% 4% 9%
[libx264 # 0x7f94d281b200] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 38% 18% 5% 3% 7% 7% 10% 5% 7%
[libx264 # 0x7f94d281b200] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 # 0x7f94d281b200] ref P L0: 20.0% 0.4% 42.4% 37.2%
[libx264 # 0x7f94d281b200] ref B L0: 0.0% 100.0%
[libx264 # 0x7f94d281b200] ref B L1: 90.9% 9.1%
[libx264 # 0x7f94d281b200] kb/s:508.50
But I get a video with no audio in QuickTime. I think its a problem of the output container (mp4) not supporting mp3. What output container might be best? Due to quality loss, I am reluctant to convert the mp3 to another format. If my audio is mp3, what might I change about this ffmpeg command?
The final destination is YouTube.
Because YouTube is the final location you can ignore the other players:
Most non-FFmpeg based players can't decode yuvj444p. If you want the video in these other players to work, then add -pix_fmt yuv420p as an output option as mentioned in the console output.
Some players have trouble decoding MP3 in MP4 such as QuickTime and WMP with certain audio rates. If you need it to work in these players you'll need to re-encode to AAC audio by changing -c:a copy to -c:a aac.
Since the input is a single image you can reduce your frame rate for a much faster encoding by adding -framerate 1 as an input option. Again, some players may not be able to decode this frame rate.
YouTube can handle these potential issues, so feel free to upload it. See FFmpeg Wiki: YouTube for more info.
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.
I was playing with ffmpeg and was able to save a live stream to a file. The command to do so is:
ffmpeg -re -i "rtmp://<ip addr>/livestream live=1" -f h264 test.flv
However, I have tested this twice, and both times ffmpeg stops after grabbing 3:28 worth of live video.
The entire output is here:
bash-4.2$ ffmpeg -re -i "rtmp://<ip addr>/livestream live=1" -vcodec libx264 -f h264 test.flv
WARNING: gnome-keyring:: couldn't connect to: /home/me/.cache/keyring-bpajcJ/pkcs11: No such file or directory
ffmpeg version 0.10.4 Copyright (c) 2000-2012 the FFmpeg developers
built on Jul 20 2012 22:01:52 with gcc 4.7.0 20120507 (Red Hat 4.7.0-5)
configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib --mandir=/usr/share/man --arch=i686 --extra-cflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables' --enable-bzlib --disable-crystalhd --enable-gnutls --enable-libass --enable-libcdio --enable-libcelt --enable-libdc1394 --disable-indev=jack --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-openal --enable-libopenjpeg --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvpx --enable-libx264 --enable-libxvid --enable-x11grab --enable-avfilter --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib --cpu=i686 --enable-runtime-cpudetect
libavutil 51. 35.100 / 51. 35.100
libavcodec 53. 61.100 / 53. 61.100
libavformat 53. 32.100 / 53. 32.100
libavdevice 53. 4.100 / 53. 4.100
libavfilter 2. 61.100 / 2. 61.100
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 6.100 / 0. 6.100
libpostproc 52. 0.100 / 52. 0.100
WARNING: gnome-keyring:: couldn't connect to: /home/me/.cache/keyring-bpajcJ/pkcs11: No such file or directory
Metadata:
videocodecid avc1
width 320.00
height 240.00
frameWidth 320.00
frameHeight 240.00
displayWidth 320.00
displayHeight 240.00
framerate 29.97
trackinfo:
timescale 90000.00
language eng
sampledescription:
sampletype H264
type video
profile-level-id 42e00c
sprop-parameter-sets Z0LgDNoFB+wEQAAC7sAAr8gh,aM4zyA==
description {H264CodecConfigInfo: profile: "Baseline", level: 1.2, frameSize: 320x240, displaySize: 320x240, PAR: 1:1, frameRate: 29.97}
rtpsessioninfo:
name H264 Stream 1
origin - 1486490083 118668671 IN IP4 10.93.183.3
timing 0 0
protocolversion 0
attributes:
range npt=now-
[flv # 0x9578ee0] Estimating duration from bitrate, this may be inaccurate
Input #0, flv, from 'rtmp://<ip addr>/livestream live=1':
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: h264 (Constrained Baseline), yuv420p, 320x240 [SAR 1:1 DAR 4:3], 14.99 tbr, 1k tbn, 59.94 tbc
[buffer # 0x99ee900] w:320 h:240 pixfmt:yuv420p tb:1/1000000 sar:1/1 sws_param:
[libx264 # 0x9584540] using SAR=1/1
[libx264 # 0x9584540] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2
[libx264 # 0x9584540] profile High, level 1.2
Output #0, h264, to 'test.flv':
Metadata:
encoder : Lavf53.32.100
Stream #0:0: Video: h264, yuv420p, 320x240 [SAR 1:1 DAR 4:3], q=-1--1, 90k tbn, 14.99 tbc
Stream mapping:
Stream #0:0 -> #0:0 (h264 -> libx264)
Press [q] to stop, [?] for help
RTMP_ReadPacket, failed to read RTMP packet body. len: 16582bitrate= 212.1kbits/s
frame= 3111 fps= 15 q=-2.0 Lsize= 5385kB time=00:03:27.47 bitrate= 212.6kbits/s
video:5385kB audio:0kB global headers:0kB muxing overhead 0.000000%
[libx264 # 0x9584540] frame I:13 Avg QP:18.70 size: 31866
[libx264 # 0x9584540] frame P:1908 Avg QP:22.29 size: 2392
[libx264 # 0x9584540] frame B:1190 Avg QP:29.24 size: 451
[libx264 # 0x9584540] consecutive B-frames: 39.5% 24.0% 13.0% 23.4%
[libx264 # 0x9584540] mb I I16..4: 0.2% 1.2% 98.6%
[libx264 # 0x9584540] mb P I16..4: 0.0% 0.0% 0.7% P16..4: 22.0% 3.5% 2.6% 0.0% 0.0% skip:71.2%
[libx264 # 0x9584540] mb B I16..4: 0.0% 0.0% 0.2% B16..8: 15.6% 2.8% 1.1% direct: 1.3% skip:78.9% L0:47.0% L1:42.2% BI:10.8%
[libx264 # 0x9584540] 8x8 transform intra:2.2% inter:8.5%
[libx264 # 0x9584540] coded y,uvDC,uvAC intra: 98.0% 94.9% 73.9% inter: 14.5% 16.0% 11.3%
[libx264 # 0x9584540] i16 v,h,dc,p: 0% 50% 17% 33%
[libx264 # 0x9584540] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 7% 21% 11% 3% 13% 6% 21% 4% 14%
[libx264 # 0x9584540] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 11% 21% 14% 5% 11% 7% 14% 5% 12%
[libx264 # 0x9584540] i8c dc,h,v,p: 65% 15% 10% 10%
[libx264 # 0x9584540] Weighted P-Frames: Y:0.5% UV:0.1%
[libx264 # 0x9584540] ref P L0: 80.8% 10.4% 7.6% 1.2% 0.0%
[libx264 # 0x9584540] ref B L0: 94.9% 4.8% 0.2%
[libx264 # 0x9584540] ref B L1: 96.4% 3.6%
[libx264 # 0x9584540] kb/s:212.48
Although I don't see any errors. It just looks like ffmpeg thought the stream had ended? But that's not possible since it's a live stream.
This is most likely related to swf verification being performed on the server side (see 'swfVfy' flag). You could try something as follows and see if the stream gets further.
ffmpeg -i "rtmp:///livestream live=1 swfVfy=1 swfUrl=url_to_the flash_player_here" -y test.flv
Unfortunately though, in my case I could not get ffmpeg's swfVfy to work, and have exapmles of the same streams working fine with rtmpdump.