
Recherche avancée
Autres articles (7)
-
Contribute to translation
13 avril 2011You can help us to improve the language used in the software interface to make MediaSPIP more accessible and user-friendly. You can also translate the interface into any language that allows it to spread to new linguistic communities.
To do this, we use the translation interface of SPIP where the all the language modules of MediaSPIP are available. Just subscribe to the mailing list and request further informantion on translation.
MediaSPIP is currently available in French and English (...) -
Other interesting software
13 avril 2011, parWe don’t claim to be the only ones doing what we do ... and especially not to assert claims to be the best either ... What we do, we just try to do it well and getting better ...
The following list represents softwares that tend to be more or less as MediaSPIP or that MediaSPIP tries more or less to do the same, whatever ...
We don’t know them, we didn’t try them, but you can take a peek.
Videopress
Website : http://videopress.com/
License : GNU/GPL v2
Source code : (...) -
Selection of projects using MediaSPIP
2 mai 2011, parThe examples below are representative elements of MediaSPIP specific uses for specific projects.
MediaSPIP farm @ Infini
The non profit organizationInfini develops hospitality activities, internet access point, training, realizing innovative projects in the field of information and communication technologies and Communication, and hosting of websites. It plays a unique and prominent role in the Brest (France) area, at the national level, among the half-dozen such association. Its members (...)
Sur d’autres sites (3971)
-
Concatenating video using FFMPEG wrapper class [duplicate]
21 décembre 2017, par alan samuelThis question already has an answer here :
I am trying to concatenate video using NReco.VideoConverter wrapper class made for FFMPEG.
I have three video files with the same frame rate and same frame size.
Here is what I have done.
string toconcatfile = @"C:\Users\Alan\Desktop\Black.mp4";
string output1 = @"C:\Users\Alan\Desktop\output1.mp4";
string output2 = @"C:\Users\Alan\Desktop\output2.mp4";
string finaloutput = @"C:\Users\Alan\Desktop\finaloutput.mp4";All the three videos have a frame rate of 25 and Video frame size yet it fails when I add in toconcatfile to the final conversion method.
It works when its just output1 and output2 meaning there must be a different setting in toconcatfile.
Here is what I have tried.
FFMpegConverter fFMpeg = new FFMpegConverter();
//Slices first video
ConvertSettings settings = new ConvertSettings
{
VideoFrameRate = 25,
VideoFrameSize = FrameSize.hd480,
MaxDuration = startcut,
AudioSampleRate = 44100
};
//Slices second video
ConvertSettings settings2 = new ConvertSettings
{
VideoFrameRate = 25,
VideoFrameSize = FrameSize.hd480,
Seek = endcut,
AudioSampleRate = 44100
};
//Copies framerate and size from the previous video to the concatenation video
ConvertSettings settings3 = new ConvertSettings
{
VideoFrameRate = 25,
VideoFrameSize = FrameSize.hd480,
MaxDuration = 4,
AppendSilentAudioStream = true,
AudioSampleRate = 44100
};
string newblack = @"C:\Users\Alan\Desktop\newblack.mp4";
//Slice method called
fFMpeg.ConvertMedia(pathtofile, Format.mp4, output1, Format.mp4, settings);
fFMpeg.ConvertMedia(pathtofile, Format.mp4, output2, Format.mp4, settings2);
fFMpeg.ConvertMedia(toconcatfile, Format.mp4, newblack, Format.mp4, settings3);
String[] inputfiles = new String[2];
inputfiles[0] = output1;
inputfiles[1] = newblack;
//inputfiles[1] = output2;
ConcatSettings concatSettings = new ConcatSettings
{
//CustomOutputArgs = output1+" "+ toconcatfile+ " "+output2+ " -filter_complex \"[0:v:0][0:a:0][1:v:0][1:a:0][2:v:0][2:a:0]concat=n=3:v=1:a=1[outv][outa]\" -map \"[outv]\" - map \"[outa]\""
};
fFMpeg.ConcatMedia(inputfiles, finaloutput, Format.mp4, concatSettings);Can anyone help ?
Edit : I get the exception message - "Invalid argument (exit code : 1)",
Here is the output log of FFMPEG
FFMPEG LOG ITEM - ffmpeg version 3.2.2 Copyright (c) 2000-2016 the
FFmpeg developers
FFMPEG LOG ITEM - built with gcc 5.4.0 (GCC)
FFMPEG LOG ITEM - configuration: --enable-gpl --enable-version3 --enable-
dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --
enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
FFMPEG LOG ITEM - libavutil 55. 34.100 / 55. 34.100
FFMPEG LOG ITEM - libavcodec 57. 64.101 / 57. 64.101
FFMPEG LOG ITEM - libavformat 57. 56.100 / 57. 56.100
FFMPEG LOG ITEM - libavdevice 57. 1.100 / 57. 1.100
FFMPEG LOG ITEM - libavfilter 6. 65.100 / 6. 65.100
FFMPEG LOG ITEM - libswscale 4. 2.100 / 4. 2.100
FFMPEG LOG ITEM - libswresample 2. 3.100 / 2. 3.100
FFMPEG LOG ITEM - libpostproc 54. 1.100 / 54. 1.100
FFMPEG LOG ITEM - Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Users\Alan\Desktop\output1.mp4':
FFMPEG LOG ITEM - Metadata:
FFMPEG LOG ITEM - major_brand : isom
FFMPEG LOG ITEM - minor_version : 512
FFMPEG LOG ITEM - compatible_brands: isomiso2avc1mp41
FFMPEG LOG ITEM - encoder : Lavf57.56.100
FFMPEG LOG ITEM - Duration: 00:00:30.02, start: 0.000000, bitrate: 543 kb/s
FFMPEG LOG ITEM - Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 852x480 [SAR 3893:2872 DAR 276403:114880], 407 kb/s, SAR 12800:9443 DAR 320:133, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
FFMPEG LOG ITEM - Metadata:
FFMPEG LOG ITEM - handler_name : VideoHandler
FFMPEG LOG ITEM - Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 129 kb/s (default)
FFMPEG LOG ITEM - Metadata:
FFMPEG LOG ITEM - handler_name : SoundHandler
FFMPEG LOG ITEM - Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Users\Alan\Desktop\newblack.mp4':
FFMPEG LOG ITEM - Metadata:
FFMPEG LOG ITEM - major_brand : isom
FFMPEG LOG ITEM - minor_version : 512
FFMPEG LOG ITEM - compatible_brands: isomiso2avc1mp41
FFMPEG LOG ITEM - encoder : Lavf57.56.100
FFMPEG LOG ITEM - Duration: 00:00:04.02, start: 0.000000, bitrate: 19 kb/s
FFMPEG LOG ITEM - Stream #1:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 852x480 [SAR 160:213 DAR 4:3], 7 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
FFMPEG LOG ITEM - Metadata:
FFMPEG LOG ITEM - handler_name : VideoHandler
FFMPEG LOG ITEM - Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 2 kb/s (default)
FFMPEG LOG ITEM - Metadata:
FFMPEG LOG ITEM - handler_name : SoundHandler
FFMPEG LOG ITEM - Input #2, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Users\Alan\Desktop\output2.mp4':
FFMPEG LOG ITEM - Metadata:
FFMPEG LOG ITEM - major_brand : isom
FFMPEG LOG ITEM - minor_version : 512
FFMPEG LOG ITEM - compatible_brands: isomiso2avc1mp41
FFMPEG LOG ITEM - encoder : Lavf57.56.100
FFMPEG LOG ITEM - Duration: 00:01:34.22, start: 0.000000, bitrate: 1058 kb/s
FFMPEG LOG ITEM - Stream #2:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 852x480 [SAR 3893:2872 DAR 276403:114880], 923 kb/s, SAR 12800:9443 DAR 320:133, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
FFMPEG LOG ITEM - Metadata:
Exception thrown: 'NReco.VideoConverter.FFMpegException' in NReco.VideoConverter.dll
FFMPEG LOG ITEM - handler_name : VideoHandler
FFMPEG LOG ITEM - Stream #2:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
FFMPEG LOG ITEM - Metadata:
FFMPEG LOG ITEM - handler_name : SoundHandler
FFMPEG LOG ITEM - [Parsed_concat_0 @ 04ded5e0] Input link in1:v0 parameters (size 852x480, SAR 160:213) do not match the corresponding output link in0:v0 parameters (852x480, SAR 12800:9443)
FFMPEG LOG ITEM - [Parsed_concat_0 @ 04ded5e0] Failed to configure output pad on Parsed_concat_0
FFMPEG LOG ITEM - Error configuring complex filters.
FFMPEG LOG ITEM - Invalid argument -
ffmpeg streaming via rtp reorders streams
19 juin 2023, par konovificationI'm streaming a video using
ffmpeg -i bbb.mp4 -c:v copy -c:a copy -f rtp_mpegts "rtp://239.1.1.1:8000"
. The command line output is :

