
Recherche avancée
Autres articles (62)
-
Des sites réalisés avec MediaSPIP
2 mai 2011, parCette page présente quelques-uns des sites fonctionnant sous MediaSPIP.
Vous pouvez bien entendu ajouter le votre grâce au formulaire en bas de page. -
HTML5 audio and video support
13 avril 2011, parMediaSPIP uses HTML5 video and audio tags to play multimedia files, taking advantage of the latest W3C innovations supported by modern browsers.
The MediaSPIP player used has been created specifically for MediaSPIP and can be easily adapted to fit in with a specific theme.
For older browsers the Flowplayer flash fallback is used.
MediaSPIP allows for media playback on major mobile platforms with the above (...) -
Librairies et binaires spécifiques au traitement vidéo et sonore
31 janvier 2010, parLes logiciels et librairies suivantes sont utilisées par SPIPmotion d’une manière ou d’une autre.
Binaires obligatoires FFMpeg : encodeur principal, permet de transcoder presque tous les types de fichiers vidéo et sonores dans les formats lisibles sur Internet. CF ce tutoriel pour son installation ; Oggz-tools : outils d’inspection de fichiers ogg ; Mediainfo : récupération d’informations depuis la plupart des formats vidéos et sonores ;
Binaires complémentaires et facultatifs flvtool2 : (...)
Sur d’autres sites (6907)
-
x264 output video is blank when threading is enabled
15 juillet 2020, par NewbieCoderI am using libx264 compiled from source. It was configured to get both .dll and .lib by this command


