In Ubuntu 12.04 LTS I have used -movflags frag_keyframe+empty_moov in my ffmpeg command:
ffmpeg -i http://filesbe.vocativ.internal.net/03/44/SN/q1/xg/xl/0344SNq1xgxl.flv \
-crf 32.0 -g 250 -keyint_min 25 -aspect 4:3 -movflags frag_keyframe -vcodec \
libx264 -acodec aac -strict experimental -ar 44100 -ac 2 -b:a 128k -map 0:0 \
-map 0:1 -f flv -y test.flv
ffmpeg version 0.8.6-4:0.8.6-0ubuntu0.12.04.1, Copyright (c) 2000-2013 the Libav developers
built on Apr 2 2013 17:02:36 with gcc 4.6.3
*** THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
[flv # 0x10569a0] Estimating duration from bitrate, this may be inaccurate
Input #0, flv, from 'http://filesbe.vocativ.internal.net/03/44/SN/q1/xg/xl/0344SNq1xgxl.flv':
Metadata:
starttime : 0
totalduration : 64
totaldatarate : 710
bytelength : 5674798
canseekontime : true
sourcedata : BADC23401MH1326550770698632
purl :
pmsg :
Duration: 00:01:03.96, start: 0.000000, bitrate: 718 kb/s
Stream #0.0: Video: h264 (Main), yuv420p, 854x480, 590 kb/s, 25 tbr, 1k tbn, 50 tbc
Stream #0.1: Audio: aac, 44100 Hz, stereo, s16, 128 kb/s
[buffer # 0x105c600] w:854 h:480 pixfmt:yuv420p
[movie # 0x105c440] seek_point:0 format_name:(null) file_name:/home/assetproxy/htdocs/transcoder/helper_asset/voca_scaled.png stream_index:0
[overlay # 0x1060840] auto-inserting filter 'auto-inserted scaler 0' between the filter 'Parsed filter 0 movie' and the filter 'Parsed filter 1 overlay'
[scale # 0x11d8300] w:90 h:51 fmt:rgb24 -> w:90 h:51 fmt:yuva420p flags:0x4
[overlay # 0x1060840] main w:854 h:480 fmt:yuv420p overlay x:754 y:419 w:90 h:51 fmt:yuva420p
[overlay # 0x1060840] main_tb:1/1000000 overlay_tb:1/25 -> tb:1/1000000 exact:1
[libx264 # 0x1059d20] using SAR=191/255
[libx264 # 0x1059d20] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2
[libx264 # 0x1059d20] profile Main, level 3.0
[libx264 # 0x1059d20] 264 - core 120 r2151 a3f4407 - H.264/MPEG-4 AVC codec - Copyleft 2003-2011 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=6 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=0 b_adapt=1 b_bias=0 direct=1 weightb=0 open_gop=1 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=32.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.41 aq=1:1.00
Option movflags not found.
First of all you're not actually using ffmpeg from FFmpeg, but an old and outdated version from a fork which does not have the -movflags option. You will need to update your ffmpeg: you can simply download a Linux build of ffmpeg (see detailed instructions), or you can follow a step-by-step guide to compile ffmpeg on Ubuntu.
Also see:
Who can tell me the difference and relation between ffmpeg, libav, and avconv?
FFmpeg and x264 Encoding Guide
FFmpeg and AAC Encoding Guide
Related
I use release: 4.2.2 (static) from "https://johnvansickle.com/ffmpeg/"
Final code will be on "Amazon AWS lambda"
Goal: use a url stream and add watermak
Link to video: https://feoval.fr/519.mp4
Link to Watermak: https://feoval.fr/watermark.png
./ffmpeg -i "https://feoval.fr/519.mp4" -i "./watermark.png" -filter_complex "overlay=W-w-10:H-h-10:format=rgb" -f "mp4" -movflags "frag_keyframe+empty_moov" -pix_fmt "yuv420p" test.mp4
return "Segmentation fault"
I have the same error on my computer and on AWS Lambda server
./ffmpeg -i "https://feoval.fr/519.mp4" -f "mp4" -movflags "frag_keyframe+empty_moov" -pix_fmt "yuv420p" test.mp4
work (but not watermak)
./ffmpeg -i "./519.mp4" -i "./watermark.png" -filter_complex "overlay=W-w-10:H-h-10:format=rgb" -f "mp4" -movflags "frag_keyframe+empty_moov" -pix_fmt "yuv420p" test.mp4
work (but not with stream)
Thanks you very much !
Logs for the first case who return "Segmentation fault":
...
Stream mapping:
Stream #0:0 (h264) -> overlay:main (graph 0)
Stream #1:0 (png) -> overlay:overlay (graph 0)
overlay (graph 0) -> Stream #0:0 (libx264)
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, ? for help
[libx264 # 0x742e480] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 # 0x742e480] profile High, level 3.1, 4:2:0, 8-bit
[libx264 # 0x742e480] 264 - core 159 r2991 1771b55 - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 - 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=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=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:
major_brand : mp42
minor_version : 1
compatible_brands: isommp41mp42
encoder : Lavf58.29.100
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 480x848, q=-1--1, 30 fps, 15360 tbn, 30 tbc (default)
Metadata:
encoder : Lavc58.54.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
creation_time : 2020-01-13T08:54:26.000000Z
handler_name : Core Media Audio
encoder : Lavc58.54.100 aac
Segmentation fault (core dumped)
According to readme.txt that is packaged with the build from johnvansickle.com:
A limitation of statically linking glibc is the loss of DNS
resolution. Installing nscd through your package manager will fix
this.
Solution is to install and start the nscd service.
Alternative solutions:
Compile (see tutorials) your own ffmpeg (during ./configure enable gnutls, openssl, libtls or mbedtls for HTTPS support).
Use ffmpeg from your repository
Download the input file before using it in ffmpeg
Use IP address instead of domain name
I want to merge two images (names are not numbered in a sequence) to a video, but the result includes only a video of the first image.
I would appreciate any kind of help!
ffmpeg.exe -r 1/5 -i image_x.png -r 1/5 -i image_y.png -codec:v libx264 -vf fps=50 video.mp4
Output:
Input #0, png_pipe, from
'C:\Users\khj\Desktop\SpeakerLayoutTool\Images_video\iamge_x.png':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: png, rgba(pc), 3840x2160, 25 tbr, 25 tbn, 25 tbc Input #1, png_pipe, from
'C:\Users\khj\Desktop\SpeakerLayoutTool\Images_video\image_y.png':
Duration: N/A, bitrate: N/A
Stream #1:0: Video: png, rgba(pc), 3840x2160, 25 tbr, 25 tbn, 25 tbc File 'C:\Users\khj\Desktop\SpeakerLayoutTool\video.mp4' already
exists. Overwrite ? [y/N] y Stream mapping: Stream #0:0 -> #0:0 (png
(native) -> h264 (libx264)) Press [q] to stop, [?] for help [libx264 #
0000016c2a46e000] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
AVX FMA3 BMI2 AVX2 [libx264 # 0000016c2a46e000] profile High 4:4:4
Predictive, level 5.2, 4:4:4, 8-bit [libx264 # 0000016c2a46e000] 264 -
core 157 r2970 5493be8 - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 -
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=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
'C:\Users\khj\Desktop\SpeakerLayoutTool\video.mp4': Metadata:
encoder : Lavf58.27.103
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv444p, 3840x2160, q=-1--1, 50 fps, 12800 tbn, 50 tbc
Metadata:
encoder : Lavc58.52.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1 frame= 250 fps= 22 q=-1.0 Lsize= 162kB time=00:00:04.94 bitrate=
268.1kbits/s speed=0.444x
Use
ffmpeg.exe -loop 1 -t 5 -i image_x.png -loop 1 -t 5 -i image_y.png -filter_complex "concat=n=2:v=1:a=0" -pix_fmt yuv420p -c:v libx264 video.mp4
My goal is to compress video making it's bitrate lower.
For experiment I used following command
ffmpeg -ss 00:00:00 -i V.mkv -to 00:10:00 -c:a copy -b:v 7500k -maxrate 7500k -minrate 5500k -bufsize 1M V7500.mkv
1. What are possible reasons speed of conversion was close to 1.0x utilizing all 8 cores?
2. Bitrate of output video stream is about 4700 (5500 was set as minrate). Is there proper way to specify bitrate?
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[libx264 # 0x55e54ad189a0] using SAR=1/1
[libx264 # 0x55e54ad189a0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 # 0x55e54ad189a0] profile High, level 4.0
[libx264 # 0x55e54ad189a0] 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=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=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=23 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=cbr mbtree=1 bitrate=7500 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=7500 vbv_bufsize=1000 nal_hrd=none filler=0 ip_ratio=1.40 aq=1:1.00
Output #0, matroska, to 'V7500.mkv':
Metadata:
title : Valerian.and.the.City.of.a.Thousand.Planets.2017.1080p.BluRay.x264.DTS-HD.MA.7.1-FGT
encoder : Lavf57.83.100
Chapter #0:0: start 0.000000, end 600.000000
Metadata:
title : Chapter 01
Stream #0:0(eng): Video: h264 (libx264) (H264 / 0x34363248), yuv420p, 1920x804 [SAR 1:1 DAR 160:67], q=-1--1, 7500 kb/s, 23.98 fps, 1k tbn, 23.98 tbc (default)
Metadata:
title : Valerian.and.the.City.of.a.Thousand.Planets.2017.1080p.BluRay.x264.DTS-HD.MA.7.1-FGT
DURATION : 02:17:03.277000000
encoder : Lavc57.107.100 libx264
Side data:
cpb: bitrate max/min/avg: 7500000/0/7500000 buffer size: 1000000 vbv_delay: -1
Stream #0:1(eng): Audio: aac (LC) ([255][0][0][0] / 0x00FF), 48000 Hz, stereo, fltp (default)
Metadata:
title : Valerian.and.the.City.of.a.Thousand.Planets.2017.1080p.BluRay.x264.DTS-HD.MA.7.1-FGT
ENCODER : Lavc57.107.100 aac
DURATION : 02:17:03.317000000
Past duration 0.994987 too large
frame=14385 fps= 31 q=-1.0 Lsize= 363641kB time=00:09:59.99 bitrate=4964.9kbits/s speed=1.28x
I am trying to convert a .mpg to .flv with ffmpeg. On other servers I got it working but here with the ffmpeg clone (avconv) it just does not do it.
Originally I was working with libfaac and preset fastfirstpass but thats not available in this build so I switched to the experimental acc and preset libx264-fast_firstpass:
$ /usr/bin/ffmpeg -i /data/upload/videos/original/150128_Test_731_9d5b83.mpg
-strict experimental -acodec aac -ab 128k -ar 44100 -vcodec libx264 -pass 1
-pre libx264-fast_firstpass -b 512k -s 360x204
-f flv /data/upload/videos/encoded/150129_Test_731_54f06a.flv
avconv version 9.16-6:9.16-0ubuntu0.14.04.1, Copyright (c) 2000-2014 the Libav developers
built on Aug 10 2014 18:16:02 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
[mpeg # 0xc87de0] max_analyze_duration reached
Guessed Channel Layout for Input Stream #0.1 : stereo
Input #0, mpeg, from '/data/upload/videos/original/150128_Test_731_9d5b83.mpg':
Duration: 00:01:00.12, start: 0.989978, bitrate: 4814 kb/s
Stream #0.0[0x1e0]: Video: mpeg2video (Main), yuv420p, 720x406 [PAR 406:405 DAR 16:9], 104857 kb/s, 23.98 fps, 23.98 tbr, 90k tbn, 47.95 tbc
Stream #0.1[0x1c0]: Audio: mp2, 48000 Hz, stereo, s16p, 224 kb/s
[libx264 # 0xc8b4c0] using SAR=136/135
[libx264 # 0xc8b4c0] MB rate (26910000) > level limit (2073600)
[libx264 # 0xc8b4c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
[libx264 # 0xc8b4c0] profile Main, level 5.2
[libx264 # 0xc8b4c0] 264 - core 142 r2389 956c8d8 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=1 deblock=1:0:0 analyse=0x1:0 me=dia subme=2 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=3 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=1 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=30 rc=abr mbtree=1 bitrate=512 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.25 aq=1:1.00
Option preset not found.
What does the error in the last line mean?
I already made sure the preset libx264-fast_firstpass.avpreset exists in /usr/share/avconv/ and if I change it to invalid ffmpeg complains with Preset invalid specified for stream 0:0, but could not be opened., so the preset is correct.
Google does provide two results for this error. This chatlog and it's pastebin about live streaming with the solution to add -f flv and some russian page. Nothing helped.
Any advice?
I had a look ìnto this preset file /usr/share/avconv/libx264-fast_firstpass and there I found this wrong "preset" option. I delete it and now it works.
I am using the command:
ffmpeg -i MovieTest.yuv -vcodec libx264 -b 1200kb -b_strategy 1 -coder 1 -qmin 10 -qmax 51 -sc_threshold 40 -flags +loop -cmp +chroma -me_range 16 -me_method hex -subq 5 -i_qfactor 0.71 -qcomp 0.6 -qdiff 4 -directpred 1 -flags2 +fastpskip -dts_delta_threshold 1 -acodec libfaac -ab 128kb output.mp4
for yuv to mp4 conversion.
Here MovieTest.yuv is my input file and output.mp4 is my output file.
And I am using h.264 codec (libx264) for conversion.
It converts my most of the yuv files properly.
But sometimes, the conversion fails with the error on terminal:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'MovieTest.yuv':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
Duration: 00:00:06.45, start: 0.000000, bitrate: 109786 kb/s
Stream #0.0(und): Video: rawvideo, uyvy422, 640x480, 109675 kb/s, 22.31 fps, 27.25 tbr, 30k tbn, 30k tbc
Stream #0.1(und): Audio: aac, stereo, s16, 106 kb/s
[libx264 # 0x12180da00]using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.1 Cache64
[libx264 # 0x12180da00]profile High, level 3.0
[libx264 # 0x12180da00]264 - core 98 - H.264/MPEG-4 AVC codec - Copyleft 2003-2010 - http://www.videolan.org/x264.html - options: cabac=1 ref=6 deblock=1:0:0 analyse=0x3:0x133 me=umh 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=0 weightp=0 keyint=12 keyint_min=7 scenecut=40 intra_refresh=0 rc_lookahead=12 rc=abr mbtree=1 bitrate=120 ratetol=33.3 qcomp=0.60 qpmin=10 qpmax=51 qpstep=4 ip_ratio=1.41 aq=1:1.00
[libfaac # 0x12180e000]libfaac doesn't support this output format!
Output #0, mp4, to 'output.mp4':
Stream #0.0(und): Video: libx264, yuv420p, 640x480, q=10-51, 120 kb/s, 90k tbn, 27.25 tbc
Stream #0.1(und): Audio: libfaac, stereo, s16, 128 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Error while opening encoder for output stream #0.1 - maybe incorrect parameters such as bit_rate, rate, width or height
If anybody has any idea, that what is going wrong, plz help.
I think it's because your output bit rate (128kb) is higher than your input bit rate (106 kb).
I've just done a quick test and when I put my output higher than my input mine fails with the same errors as yours - it succeeds when I lower it again.
This may explain why it only fails for some inputs.
If you're scripting this in some way you'll have to use either 'ffmpeg -i' or something like MediaInfo to analyse your input source first and adjust accordingly.