
Recherche avancée
Autres articles (69)
-
Personnaliser en ajoutant son logo, sa bannière ou son image de fond
5 septembre 2013, parCertains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;
-
Ecrire une actualité
21 juin 2013, parPrésentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
Vous pouvez personnaliser le formulaire de création d’une actualité.
Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...) -
Le profil des utilisateurs
12 avril 2011, parChaque utilisateur dispose d’une page de profil lui permettant de modifier ses informations personnelle. Dans le menu de haut de page par défaut, un élément de menu est automatiquement créé à l’initialisation de MediaSPIP, visible uniquement si le visiteur est identifié sur le site.
L’utilisateur a accès à la modification de profil depuis sa page auteur, un lien dans la navigation "Modifier votre profil" est (...)
Sur d’autres sites (6345)
-
FFmpeg make video from figures and speed up a chosen part
11 juin 2020, par user13720066Make a video from a series of 100 figures



ffmpeg -framerate 10 -i input_figure%01d.png out.mp4




How can I only make figure numbers from [0-49] with a slower speed like
-framerate 5
?


My try is



ffmpeg -start_number 1 -framerate 5 -i input_figure%01d.png -vframes 49 \
-start_number 50 -framerate 10 -i input_figure%01d.png \
out.mp4 




Doesn't work


-
ffmpeg video slides vertically after 'Invalid buffer size, packet size expected frame_size' error (vsync screen tearing glitch) ?
7 juillet 2020, par GlabbichRulzI have a video which i want to cut and crop using opencv and ffmpeg.




I want the output to be H265, so i am using a ffmpeg subprocess (writing frame bytes to stdin) as explained here. This is a minimum version of my code that leads to the error :


import os, shlex, subprocess, cv2, imutils

VIDEO_DIR = '../SoExample' # should contain a file 'in.mpg'
TIMESPAN = (3827, 3927) # cut to this timespan (frame numbers)
CROP = dict(min_x=560, max_x=731, min_y=232, max_y=418) # crop to this area

# calculate output video size
size = (CROP['max_x']-CROP['min_x'], CROP['max_y']-CROP['min_y']) # (w,h)
# ffmpeg throws an error when having odd dimensions that are not dividable by 2,
# so i just add a pixel to the size and stretch the original image by 1 pixel later.
size_rounded = (size[0]+1 if size[0] % 2 != 0 else size[0],
 size[1]+1 if size[1] % 2 != 0 else size[1])

# read input video
vid_path_in = os.path.join(VIDEO_DIR, 'in.mpg')
cap = cv2.VideoCapture(vid_path_in)
fps = int(cap.get(cv2.CAP_PROP_FPS))

# generate and run ffmpeg command
ffmpeg_cmd = (f'/usr/bin/ffmpeg -y -s {size_rounded[0]}x{size_rounded[1]} -pixel_format'
 + f' bgr24 -f rawvideo -r {fps} -re -i pipe: -vcodec libx265 -pix_fmt yuv420p'
 + f' -crf 24 -x265-params "ctu=64" "{os.path.join(VIDEO_DIR, "out.mp4")}"')
print("using cmd", ffmpeg_cmd)
process = subprocess.Popen(shlex.split(ffmpeg_cmd), stdin=subprocess.PIPE)

# seek to the beginning of the cutting timespan and loop through frames of input video
cap.set(cv2.CAP_PROP_POS_FRAMES, TIMESPAN[0])
frame_returned = True
while cap.isOpened() and frame_returned:
 frame_returned, frame = cap.read()
 frame_number = cap.get(cv2.CAP_PROP_POS_FRAMES) - 1

 # check if timespan end is not reached yet
 if frame_number < TIMESPAN[1]:

 # crop to relevant image area
 frame_cropped = frame[CROP['min_y']:CROP['max_y'],
 CROP['min_x']:CROP['max_x']]

 # resize to even frame size if needed:
 if size != size_rounded:
 frame_cropped = imutils.resize(frame_cropped, width=size_rounded[0],
 height=size_rounded[1])

 # Show processed image using opencv: I see no errors here.
 cv2.imshow('Frame', frame_cropped)

 # Write cropped video frame to input stream of ffmpeg sub-process.
 process.stdin.write(frame_cropped.tobytes())
 else:
 break

 # Press Q on keyboard to exit earlier
 if cv2.waitKey(25) & 0xFF == ord('q'):
 break

process.stdin.close() # Close and flush stdin
process.wait() # Wait for sub-process to finish
process.terminate() # Terminate the sub-process

print("Done!")



Unfortunately, my output looks like this :




The output should not include this vertical sliding glitch. Does anyone know how to fix it ?


My console output for aboves script shows :


