
Recherche avancée
Autres articles (26)
-
Modifier la date de publication
21 juin 2013, parComment changer la date de publication d’un média ?
Il faut au préalable rajouter un champ "Date de publication" dans le masque de formulaire adéquat :
Administrer > Configuration des masques de formulaires > Sélectionner "Un média"
Dans la rubrique "Champs à ajouter, cocher "Date de publication "
Cliquer en bas de la page sur Enregistrer -
Publier sur MédiaSpip
13 juin 2013Puis-je poster des contenus à partir d’une tablette Ipad ?
Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir -
Pas question de marché, de cloud etc...
10 avril 2011Le vocabulaire utilisé sur ce site essaie d’éviter toute référence à la mode qui fleurit allègrement
sur le web 2.0 et dans les entreprises qui en vivent.
Vous êtes donc invité à bannir l’utilisation des termes "Brand", "Cloud", "Marché" etc...
Notre motivation est avant tout de créer un outil simple, accessible à pour tout le monde, favorisant
le partage de créations sur Internet et permettant aux auteurs de garder une autonomie optimale.
Aucun "contrat Gold ou Premium" n’est donc prévu, aucun (...)
Sur d’autres sites (4450)
-
Pipe opencv frames into ffmpeg
25 juin 2023, par Dmytro SoltusyukI am trying to pipe opencv frames into ffmpeg, but it does not work.