./configure --disable-cli --enable-shared --extra-ldflags=-Wl,--output-def=libx264.def`


I am using the libx264 API in my screen-sharing program with the preset - "veryfast", tune - "zerolatency", profile - "high" and also the following settings.


param.i_csp = X264_CSP_BGRA;
 param.i_threads = 1;
 param.i_width = width;
 param.i_height = height;
 param.i_fps_num = fps;
 param.i_fps_den = 1;
 param.rc.i_bitrate = bitrate;
 param.rc.i_rc_method = X264_RC_ABR;
 param.rc.b_filler = true;
 param.rc.f_rf_constant = (float)0;
 param.rc.i_vbv_max_bitrate = param.rc.i_bitrate;
 param.rc.i_vbv_buffer_size = param.rc.i_bitrate;
 param.b_repeat_headers = 0;
 param.b_annexb = 1;



For these settings the program works fine. I specified it as single threaded by setting
param.i_threads = 1
.
If this is removed, x264 defaults to using multiple threads and setsparam.i_threads
as 1.5x of number of cores in the CPU automatically. This will give faster performance than running in single thread.

But when I remove the
param.i_threads = 1
to make it multi-threaded, the generated output is fully grey. I cannot see any output when I view the live stream with VLC or some times I can view a weird output.

I am using this bitmap image as an example (https://imgur.com/a/l8LCd1l). Only this same image is being encoded multiple times. When it is saved into .h264 video, it is viewable clearly. But when the encoded payload is sent through rtmp, the live stream produces very bad and weird output (or sometimes no output). This is the weird output which im seeing most of the time for this image : https://imgur.com/a/VdyX1Zm


This is the full example code in which I am both streaming and writing video file of the same picture. This is using the srs librtmp library. There is no error but the stream has weird output.


In this code if you set add
param.i_threads = 1;
then only the output stream will be viewable. The problem is that it should be viewable in both single-threaded and multi-threaded encoding.

#include <iostream>
#include 
#include <sstream>
#include 
#include "srs_librtmp.h"

#pragma comment(lib, "C:/Softwares/x264/libx264.lib")

using namespace std;

int check_ret(int ret);

int main()
{
 int dts = 0;

 x264_param_t param;
 x264_t* h;
 x264_nal_t* nals;
 int i_nal;
 int pts = 0;
 int i_frame_size;
 x264_picture_t picIn;
 x264_picture_t picOut;

 x264_param_default_preset(&param, "veryfast", "zerolatency");

 //x264 settings
 param.i_csp = X264_CSP_BGRA;
 param.i_width = 1920;
 param.i_height = 1080;
 param.i_fps_num = 30;
 param.i_fps_den = 1;
 param.rc.i_bitrate = 2500;
 param.rc.i_rc_method = X264_RC_ABR;
 param.rc.b_filler = true;
 param.rc.f_rf_constant = (float)0;
 param.rc.i_vbv_max_bitrate = param.rc.i_bitrate;
 param.rc.i_vbv_buffer_size = param.rc.i_bitrate;
 param.b_repeat_headers = 0;
 param.b_annexb = 1;

 x264_param_apply_profile(&param, "high");
 h = x264_encoder_open(&param);

 //allocate picture
 x264_picture_alloc(&picIn, param.i_csp, param.i_width, param.i_height);

 //picture settings
 picIn.img.i_plane = 1;
 picIn.img.i_stride[0] = 4 * param.i_width;
 picIn.i_type = X264_TYPE_AUTO;

 int header_size = x264_encoder_headers(h, &nals, &i_nal);
 FILE* fptr;
 fopen_s(&fptr, "example1.h264", "wb");
 // write sps and pps in the video file
 fwrite(nals->p_payload, header_size, 1, fptr);

 int size = 1920 * 1080 * 4;
 char* bmp = new char[size];
 FILE* bitptr;
 errno_t err = fopen_s(&bitptr, "flower.bmp", "rb");
 fseek(bitptr, 54, SEEK_SET);
 fread(bmp, size, 1, bitptr);
 fclose(bitptr);

 srs_rtmp_t rtmp = srs_rtmp_create("127.0.0.1:1935/live/test");

 if (srs_rtmp_handshake(rtmp) != 0)
 {
 std::cout << "Simple handshake failed.";
 return -1;
 }

 std::cout << "Handshake completed successfully.\n";

 if (srs_rtmp_connect_app(rtmp) != 0) {
 std::cout << "Connecting to host failed.";
 return -1;
 }

 std::cout << "Connected to host successfully.\n";

 if (srs_rtmp_publish_stream(rtmp) != 0) {
 std::cout << "Publish signal failed.";
 }

 std::cout << "Publish signal success\n";

 // write sps and pps in the live stream
 int ret = srs_h264_write_raw_frames(rtmp, reinterpret_cast(nals->p_payload), header_size, 0, 0);
 ret = check_ret(ret);
 if (!ret)
 return -1;
 std::cout << "SPS and PPS sent.\n";

 // main loop
 std::cout << "Now streaming and encoding\n";
 int i = 1800;
 while (i--)
 {

 picIn.img.plane[0] = reinterpret_cast(bmp);
 picIn.i_pts = pts++;
 i_frame_size = x264_encoder_encode(h, &nals, &i_nal, &picIn, &picOut);
 if (i_frame_size)
 {
 for (int j = 0; j < i_nal; j++)
 {

 x264_nal_t* nal = nals + j;
 // write data in the video file
 fwrite(nal->p_payload, nal->i_payload, 1, fptr);
 // write data in the live stream
 ret = srs_h264_write_raw_frames(rtmp, reinterpret_cast(nal->p_payload), nal->i_payload, dts, dts);
 ret = check_ret(ret);
 if (!ret)
 {
 return -1;
 }
 }
 }
 else
 {
 std::cout << "i_frame_size = 0 (encoder failed)\n";
 }
 dts += 33;
 }

 while (x264_encoder_delayed_frames(h))
 {
 i_frame_size = x264_encoder_encode(h, &nals, &i_nal, NULL, &picOut);
 if (i_frame_size)
 {
 fwrite(nals->p_payload, i_frame_size, 1, fptr);
 }
 }

 std::cout << "\nAll done\n";
 std::cout << "Output video is example1.h264 and it is viewable in VLC";

 return 0;
}

int check_ret(int ret)
{
 if (ret != 0) {
 if (srs_h264_is_dvbsp_error(ret)) {
 srs_human_trace("ignoring drop video error, code=%d", ret);
 }
 else if (srs_h264_is_duplicated_sps_error(ret)) {
 srs_human_trace("ignoring duplicated sps, code=%d", ret);
 }
 else if (srs_h264_is_duplicated_pps_error(ret)) {
 srs_human_trace("ignoring duplicated pps, code=%d", ret);
 }
 else {
 srs_human_trace("sending h264 raw data failed. ret=%d", ret);
 return 0;
 }
 }
 return 1;
}
</sstream></iostream>


If you would like to download the original flower.bmp file, here is the link : https://gofile.io/d/w2kX56
This error can be reproduced in any other bmp file also.


Please tell me what is causing this problem when multi-threading is enabled. Am I setting wrong values ? Is the code in which I am streaming the encoded data wrong ?


-
JavaCV FFmpegFrameRecorder Video output reddish color
14 juin 2016, par Diego PerozoI am trying to make a video
.mp4
file out of a group of images using FFmpegFrameRecorder as a part of a bigger program, so I set up a test project in which I try to make a video out of 100 instances of the same frame at 25fps. The program seems to work. However, every time I run it the image seems to be reddish. As if a red filter had been applied to it.Here’s the code snippet :
public static void main(String[] args) {
File file = new File("C:/Users/Diego/Desktop/tc-images/image0.jpg");
BufferedImage img = null;
try {
img = ImageIO.read(file);
} catch (IOException e1) {
e1.printStackTrace();
}
IplImage image = IplImage.createFrom(img);
FFmpegFrameRecorder recorder = new FFmpegFrameRecorder("C:/Users/Diego/Desktop/tc-images/test.mp4",1920,1080);
try {
recorder.setVideoCodec(13);
recorder.setFormat("mp4");
recorder.setPixelFormat(0);
recorder.setFrameRate(25);
recorder.start();
for (int i=0;i<100;i++){
recorder.record(image);
}
recorder.stop();
}
catch (Exception e){
e.printStackTrace();
}
}I’d appreciate it if anybody told me what’s wrong. Thanks in advance for any help.
-
ffmpeg make slideshow with images and videos
6 avril 2020, par atticusI'm trying to make a slideshow with ffmpeg that should contain videos and images. Since as far as I know, ffmpeg cannot do this in one step (which would be of course the preferable step)
I'm breaking it up to make a slideshow of some images and concatenate the resulting video with another video.



The problem with this is that when making a slideshow with ffmpeg (like described here : https://trac.ffmpeg.org/wiki/Slideshow) the framerate is adjusted to make it possible to view one image for a longer time.



Now I've got multiple videos with different framerates to concatenate which is no good (I didn't got it working).



I also tried to make the slideshow with a higher framerate (with
-vf fps=25
) but I didn't got this working.


(since I have images from different locations/not all images of the current directory should be concatenated at once I really need to use the concat demuxer (as far as I know))



Does someone know how to do this right ?





What I already tried :



ffmpeg -safe 0 -f concat -i tmp -vsync vfr -pix_fmt yuv420p -vf fps=25 output.mkv




with a file tmp looking like this : (see the link above for reference)



file /path/to/file1.JPG
duration 2
file /path/to/file2.JPG
duration 2
file /path/to/file2.JPG




This gives me a video which somehow only the first image.





ffmpeg -safe 0 -f concat -i tmp -vsync vfr -pix_fmt yuv420p output.mkv




with a file tmp looking like this : (see the link above for reference)



file /path/to/file1.JPG
duration 2
file /path/to/file2.JPG
duration 2
file /path/to/file2.JPG




This gives me a file which shows all images at the right rate (everything right up to now) but I'm unable to concatenate it with the right video (25fps) with
ffmpeg -safe 0 -f concat -i <(printf "file ${PWD}/%s\n" "output.mkv" "video.mp4") -c copy out.mkv





EDIT : The main problem is the concatenation of these two Files :



$ mediainfo video2.MTS
General
ID : 1 (0x1)
Complete name : video2.MTS
Format : MPEG-TS
File size : 8.95 MiB
Duration : 8 s 240 ms
Overall bit rate mode : Variable
Overall bit rate : 9 024 kb/s
FileExtension_Invalid : ts m2t m2s m4t m4s tmf ts tp trp ty

Video
ID : 256 (0x100)
Menu ID : 1 (0x1)
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L4
Format settings : CABAC / 4 Ref Frames
Format settings, CABAC : Yes
Format settings, Reference frames : 4 frames
Codec ID : 27
Duration : 8 s 320 ms
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Variable
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Writing library : x264 core 159 r2991 1771b55
Encoding settings : 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

Audio
ID : 257 (0x101)
Menu ID : 1 (0x1)
Format : AAC LC
Format/Info : Advanced Audio Codec Low Complexity
Format version : Version 4
Muxing mode : ADTS
Codec ID : 15-2
Duration : 8 s 192 ms
Bit rate mode : Variable
Channel(s) : 2 channels
Channel layout : L R
Sampling rate : 48.0 kHz
Frame rate : 46.875 FPS (1024 SPF)
Compression mode : Lossy
Delay relative to video : -21 ms

Menu
ID : 4096 (0x1000)
Menu ID : 1 (0x1)
Duration : 8 s 240 ms
List : 256 (0x100) (AVC) / 257 (0x101) (AAC)
Service name : Service01
Service provider : FFmpeg
Service type : digital television




and



$ mediainfo output.mkv
General
Unique ID : 28406040384100140874396026026809692875 (0x155ECDEBB2C5FEFE07B31D86D8B512CB)
Complete name : output.mkv
Format : Matroska
Format version : Version 4
File size : 10.2 MiB
Duration : 6 s 83 ms
Overall bit rate : 14.0 Mb/s
Writing application : Lavf58.29.100
Writing library : Lavf58.29.100
ErrorDetectionType : Per level 1

Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L6
Format settings : CABAC / 4 Ref Frames
Format settings, CABAC : Yes
Format settings, Reference frames : 4 frames
Codec ID : V_MPEG4/ISO/AVC
Duration : 6 s 63 ms
Width : 5 184 pixels
Height : 3 888 pixels
Display aspect ratio : 4:3
Frame rate mode : Variable
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Writing library : x264 core 159 r2991 1771b55
Encoding settings : 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
Default : Yes
Forced : No

Audio
ID : 2
Format : AAC LC
Format/Info : Advanced Audio Codec Low Complexity
Codec ID : A_AAC-2
Duration : 6 s 83 ms
Channel(s) : 2 channels
Channel layout : L R
Sampling rate : 44.1 kHz
Frame rate : 43.066 FPS (1024 SPF)
Compression mode : Lossy
Writing library : Lavc58.54.100 aac
Default : Yes
Forced : No