ffmpeg version 4.3.6-0+deb11u1 Copyright (c) 2000-2023 the FFmpeg developers
 built with gcc 10 (Debian 10.2.1-6)
 configuration: --prefix=/usr --extra-version=0+deb11u1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --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-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
 WARNING: library configuration mismatch
 avcodec configuration: --prefix=/usr --extra-version=0+deb11u1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --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-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared --enable-version3 --disable-doc --disable-programs --enable-libaribb24 --enable-liblensfun --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libtesseract --enable-libvo_amrwbenc
 libavutil 56. 51.100 / 56. 51.100
 libavcodec 58. 91.100 / 58. 91.100
 libavformat 58. 45.100 / 58. 45.100
 libavdevice 58. 10.100 / 58. 10.100
 libavfilter 7. 85.100 / 7. 85.100
 libavresample 4. 0. 0 / 4. 0. 0
 libswscale 5. 7.100 / 5. 7.100
 libswresample 3. 7.100 / 3. 7.100
 libpostproc 55. 7.100 / 55. 7.100
Guessed Channel Layout for Input Stream #0.1 : 5.1
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'bbb.mp4':
 Metadata:
 major_brand : isom
 minor_version : 512
 compatible_brands: isomiso2avc1mp41
 title : Big Buck Bunny, Sunflower version
 artist : Blender Foundation 2008, Janus Bager Kristensen 2013
 composer : Sacha Goedegebure
 encoder : Lavf58.45.100
 comment : Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net
 genre : Animation
 Duration: 00:10:34.64, start: 0.000000, bitrate: 4195 kb/s
 Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 4094 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
 Metadata:
 handler_name : GPAC ISO Video Handler
 Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 96 kb/s (default)
 Metadata:
 handler_name : GPAC ISO Audio Handler
