
Recherche avancée
Autres articles (48)
-
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 -
Contribute to documentation
13 avril 2011Documentation is vital to the development of improved technical capabilities.
MediaSPIP welcomes documentation by users as well as developers - including : critique of existing features and functions articles contributed by developers, administrators, content producers and editors screenshots to illustrate the above translations of existing documentation into other languages
To contribute, register to the project users’ mailing (...) -
Ajouter notes et légendes aux images
7 février 2011, parPour pouvoir ajouter notes et légendes aux images, la première étape est d’installer le plugin "Légendes".
Une fois le plugin activé, vous pouvez le configurer dans l’espace de configuration afin de modifier les droits de création / modification et de suppression des notes. Par défaut seuls les administrateurs du site peuvent ajouter des notes aux images.
Modification lors de l’ajout d’un média
Lors de l’ajout d’un média de type "image" un nouveau bouton apparait au dessus de la prévisualisation (...)
Sur d’autres sites (7161)
-
lavfi/dnn : Add OpenVINO API 2.0 support
15 août 2023, par Wenbin Chenlavfi/dnn : Add OpenVINO API 2.0 support
OpenVINO API 2.0 was released in March 2022, which introduced new
features.
This commit implements current OpenVINO features with new 2.0 APIs. And
will add other features in API 2.0.
Please add installation path, which include openvino.pc, to
PKG_CONFIG_PATH mannually for new OpenVINO libs config.Signed-off-by : Ting Fu <ting.fu@intel.com>
Signed-off-by : Wenbin Chen <wenbin.chen@intel.com> -
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 error in subprocess.run but works in terminal
6 juin 2023, par 8TMI'm creating my own MKV videos and I found a strange bug when I'm using subprocess module from python 3.11.2 to execute FFmpeg command.


My FFmpeg command is running fine in terminal (ends with success) :


ffmpeg -y \
-i input_video_stream.mkv \
-i input_audio_stream_1.ac3 \
-i input_audio_stream_2.ac3 \
-i input_audio_stream_3.ac3 \
-i input_audio_stream_4.ac3 \
-f srt -i input_subtitle_stream_1.srt \
-f srt -i input_subtitle_stream_2.srt \
-map 0 -map 1 -map 2 -map 3 -map 4 -map 5 -map 6 \
-c copy \
-metadata:s:a:0 language=eng -metadata:s:a:0 title="English1" \
-metadata:s:a:1 language=eng -metadata:s:a:1 title="English2" \
-metadata:s:a:2 language=eng -metadata:s:a:2 title="English3" \
-metadata:s:a:3 language=eng -metadata:s:a:3 title="English4" \
-metadata:s:s:0 language=eng -metadata:s:s:0 title="English1" -metadata:s:s:0 mimetype=application/x-ass \
-metadata:s:s:1 language=eng -metadata:s:s:1 title="English2" -metadata:s:s:1 mimetype=application/x-ass \
-disposition:a:0 default -disposition:s:s:0 default \
output_video_with_audio_and_subtitles.mkv



But when I'm running it by in the same terminal (the same session and the same ffmpeg version) by python from subprocess.run(command) :


subprocess.run([
 'ffmpeg', '-y',
 '-i', 'input_video_stream.mkv',
 '-i', 'input_audio_stream_1.ac3',
 '-i', 'input_audio_stream_2.ac3',
 '-i', 'input_audio_stream_3.ac3',
 '-i', 'input_audio_stream_4.ac3',
 '-f', 'srt', '-i', 'input_subtitle_stream_1.srt',
 '-f', 'srt', '-i', 'input_subtitle_stream_2.srt',
 '-map', '0', '-map', '1', '-map', '2', '-map', '3', '-map', '4', '-map', '5', '-map', '6',
 '-c', 'copy',
 '-metadata:s:a:0', 'language=eng', '-metadata:s:a:0', 'title="English1"', 
 '-metadata:s:a:1', 'language=eng', '-metadata:s:a:1', 'title="English2"', 
 '-metadata:s:a:2', 'language=eng', '-metadata:s:a:2', 'title="English3"', 
 '-metadata:s:a:3', 'language=eng', '-metadata:s:a:3', 'title="English4"', 
 '-metadata:s:s:0', 'language=eng', '-metadata:s:s:0', 'title="English1"', 
 '-metadata:s:s:0', 'mimetype=application/x-ass',
 '-metadata:s:s:1', 'language=eng', '-metadata:s:s:1', 'title="English2"', '-metadata:s:s:1', 'mimetype=application/x-ass', 
 '-disposition:a:0 default', '-disposition:s:s:0 default', 
 'output_video_with_audio_and_subtitles.mkv'
])




it fails :