using cmd /usr/bin/ffmpeg -y -s 172x186 -pixel_format bgr24 -f rawvideo -r 23 -i pipe: -vcodec libx265 -pix_fmt yuv420p -crf 24 -x265-params "ctu=64" "../SoExample/out.mp4"
ffmpeg version 3.4.6-0ubuntu0.18.04.1 Copyright (c) 2000-2019 the FFmpeg developers
 built with gcc 7 (Ubuntu 7.3.0-16ubuntu3)
 configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
 WARNING: library configuration mismatch
 avcodec configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared --enable-version3 --disable-doc --disable-programs --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libtesseract --enable-libvo_amrwbenc
 libavutil 55. 78.100 / 55. 78.100
 libavcodec 57.107.100 / 57.107.100
 libavformat 57. 83.100 / 57. 83.100
 libavdevice 57. 10.100 / 57. 10.100
 libavfilter 6.107.100 / 6.107.100
 libavresample 3. 7. 0 / 3. 7. 0
 libswscale 4. 8.100 / 4. 8.100
 libswresample 2. 9.100 / 2. 9.100
 libpostproc 54. 7.100 / 54. 7.100
Input #0, rawvideo, from 'pipe:':
 Duration: N/A, start: 0.000000, bitrate: 17659 kb/s
 Stream #0:0: Video: rawvideo (BGR[24] / 0x18524742), bgr24, 172x186, 17659 kb/s, 23 tbr, 23 tbn, 23 tbc
Stream mapping:
 Stream #0:0 -> #0:0 (rawvideo (native) -> hevc (libx265))
x265 [info]: HEVC encoder version 2.6
x265 [info]: build info [Linux][GCC 7.2.0][64 bit] 8bit+10bit+12bit
x265 [info]: using cpu capabilities: MMX2 SSE2Fast LZCNT SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
x265 [info]: Main profile, Level-2 (Main tier)
x265 [info]: Thread pool created using 4 threads
x265 [info]: Slices : 1
x265 [info]: frame threads / pool features : 2 / wpp(3 rows)
x265 [warning]: Source height < 720p; disabling lookahead-slices
x265 [info]: Coding QT: max CU size, min CU size : 64 / 8
x265 [info]: Residual QT: max TU size, max depth : 32 / 1 inter / 1 intra
x265 [info]: ME / range / subpel / merge : hex / 57 / 2 / 2
x265 [info]: Keyframe min / max / scenecut / bias: 23 / 250 / 40 / 5.00
x265 [info]: Lookahead / bframes / badapt : 20 / 4 / 2
x265 [info]: b-pyramid / weightp / weightb : 1 / 1 / 0
x265 [info]: References / ref-limit cu / depth : 3 / on / on
x265 [info]: AQ: mode / str / qg-size / cu-tree : 1 / 1.0 / 32 / 1
x265 [info]: Rate Control / qCompress : CRF-24.0 / 0.60
x265 [info]: tools: rd=3 psy-rd=2.00 rskip signhide tmvp strong-intra-smoothing
x265 [info]: tools: deblock sao
Output #0, mp4, to '../SoExample/out.mp4':
 Metadata:
 encoder : Lavf57.83.100
 Stream #0:0: Video: hevc (libx265) (hev1 / 0x31766568), yuv420p, 172x186, q=2-31, 23 fps, 11776 tbn, 23 tbc
 Metadata:
 encoder : Lavc57.107.100 libx265
[rawvideo @ 0x564ebd221aa0] Invalid buffer size, packet size 51600 < expected frame_size 95976 
Error while decoding stream #0:0: Invalid argument
frame= 100 fps= 30 q=-0.0 Lsize= 36kB time=00:00:04.21 bitrate= 69.1kbits/s speed=1.25x 
video:32kB audio:0kB subtitle:0kB other streams:0kB global headers:2kB muxing overhead: 12.141185%
x265 [info]: frame I: 1, Avg QP:22.44 kb/s: 179.77 
x265 [info]: frame P: 29, Avg QP:24.20 kb/s: 130.12 
x265 [info]: frame B: 70, Avg QP:29.99 kb/s: 27.82 
x265 [info]: Weighted P-Frames: Y:0.0% UV:0.0%
x265 [info]: consecutive B-frames: 20.0% 3.3% 16.7% 43.3% 16.7% 

encoded 100 frames in 3.35s (29.83 fps), 59.01 kb/s, Avg QP:28.23
Done!



As you can see, there is an error :
Invalid buffer size, packet size 51600 < expected frame_size 95976 Error while decoding stream #0:0: Invalid argument
, do you think this could be the cause to the shown problem ? I am not sure, as in the end, it tells me all 100 frames would have been encoded.

In case you want to reproduce this on the exact same video, you can find
actions1.mpg
in the UCF Aerial Action Dataset.

I would greatly appreciate any help as i am really stuck on this error.