Output #0, rtp_mpegts, to 'rtp://239.1.1.1:8000':
 Metadata:
 major_brand : isom
 minor_version : 512
 compatible_brands: isomiso2avc1mp41
 title : Big Buck Bunny, Sunflower version
 artist : Blender Foundation 2008, Janus Bager Kristensen 2013
 composer : Sacha Goedegebure
 genre : Animation
 comment : Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net
 encoder : Lavf58.45.100
 Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 4094 kb/s, 25 fps, 25 tbr, 90k tbn, 25 tbc (default)
 Metadata:
 handler_name : GPAC ISO Video Handler
 Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 96 kb/s (default)
 Metadata:
 handler_name : GPAC ISO Audio Handler
Stream mapping:
 Stream #0:0 -> #0:0 (copy)
 Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help



When I run
ffprobe rtp://239.1.1.1:8000
(without restarting the stream), around one in ten times I get

Input #0, rtp, from 'rtp://239.1.1.1:8000':
 Duration: N/A, start: 411.533978, bitrate: N/A
 Program 1 
 Metadata:
 service_name : Service01
 service_provider: FFmpeg
 Stream #0:1: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
 Stream #0:0: Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 384 kb/s



Meaning that the video and audio streams swapped indices. I'm writing a program which uses
libav
where I rely on this to not happen. What is the reason for this and can it be fixed ?

-
Python cv2 script that scans a giant image to a video. Why do I need pad two extra lines
27 avril 2022, par MahrarenaI wrote a script that scans a giant image to make a video. Normally I just post my scripts straight to my Code Review account, but this script is ugly, needs to be refactored, implements only horizontal scrolling and most importantly I just fixed a bug but I don't completely understand why it works.


Example :


Original image (Google Drive)


Video Output (Google Drive)


As you can see from the video, everything is working properly except the fact that I don't know how it works.


Full working code



import cv2
import numpy as np
import random
import rpack
from fractions import Fraction
from math import prod

def resize_guide(image_size, target_area):
 aspect_ratio = Fraction(*image_size).limit_denominator()
 horizontal = aspect_ratio.numerator
 vertical = aspect_ratio.denominator
 unit_length = (target_area/(horizontal*vertical))**.5
 return (int(horizontal*unit_length), int(vertical*unit_length))

fourcc = cv2.VideoWriter_fourcc(*'mp4v')
FRAME = np.zeros((1080, 1920, 3), dtype=np.uint8)

def new_frame():
 return np.ndarray.copy(FRAME)

def center(image):
 frame = new_frame()
 h, w = image.shape[:2]
 yoff = round((1080-h)/2)
 xoff = round((1920-w)/2)
 frame[yoff:yoff+h, xoff:xoff+w] = image
 return frame