ffmpeg version 5.1.2-3 Copyright (c) 2000-2022 the FFmpeg developers
 built with gcc 12 (Debian 12.2.0-14)
 configuration : —prefix=/usr —extra-version=3 —toolchain=hardened —libdir=/usr/lib/x86_64-linux-gnu —incdir=/usr/include/x86_64-linux-gnu —arch=amd64 —enable-gpl —disable-stripping —enable-gnutls —enable-ladspa —enable-libaom —enable-libass —enable-libbluray —enable-libbs2b —enable-libcaca —enable-libcdio —enable-libcodec2 —enable-libdav1d —enable-libflite —enable-libfontconfig —enable-libfreetype —enable-libfribidi —enable-libglslang —enable-libgme —enable-libgsm —enable-libjack —enable-libmp3lame —enable-libmysofa —enable-libopenjpeg —enable-libopenmpt —enable-libopus —enable-libpulse —enable-librabbitmq —enable-librist —enable-librubberband —enable-libshine —enable-libsnappy —enable-libsoxr —enable-libspeex —enable-libsrt —enable-libssh —enable-libsvtav1 —enable-libtheora —enable-libtwolame —enable-libvidstab —enable-libvorbis —enable-libvpx —enable-libwebp —enable-libx265 —enable-libxml2 —enable-libxvid —enable-libzimg —enable-libzmq —enable-libzvbi —enable-lv2 —enable-omx —enable-openal —enable-opencl —enable-opengl —enable-sdl2 —disable-sndio —enable-libjxl —enable-pocketsphinx —enable-librsvg —enable-libmfx —enable-libdc1394 —enable-libdrm —enable-libiec61883 —enable-chromaprint —enable-frei0r —enable-libx264 —enable-libplacebo —enable-librav1e —enable-shared
 libavutil 57. 28.100 / 57. 28.100
 libavcodec 59. 37.100 / 59. 37.100
 libavformat 59. 27.100 / 59. 27.100
 libavdevice 59. 7.100 / 59. 7.100
 libavfilter 8. 44.100 / 8. 44.100
 libswscale 6. 7.100 / 6. 7.100
 libswresample 4. 7.100 / 4. 7.100
 libpostproc 56. 6.100 / 56. 6.100
Input #0, matroska,webm, from 'input_video_stream.mkv' :
 Metadata :
 ENCODER : Lavf59.27.100
 Duration : 00:44:19.94, start : 0.000000, bitrate : 22551 kb/s
 Stream #0:0 : Video : h264 (High), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn (default)
 Metadata :
 BPS : 22549589
 NUMBER_OF_FRAMES : 63631
 NUMBER_OF_BYTES : 7480665638
 _STATISTICS_WRITING_APP : mkvmerge v56.0.0 ('Strasbourg / St. Denis') 64-bit
 _STATISTICS_WRITING_DATE_UTC : 2023-05-15 08:21:43
 _STATISTICS_TAGS : BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
 DURATION : 00:44:19.942000000
[ac3 @ 0x55b374ee9e80] Estimating duration from bitrate, this may be inaccurate
Input #1, ac3, from 'input_audio_stream_1.ac3' :
 Duration : 00:44:19.89, start : 0.000000, bitrate : 448 kb/s
 Stream #1:0 : Audio : ac3, 48000 Hz, 5.1(side), fltp, 448 kb/s
[ac3 @ 0x55b37502ef80] Estimating duration from bitrate, this may be inaccurate
Input #2, ac3, from 'input_audio_stream_2.ac3' :
 Duration : 00:44:19.89, start : 0.000000, bitrate : 192 kb/s
 Stream #2:0 : Audio : ac3, 48000 Hz, stereo, fltp, 192 kb/s
[ac3 @ 0x55b374efc900] Estimating duration from bitrate, this may be inaccurate
Input #3, ac3, from 'input_audio_stream_3.ac3' :
 Duration : 00:43:19.18, start : 0.000000, bitrate : 384 kb/s
 Stream #3:0 : Audio : ac3, 48000 Hz, stereo, fltp, 384 kb/s
[ac3 @ 0x55b374fd60c0] Estimating duration from bitrate, this may be inaccurate
Input #4, ac3, from 'input_audio_stream_4.ac3' :
 Duration : 00:43:19.18, start : 0.000000, bitrate : 192 kb/s
 Stream #4:0 : Audio : ac3, 48000 Hz, stereo, fltp, 192 kb/s
Input #5, srt, from 'input_subtitle_stream_1.srt' :
 Duration : N/A, bitrate : N/A
 Stream #5:0 : Subtitle : subrip
Input #6, srt, from 'input_subtitle_stream_2.srt' :
 Duration : N/A, bitrate : N/A
 Stream #6:0 : Subtitle : subrip
[matroska @ 0x55b3751a1940] Invalid stream specifier : a:0 default.
 Last message repeated 1 times



I know it's reporting something with audio ([matroska @ 0x55b3751a1940] Invalid stream specifier : a:0 default. Last message repeated 1 times) but it's probably problem with my ffmpeg command.