After the research, I found this answer (https://stackoverflow.com/a/62807083/10676682) to work the best for me, so I have the following :


def start_streaming_process(rtmp_url, width, height, fps):
 # fmt: off
 cmd = ['ffmpeg',
 '-y',
 '-f', 'rawvideo',
 '-vcodec', 'rawvideo',
 '-pix_fmt', 'bgr24',
 '-s', "{}x{}".format(width, height),
 '-r', str(fps),
 '-i', '-',
 '-c:v', 'libx264',
 '-pix_fmt', 'yuv420p',
 '-preset', 'ultrafast',
 '-f', 'flv',
 '-flvflags', 'no_duration_filesize',
 rtmp_url]
 # fmt: on

 return subprocess.Popen(cmd, stdin=subprocess.PIPE)



def main():
 width, height, fps = get_video_size(SOURCE_VIDEO_PATH)
 streaming_process = start_streaming_process(
 TARGET_VIDEO_PATH,
 width,
 height,
 fps,
 )

 model = load_yolo(WEIGHTS_PATH)
 frame_iterator = read_frames(video_source=SOURCE_VIDEO_PATH)
 processed_frames_iterator = process_frames(
 model, frame_iterator, ball_target_area=400
 )

 for processed_frame in processed_frames_iterator:
 streaming_process.communicate(processed_frame.tobytes())

 streaming_process.kill()



processed_frame
here is an annotated OpenCV frame.

However, after I do my first
streaming_process.communicate
call, the ffmpeg process exits with code 0 (meaning everything was ok), but it is not. I can not feed the rest of the frames into ffmpeg, because the process exited.

Here are the logs :


Input #0, rawvideo, from 'fd:':
 Duration: N/A, start: 0.000000, bitrate: 663552 kb/s
 Stream #0:0: Video: rawvideo (BGR[24] / 0x18524742), bgr24, 1280x720, 663552 kb/s, 30 tbr, 30 tbn
Stream mapping:
 Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
[libx264 @ 0x132e05570] using cpu capabilities: ARMv8 NEON
[libx264 @ 0x132e05570] profile High, level 3.1, 4:2:0, 8-bit
[libx264 @ 0x132e05570] 264 - core 164 r3095 baee400 - H.264/MPEG-4 AVC codec - Copyleft 2003-2022 - h
ttp://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=15 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 inter
laced=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 mbt
ree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, flv, to 'rtmp://global-live.mux.com:5222/app/9428e064-e5d3-0bee-dc67-974ba53ce164':
 Metadata:
 encoder : Lavf60.3.100
 Stream #0:0: Video: h264 ([7][0][0][0] / 0x0007), yuv420p(tv, progressive), 1280x720, q=2-31, 30 fps
, 1k tbn
 Metadata:
 encoder : Lavc60.3.100 libx264
 Side data:
 cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
frame= 1 fps=0.0 q=29.0 Lsize= 41kB time=00:00:00.00 bitrate=N/A speed= 0x eed=N/A 
video:40kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.678311%
[libx264 @ 0x132e05570] frame I:1 Avg QP:25.22 size: 40589
[libx264 @ 0x132e05570] mb I I16..4: 37.7% 33.4% 28.9%
[libx264 @ 0x132e05570] 8x8 transform intra:33.4%
[libx264 @ 0x132e05570] coded y,uvDC,uvAC intra: 51.1% 53.2% 14.4%
[libx264 @ 0x132e05570] i16 v,h,dc,p: 32% 38% 20% 10%
[libx264 @ 0x132e05570] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 16% 36% 28% 3% 2% 2% 3% 3% 6%
[libx264 @ 0x132e05570] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 18% 37% 17% 4% 4% 4% 5% 4% 7%
[libx264 @ 0x132e05570] i8c dc,h,v,p: 46% 37% 12% 4%
[libx264 @ 0x132e05570] kb/s:9741.36



That's all. Exit code 0.


-
ffmpeg converts anything to mp4
23 septembre 2015, par KevinOelenI’m trying to get familiar with python subprocess and here is my little code :
import subprocess
import os
import re
import subprocess as sp
import logging
the_file = "/home/vagrant/test/out.pkg"
out_file = "/home/vagrant/test/result.mp4"
ffmpeg = sp.Popen(['/usr/bin/ffmpeg', '-i', the_file, out_file], stdout = sp.PIPE, stderr = sp.STDOUT)
process_output = ffmpeg.communicate()
print "communicate:", process_outputThe result :
communicate: ("ffmpeg version N-75410-g58fe57d Copyright (c) 2000-2015 the FFmpeg developers\n built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-16)\n configuration: --prefix=/home/vagrant/ffmpeg_build --extra-cflags=-I/home/vagrant/ffmpeg_build/include --extra-ldflags=-L/home/vagrant/ffmpeg_build/lib --bindir=/usr/local/bin --enable-gpl --enable-nonfree --enable-libfdk_aac --enable-libmp3lame --enable-libvorbis --enable-libopus --enable-libvpx --enable-libx264 --enable-libfreetype\n libavutil 55. 2.100 / 55. 2.100\n libavcodec 57. 3.100 / 57. 3.100\n libavformat 57. 2.100 / 57. 2.100\n libavdevice 57. 0.100 / 57. 0.100\n libavfilter 6. 5.100 / 6. 5.100\n libswscale 4. 0.100 / 4. 0.100\n libswresample 2. 0.100 / 2. 0.100\n libpostproc 54. 0.100 / 54. 0.100\nInput #0, tty, from '/home/vagrant/test/out.txt':\n Duration: 00:00:00.04, bitrate: 1 kb/s\n Stream #0:0: Video: ansi, pal8, 640x400, 25 fps, 25 tbr, 25 tbn, 25 tbc\nNo pixel format specified, yuv444p for H.264 encoding chosen.\nUse -pix_fmt yuv420p for compatibility with outdated media players.\n[libx264 @ 0x379f300] using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64\n[libx264 @ 0x379f300] profile High 4:4:4 Predictive, level 3.0, 4:4:4 8-bit\n[libx264 @ 0x379f300] 264 - core 148 r2597 e86f3a1 - 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=1 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\nOutput #0, mp4, to '/home/vagrant/test/result.mp4':\n Metadata:\n encoder : Lavf57.2.100\n Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv444p, 640x400, q=-1--1, 25 fps, 12800 tbn, 25 tbc\n Metadata:\n encoder : Lavc57.3.100 libx264\nStream mapping:\n Stream #0:0 -> #0:0 (ansi (native) -> h264 (libx264))\nPress [q] to stop, [?] for help\nframe= 1 fps=0.0 q=28.0 Lsize= 2kB time=00:00:00.04 bitrate= 362.4kbits/s \nvideo:1kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 78.698227%\n[libx264 @ 0x379f300] frame I:1 Avg QP:13.08 size: 326\n[libx264 @ 0x379f300] mb I I16..4: 0.4% 99.1% 0.5%\n[libx264 @ 0x379f300] 8x8 transform intra:99.1%\n[libx264 @ 0x379f300] coded y,u,v intra: 0.4% 0.0% 0.0%\n[libx264 @ 0x379f300] i16 v,h,dc,p: 0% 75% 25% 0%\n[libx264 @ 0x379f300] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 0% 92% 8% 0% 0% 0% 0% 0% 0%\n[libx264 @ 0x379f300] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 24% 35% 35% 2% 1% 0% 2% 0% 0%\n[libx264 @ 0x379f300] kb/s:65.20\n", None)
As it expected, sends me back a tuple (stdout,stderr). But the problem is, ffmpeg converts any file(as you can see above, even pkg file) without giving me back an error or exit status with 1. stderr = None
Can anyone explain what’s wrong on this one ? Thanks so much.
-
Pipe breaks when piping gif to ffmpeg
20 avril 2015, par forwardslashI’ve been trying to pipe gifs to ffmpeg to turn them into mp4s but I keep getting I/O errors from the pipe when I try.
Something like
cat nyan.gif | ffmpeg -f gif -i - -pix_fmt yuv420p -y nyan.mp4
Outputs
fmpeg version 2.6.2 Copyright (c) 2000-2015 the FFmpeg developers
built with Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/2.6.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-libvo-aacenc --enable-libxvid --enable-openssl --enable-libwebp --enable-nonfree --enable-vda
libavutil 54. 20.100 / 54. 20.100
libavcodec 56. 26.100 / 56. 26.100
libavformat 56. 25.101 / 56. 25.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 11.102 / 5. 11.102
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, gif, from 'pipe:0':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: gif, bgra, 752x420, 100 tbr, 100 tbn, 100 tbc
[libx264 @ 0x7f9b3a012e00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0x7f9b3a012e00] profile High, level 3.2
[libx264 @ 0x7f9b3a012e00] 264 - core 144 r2533 c8a773e - 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=-2 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 'nyan3.mp4':
Metadata:
encoder : Lavf56.25.101
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 752x420, q=-1--1, 100 fps, 12800 tbn, 100 tbc
Metadata:
encoder : Lavc56.26.100 libx264
Stream mapping:
Stream #0:0 -> #0:0 (gif (native) -> h264 (libx264))
pipe:0: Input/output error
frame= 20 fps=0.0 q=-1.0 Lsize= 21kB time=00:00:00.18 bitrate= 974.0kbits/s dup=17 drop=0
video:20kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 5.163643%
[libx264 @ 0x7f9b3a012e00] frame I:1 Avg QP:20.83 size: 10238
[libx264 @ 0x7f9b3a012e00] frame P:6 Avg QP:21.55 size: 1484
[libx264 @ 0x7f9b3a012e00] frame B:13 Avg QP:17.85 size: 77
[libx264 @ 0x7f9b3a012e00] consecutive B-frames: 10.0% 0.0% 30.0% 60.0%
[libx264 @ 0x7f9b3a012e00] mb I I16..4: 42.0% 32.5% 25.5%
[libx264 @ 0x7f9b3a012e00] mb P I16..4: 0.6% 2.2% 1.6% P16..4: 4.7% 2.2% 1.2% 0.0% 0.0% skip:87.4%
[libx264 @ 0x7f9b3a012e00] mb B I16..4: 0.3% 0.0% 0.0% B16..8: 3.8% 0.0% 0.0% direct: 0.0% skip:95.8% L0:62.9% L1:37.0% BI: 0.2%
[libx264 @ 0x7f9b3a012e00] 8x8 transform intra:35.1% inter:11.1%
[libx264 @ 0x7f9b3a012e00] coded y,uvDC,uvAC intra: 18.2% 30.0% 25.7% inter: 0.6% 0.4% 0.3%
[libx264 @ 0x7f9b3a012e00] i16 v,h,dc,p: 70% 17% 13% 0%
[libx264 @ 0x7f9b3a012e00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 43% 8% 47% 0% 0% 0% 1% 0% 1%
[libx264 @ 0x7f9b3a012e00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28% 33% 22% 2% 3% 2% 4% 2% 4%
[libx264 @ 0x7f9b3a012e00] i8c dc,h,v,p: 69% 20% 8% 3%
[libx264 @ 0x7f9b3a012e00] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x7f9b3a012e00] ref P L0: 83.5% 5.8% 8.9% 1.8%
[libx264 @ 0x7f9b3a012e00] ref B L0: 66.7% 33.0% 0.2%
[libx264 @ 0x7f9b3a012e00] ref B L1: 85.7% 14.3%
[libx264 @ 0x7f9b3a012e00] kb/s:805.96The important part being
pipe:0: Input/output error
I’ve tried this in bash and zsh on OSX and Ubuntu and I get the same error on all of them. I get the same error when trying to pipe with curl or httpie. When I just have file as input it works fine. Am I missing something necessary when piping to ffmpeg ?