def image_scanning(file, fps=60, pan_increment=64, horizontal_increment=8):
 image = cv2.imread(file)
 height, width = image.shape[:2]
 assert width*height >= 1920*1080
 video_writer = cv2.VideoWriter(file+'.mp4', fourcc, fps, (1920, 1080))
 fit_height = True
 if height < 1080:
 width = width*1080/height
 image = cv2.resize(image, (width, 1080), interpolation = cv2.INTER_AREA)
 aspect_ratio = width / height
 zooming_needed = False
 if 4/9 <= aspect_ratio <= 16/9:
 new_width = round(width*1080/height)
 fit = cv2.resize(image, (new_width, 1080), interpolation = cv2.INTER_AREA)
 zooming_needed = True
 
 elif 16/9 < aspect_ratio <= 32/9:
 new_height = round(height*1920/width)
 fit = cv2.resize(image, (1920, new_height), interpolation = cv2.INTER_AREA)
 fit_height = False
 zooming_needed = True
 
 centered = center(fit)
 for i in range(fps):
 video_writer.write(centered)
 if fit_height:
 xoff = round((1920 - new_width)/2)
 while xoff:
 if xoff - pan_increment >= 0:
 xoff -= pan_increment
 else:
 xoff = 0
 frame = new_frame()
 frame[0:1080, xoff:xoff+new_width] = fit
 video_writer.write(frame)
 else:
 yoff = round((1080 - new_height)/2)
 while yoff:
 if yoff - pan_increment >= 0:
 yoff -= pan_increment
 else:
 yoff = 0
 frame = new_frame()
 frame[yoff:yoff+new_height, 0:1920] = fit
 video_writer.write(frame)
 
 if zooming_needed:
 if fit_height:
 width_1, height_1 = new_width, 1080
 else:
 width_1, height_1 = 1920, new_height
 new_area = width_1 * height_1
 original_area = width * height
 area_diff = original_area - new_area
 unit_diff = area_diff / fps
 for i in range(1, fps+1):
 zoomed = cv2.resize(image, resize_guide((width_1, height_1), new_area+unit_diff*i), interpolation=cv2.INTER_AREA)
 zheight, zwidth = zoomed.shape[:2]
 zheight = min(zheight, 1080)
 zwidth = min(zwidth, 1920)
 frame = new_frame()
 frame[0:zheight, 0:zwidth] = zoomed[0:zheight, 0:zwidth]
 video_writer.write(frame)
 
 if (width - 1920) % horizontal_increment:
 new_width = ((width - 1920) // horizontal_increment + 1) * horizontal_increment + 1920
 frame = np.zeros([height, new_width, 3], dtype=np.uint8)
 frame[0:height, 0:width] = image
 width = new_width
 image = frame
 
 if height % 1080:
 new_height = (height // 1080 + 2) * 1080
 frame = np.zeros([new_height, width, 3], dtype=np.uint8)
 frame[0:height, 0:width] = image
 height = new_height - 1080
 image = frame
 
 y, x = 0, 0
 for y in range(0, height, 1080):
 for x in range(0, width-1920, horizontal_increment):
 frame = image[y:y+1080, x:x+1920]
 video_writer.write(frame)
 x = width - 1920
 frame = image[y:y+1080, x:x+1920]
 for i in range(round(fps/3)):
 video_writer.write(frame)
 cv2.destroyAllWindows()
 video_writer.release()
 del video_writer



I don't know why I need to pad two extra lines instead of one, meaning if I change this :


if height % 1080:
 new_height = (height // 1080 + 2) * 1080
 frame = np.zeros([new_height, width, 3], dtype=np.uint8)
 frame[0:height, 0:width] = image
 height = new_height - 1080
 image = frame



To this :


if height % 1080:
 new_height = (height // 1080 + 1) * 1080
 frame = np.zeros([new_height, width, 3], dtype=np.uint8)
 frame[0:height, 0:width] = image
 height = new_height
 image = frame



The program raises exceptions :


OpenCV: FFMPEG: tag 0x34363268/'h264' is not supported with codec id 27 and format 'mp4 / MP4 (MPEG-4 Part 14)'
OpenCV: FFMPEG: fallback to use tag 0x31637661/'avc1'
---------------------------------------------------------------------------
error Traceback (most recent call last)
 in <module>
----> 1 image_scanning("D:/collages/91f53ebcea2a.png")

 in image_scanning(file, fps, pan_increment, horizontal_increment, fast_decrement)
 122 x += horizontal_increment
 123 frame = image[y:y+1080, x:x+1920]
--> 124 video_writer.write(frame)
 125 cv2.destroyAllWindows()
 126 video_writer.release()

error: Unknown C++ exception from OpenCV code
</module>


I guess it was caused by indexing error because the last line would not have enough pixels so padding the height of the image to a multiple of 1080 should work.


But that's not the case, I need to pad two lines, why is that ? I really don't understand why it is working.



No, I really wrote all of it, I understand all the principles, the ideas are all mine, but there is one small problem in implementation. I don't know why I need extra pixels in the bottom to make it work, because if I don't pad the height to a multiple of 1080, I can't get the bottom line, the lowest potion of height % 1080 would be lost.


If I tried to get the lowest part, the program will raise exceptions even if I pad the height to a multiple of 1080, I think it is related to indexing but I don't fully understand it, turns out I need to pad the height and add extra pixels, even 1 pixel would work.


I don't know why it raises exceptions and how add extra pixels got rid of the exception, but I understand everything else perfectly clear, after all I wrote it.


There's a bug in my program, I don't know what caused it, and I want you to help me debugging, and that's the entire point of the question !