-
ffmpeg : how to correctly program input framerate calculation, given desired video length duration and output framerate ?
19 septembre 2015, par user89Let us say that I have
n
pictures named asimgXY.png
(whereXY
represent the numbers0
ton-1
, properly padded with zeros).From these, I would like to create a video that is
t
seconds long, that has an (output) framerateR
.I want to figure out what the input framerate should be, so I do the following calculation :
-
time spent per frame :
t_per_frame = t/n
-
input framerate :
1/t_per_frame = n/t
However, when I then try to create a movie using the following command :
ffmpeg -framerate n/t -i img%02d.png -r 30 test_output.mp4
I don’t get a movie that is
t
seconds long, and only two of the frames end up getting displayed. Why is this the case ?The following questions were unhelpful :
How to successfully use ffmpeg to convert images into videos
Turning images into videos with ffmpeg
I think I am misunderstanding what is meant by input framerate, and what is meant by output framerate. Could you help clarify ? I am using a Python script to call ffmpeg, as documented here : http://zulko.github.io/blog/2013/09/27/read-and-write-video-frames-in-python-using-ffmpeg/
Here’s the output from the following manually executed command :
ffmpeg -framerate 24/5 -i img%02d.png -c:v libx264 -r 30 -pix_fmt yuv420p test_output.mp4
ffmpeg version N-75204-g314bc20 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.9.3 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --
enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-l
ibilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enab
le-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --en
able-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --ena
ble-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc
--enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enabl
e-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --ena
ble-decklink --enable-opencl --enable-zlib
libavutil 55. 2.100 / 55. 2.100
libavcodec 57. 1.100 / 57. 1.100
libavformat 57. 0.100 / 57. 0.100
libavdevice 57. 0.100 / 57. 0.100
libavfilter 6. 1.100 / 6. 1.100
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.100 / 2. 0.100
libpostproc 54. 0.100 / 54. 0.100
Input #0, image2, from 'img%02d.png':
Duration: 00:00:00.42, start: 0.000000, bitrate: N/A
Stream #0:0: Video: png, rgb24(pc), 800x400, 4.80 tbr, 4.80 tbn, 4.80 tbc
File 'test_output.mp4' already exists. Overwrite ? [y/N] y
[libx264 @ 0000000004f16ba0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0000000004f16ba0] profile High, level 3.0
[libx264 @ 0000000004f16ba0] 264 - core 148 r2597 e86f3a1 - H.264/MPEG-4 AVC cod
ec - Copyleft 2003-2015 - http://www.videolan.org/x264.html - options: cabac=1 r
ef=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_pski
p=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 dec
imate=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_output.mp4':
Metadata:
encoder : Lavf57.0.100
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 800x40
0, q=-1--1, 30 fps, 15360 tbn, 30 tbc
Metadata:
encoder : Lavc57.1.100 libx264
Stream mapping:
Stream #0:0 -> #0:0 (png (native) -> h264 (libx264))
Press [q] to stop, [?] for help
frame= 12 fps=0.0 q=-1.0 Lsize= 3kB time=00:00:00.33 bitrate= 62.2kbits
/s dup=10 drop=0
video:2kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing ove
rhead: 60.557274%
[libx264 @ 0000000004f16ba0] frame I:1 Avg QP:10.12 size: 566
[libx264 @ 0000000004f16ba0] frame P:3 Avg QP:18.10 size: 62
[libx264 @ 0000000004f16ba0] frame B:8 Avg QP:13.75 size: 22
[libx264 @ 0000000004f16ba0] consecutive B-frames: 8.3% 0.0% 25.0% 66.7%
[libx264 @ 0000000004f16ba0] mb I I16..4: 99.4% 0.0% 0.6%
[libx264 @ 0000000004f16ba0] mb P I16..4: 0.0% 0.0% 0.0% P16..4: 0.0% 0.0
% 0.0% 0.0% 0.0% skip:99.9%
[libx264 @ 0000000004f16ba0] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 0.1% 0.0
% 0.0% direct: 0.0% skip:99.9% L0:37.5% L1:62.5% BI: 0.0%
[libx264 @ 0000000004f16ba0] 8x8 transform intra:0.0% inter:0.0%
[libx264 @ 0000000004f16ba0] coded y,uvDC,uvAC intra: 0.6% 0.0% 0.0% inter: 0.0%
0.0% 0.0%
[libx264 @ 0000000004f16ba0] i16 v,h,dc,p: 96% 0% 4% 0%
[libx264 @ 0000000004f16ba0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 29% 18% 36% 2% 2%
3% 3% 5% 1%
[libx264 @ 0000000004f16ba0] i8c dc,h,v,p: 100% 0% 0% 0%
[libx264 @ 0000000004f16ba0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0000000004f16ba0] ref P L0: 50.0% 50.0%
[libx264 @ 0000000004f16ba0] kb/s:18.50 -