
Recherche avancée
Autres articles (38)
-
Websites made with MediaSPIP
2 mai 2011, parThis page lists some websites based on MediaSPIP.
-
Creating farms of unique websites
13 avril 2011, parMediaSPIP platforms can be installed as a farm, with a single "core" hosted on a dedicated server and used by multiple websites.
This allows (among other things) : implementation costs to be shared between several different projects / individuals rapid deployment of multiple unique sites creation of groups of like-minded sites, making it possible to browse media in a more controlled and selective environment than the major "open" (...) -
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
Sur d’autres sites (8001)
-
How to get 20 screenshots from a video with tile or mosiac effect ffmpeg ?
2 octobre 2019, par NaneI am trying to get 20(Will take screens at 5%, 10%, 15%, 20%,.., of the video) screenshot which will be arranged in a single image like this Link
I found this command but it is taking screenshot based on frames like 1000 I want to get evenly distributed 20 screenshots of the entire video
ffmpeg -ss 00:00:10 -i movie.avi -frames 1 -vf "select=not(mod(n\,1000)),scale=320:240,tile=2x3" out.png
-
Send AVPacket over Network
2 décembre 2019, par YondonatorI’m generating AVPackets with an encoder with ffmpeg and now I want to send them with UDP to another Computer and show them there.
The problem is I don’t know how to convert the packet to bytes and back. I tried this to copy the package :AVPacket newPacket = avcodec.av_packet_alloc();
ByteBuffer byteBuffer = packet.buf().buffer().asByteBuffer();
int bufferSize = byteBuffer.capacity();
byte bytes[] = new byte[bufferSize];
byteBuffer.get(bytes);
AVBufferRef newBufferRef = avutil.av_buffer_alloc(bufferSize);
newBufferRef.data(new BytePointer(bytes));
newPacket.buf(newBufferRef);
ByteBuffer dataBuffer = packet.data().asByteBuffer();
int dataSize = dataBuffer.capacity();
byte dataBytes[] = new byte[dataSize];
dataBuffer.get(dataBytes);
BytePointer dataPointer = new BytePointer(dataBytes);
newPacket.data(dataPointer);
newPacket.dts(packet.dts());
newPacket.duration(packet.duration());
newPacket.flags(packet.flags());
newPacket.pos(packet.pos());
newPacket.pts(packet.pts());
newPacket.side_data_elems(0);
newPacket.size(packet.size());
newPacket.stream_index(packet.stream_index());
videoPlayer.sendPacket(newPacket);This gives me this Error :
[h264 @ 0000018951be8440] Invalid NAL unit size (3290676 > 77).
[h264 @ 0000018951be8440] Error splitting the input into NAL units.
[h264 @ 0000018951bf6480] Invalid NAL unit size (15305314 > 163).
[h264 @ 0000018951bf6480] Error splitting the input into NAL units.The problem is
newPacket.data()
. When I set it directly :newPacket.data(packet.data())
it works. Alsopacket.data().asByteBuffer().capacity()
returns 1 andpacket.data().capacity()
returns 0.This is my method that creates the decoder :
private void startUnsafe() throws Exception
{
int result;
convertContext = null;
codec = null;
codecContext = null;
AVFrame = null;
RGBAVFrame = null;
frame = new Frame();
codec = avcodec_find_decoder(codecID);
if(codec == null)
{
throw new Exception("Unable to find decoder");
}
codecContext = avcodec_alloc_context3(codec);
if(codecContext == null)
{
releaseUnsafe();
throw new Exception("Unable to alloc codec context!");
}
AVCodecParameters para = avcodec_parameters_alloc();
para.bit_rate(streamBitrate);
para.width(streamWidth);
para.height(streamHeight);
para.codec_id(codecID);
para.codec_type(AVMEDIA_TYPE_VIDEO);
try
{
byte extradataByte[] = Files.readAllBytes(new File("extradata.byte").toPath());
para.extradata(new BytePointer(extradataByte));
para.extradata_size(extradataByte.length);
}
catch (IOException e1)
{
e1.printStackTrace();
throw new Exception("extradata file not available");
}
result = avcodec_parameters_to_context(codecContext, para);
if(result < 0)
{
throw new Exception("Unable to copy parameters to context! [" + result + "]");
}
codecContext.thread_count(0);
result = avcodec_open2(codecContext, codec, new AVDictionary());
if(result < 0)
{
releaseUnsafe();
throw new Exception("Unable to open codec context![" + result + "]");
}
AVFrame = av_frame_alloc();
if(AVFrame == null)
{
releaseUnsafe();
throw new Exception("Unable to alloc AVFrame!");
}
RGBAVFrame = av_frame_alloc();
if(RGBAVFrame == null)
{
releaseUnsafe();
throw new Exception("Unable to alloc AVFrame!");
}
initRGBAVFrame();
TimerTask task = new TimerTask() {
@Override
public void run()
{
timerTask();
}
};
timer = new Timer();
timer.scheduleAtFixedRate(task, 0, (long) (1000/streamFramerateDouble));
window.setVisible(true);
}The file extradata.byte has some bytes that I got from another video, because without them it doesn’t work too.
EDIT :
package org.stratostream.streaming;
import java.nio.ByteBuffer;
import org.bytedeco.javacpp.BytePointer;
import org.bytedeco.javacpp.Pointer;
import org.bytedeco.javacpp.avcodec;
import org.bytedeco.javacpp.avutil;
import org.bytedeco.javacpp.avcodec.AVPacket;
import org.bytedeco.javacpp.avcodec.AVPacketSideData;
public class PacketIO {
public static final int SIDE_DATA_FIELD = 0;
public static final int SIDE_ELEMENTS_FIELD = 4;
public static final int SIDE_TYPE_FIELD = 8;
public static final int DTS_FIELD = 12;
public static final int PTS_FIELD = 20;
public static final int FLAGS_FIELD = 28;
public static final int DATA_OFFSET = 32;
public static byte[] toByte(AVPacket packet) throws Exception
{
int dataSize = packet.size();
ByteBuffer dataBuffer = packet.data().capacity(dataSize).asByteBuffer();
byte dataBytes[] = new byte[dataSize];
dataBuffer.get(dataBytes);
AVPacketSideData sideData = packet.side_data();
int sideSize = sideData.size();
ByteBuffer sideBuffer = sideData.data().capacity(sideSize).asByteBuffer();
byte sideBytes[] = new byte[sideSize];
sideBuffer.get(sideBytes);
int sideOffset = DATA_OFFSET + dataSize;
int resultSize = sideOffset + sideSize;
byte resultBytes[] = new byte[resultSize];
System.arraycopy(dataBytes, 0, resultBytes, DATA_OFFSET, dataSize);
System.arraycopy(sideBytes, 0, resultBytes, sideOffset, sideSize);
resultBytes[SIDE_DATA_FIELD] = (byte) (sideOffset >>> 24);
resultBytes[SIDE_DATA_FIELD+1] = (byte) (sideOffset >>> 16);
resultBytes[SIDE_DATA_FIELD+2] = (byte) (sideOffset >>> 8);
resultBytes[SIDE_DATA_FIELD+3] = (byte) (sideOffset >>> 0);
int sideType = sideData.type();
intToByte(resultBytes, SIDE_TYPE_FIELD, sideType);
int sideElements = packet.side_data_elems();
intToByte(resultBytes, SIDE_ELEMENTS_FIELD, sideElements);
long dts = packet.dts();
longToByte(resultBytes, DTS_FIELD, dts);
long pts = packet.pts();
longToByte(resultBytes, PTS_FIELD, pts);
int flags = packet.flags();
intToByte(resultBytes, FLAGS_FIELD, flags);
return resultBytes;
}
public static AVPacket toPacket(byte bytes[]) throws Exception
{
AVPacket packet = avcodec.av_packet_alloc();
int sideOffset = byteToInt(bytes, SIDE_DATA_FIELD);
int sideElements = byteToInt(bytes, SIDE_ELEMENTS_FIELD);
int sideType = byteToInt(bytes, SIDE_TYPE_FIELD);
int dataSize = sideOffset - DATA_OFFSET;
int sideSize = bytes.length - sideOffset;
long pts = byteToLong(bytes, PTS_FIELD);
long dts = byteToLong(bytes, DTS_FIELD);
int flags = byteToInt(bytes, FLAGS_FIELD);
packet.pts(pts);
packet.dts(dts);
packet.flags(flags);
Pointer newDataPointer = avutil.av_malloc(bytes.length);
BytePointer dataPointer = new BytePointer(newDataPointer);
byte dataBytes[] = new byte[dataSize];
System.arraycopy(bytes, DATA_OFFSET, dataBytes, 0, dataSize);
dataPointer.put(dataBytes);
packet.data(dataPointer);
packet.size(dataSize);
Pointer newSidePointer = avutil.av_malloc(sideSize);
BytePointer sidePointer = new BytePointer(newSidePointer);
byte sideBytes[] = new byte[sideSize];
System.arraycopy(bytes, sideOffset, sideBytes, 0, sideSize);
sidePointer.put(sideBytes);
AVPacketSideData sideData = new AVPacketSideData();
sideData.data(sidePointer);
sideData.type(sideType);
sideData.size(sideSize);
//packet.side_data(sideData);
//packet.side_data_elems(sideElements);
return packet;
}
private static void intToByte(byte[] bytes, int offset, int value)
{
bytes[offset] = (byte) (value >>> 24);
bytes[offset+1] = (byte) (value >>> 16);
bytes[offset+2] = (byte) (value >>> 8);
bytes[offset+3] = (byte) (value >>> 0);
}
private static void longToByte(byte[] bytes, int offset, long value)
{
bytes[offset] = (byte) (value >>> 56);
bytes[offset+1] = (byte) (value >>> 48);
bytes[offset+2] = (byte) (value >>> 40);
bytes[offset+3] = (byte) (value >>> 32);
bytes[offset+4] = (byte) (value >>> 24);
bytes[offset+5] = (byte) (value >>> 16);
bytes[offset+6] = (byte) (value >>> 8);
bytes[offset+7] = (byte) (value >>> 0);
}
private static int byteToInt(byte[] bytes, int offset)
{
return (bytes[offset]<<24)&0xff000000|(bytes[offset+1]<<16)&0x00ff0000|(bytes[offset+2]<<8)&0x0000ff00|(bytes[offset+3]<<0)&0x000000ff;
}
private static long byteToLong(byte[] bytes, int offset)
{
return (bytes[offset]<<56)&0xff00000000000000L|(bytes[offset+1]<<48)&0x00ff000000000000L|(bytes[offset+2]<<40)&0x0000ff0000000000L|(bytes[offset+3]<<32)&0x000000ff00000000L|(bytes[offset+4]<<24)&0x00000000ff000000L|(bytes[offset+5]<<16)&0x0000000000ff0000L|(bytes[offset+6]<<8)&0x000000000000ff00L|(bytes[offset+7]<<0)&0x00000000000000ffL;
}
}Now I have this class that works fine on the same programm, but when I send the bytes over the network I get a bad output and this error is printed to the console :
[h264 @ 00000242442acc40] Missing reference picture, default is 72646
[h264 @ 000002424089de00] Missing reference picture, default is 72646
[h264 @ 000002424089e3c0] mmco: unref short failure
[h264 @ 000002424081a580] reference picture missing during reorder
[h264 @ 000002424081a580] Missing reference picture, default is 72652
[h264 @ 000002424082c400] mmco: unref short failure
[h264 @ 000002424082c400] co located POCs unavailable
[h264 @ 000002424082c9c0] co located POCs unavailable
[h264 @ 00000242442acc40] co located POCs unavailable
[h264 @ 000002424089de00] mmco: unref short failureI think its because I dont set the sidedata field but when I try to set it the encoder crashes with the second packet.
The output looks like this :
Decoder Output -
how to solve ffmpeg video merging complain about parameters mismatching
22 septembre 2019, par mohammad rostami siahgeliI’m trying to concatenate an intro video to a main video. Here’s my command :
ffmpeg -i C:\Temp\intro.mp4 -i C:\Temp\main.mp4 -filter_complex "[0:v:0][0:a:0][1:v:0][1:a:0]concat=n=2:v=1:a=1[outv][outa]" -map "[outv]" -map "[outa]" C:\Temp\output.mp4
When I run this command in cmd, I get the following error :
ffmpeg version N-95004-g2f87c9f646 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 9.2.1 (GCC) 20190918
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
libavutil 56. 35.100 / 56. 35.100
libavcodec 58. 58.101 / 58. 58.101
libavformat 58. 33.100 / 58. 33.100
libavdevice 58. 9.100 / 58. 9.100
libavfilter 7. 58.102 / 7. 58.102
libswscale 5. 6.100 / 5. 6.100
libswresample 3. 6.100 / 3. 6.100
libpostproc 55. 6.100 / 55. 6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Temp\intro.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42mp41
creation_time : 2019-09-21T09:23:34.000000Z
Duration: 00:00:07.32, start: 0.000000, bitrate: 706 kb/s
Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, smpte170m), 960x540, 323 kb/s, 15 fps, 15 tbr, 30k tbn, 30 tbc (default)
Metadata:
creation_time : 2019-09-21T09:23:34.000000Z
handler_name : ?Mainconcept Video Media Handler
encoder : AVC Coding
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 317 kb/s (default)
Metadata:
creation_time : 2019-09-21T09:23:34.000000Z
handler_name : #Mainconcept MP4 Sound Media Handler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Temp\main.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.40.101
Duration: 00:00:08.78, start: 0.000000, bitrate: 499 kb/s
Stream #1:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 640x640 [SAR 1:1 DAR 1:1], 430 kb/s, 29.97 fps, 29.97 tbr, 11988 tbn, 59.94 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 64 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream mapping:
Stream #0:0 (h264) -> concat:in0:v0
Stream #0:1 (aac) -> concat:in0:a0
Stream #1:0 (h264) -> concat:in1:v0
Stream #1:1 (aac) -> concat:in1:a0
concat:out:v0 -> Stream #0:0 (libx264)
concat:out:a0 -> Stream #0:1 (aac)
Press [q] to stop, [?] for help
[Parsed_concat_0 @ 0000018168eedec0] Input link in0:v0 parameters (size 640x640, SAR 1:1) do not match the corresponding output link in0:v0 parameters (960x540, SAR 1:1)
[Parsed_concat_0 @ 0000018168eedec0] Failed to configure output pad on Parsed_concat_0
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #1:0
Conversion failed!I’m not a video ninja. I know parameters are different, but I have no idea after hours of search on how to solve this. A lot of online video services concatenate these two videos and give me a reasonable result. They have a GUI though. I need to do it in code, so that I can automate it.
How can I solve these errors ?
Update : This is the second error :
ffmpeg version N-95004-g2f87c9f646 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 9.2.1 (GCC) 20190918
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
libavutil 56. 35.100 / 56. 35.100
libavcodec 58. 58.101 / 58. 58.101
libavformat 58. 33.100 / 58. 33.100
libavdevice 58. 9.100 / 58. 9.100
libavfilter 7. 58.102 / 7. 58.102
libswscale 5. 6.100 / 5. 6.100
libswresample 3. 6.100 / 3. 6.100
libpostproc 55. 6.100 / 55. 6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Temp\intro.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42mp41
creation_time : 2019-09-21T09:23:34.000000Z
Duration: 00:00:07.32, start: 0.000000, bitrate: 706 kb/s
Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, smpte170m), 960x540, 323 kb/s, 15 fps, 15 tbr, 30k tbn, 30 tbc (default)
Metadata:
creation_time : 2019-09-21T09:23:34.000000Z
handler_name : ?Mainconcept Video Media Handler
encoder : AVC Coding
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 317 kb/s (default)
Metadata:
creation_time : 2019-09-21T09:23:34.000000Z
handler_name : #Mainconcept MP4 Sound Media Handler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Temp\main.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.40.101
Duration: 00:00:08.78, start: 0.000000, bitrate: 499 kb/s
Stream #1:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 640x640 [SAR 1:1 DAR 1:1], 430 kb/s, 29.97 fps, 29.97 tbr, 11988 tbn, 59.94 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 64 kb/s (default)
Metadata:
handler_name : SoundHandler
File 'C:\Temp\output.mp4' already exists. Overwrite ? [y/N] Y
Stream mapping:
Stream #0:0 (h264) -> scale
Stream #0:1 (aac) -> concat:in0:a0
Stream #1:0 (h264) -> concat:in1:v0
Stream #1:1 (aac) -> concat:in1:a0
concat:out:v0 -> Stream #0:0 (libx264)
concat:out:a0 -> Stream #0:1 (aac)
Press [q] to stop, [?] for help
[mp4 @ 000002f17869d7c0] Frame rate very high for a muxer not efficiently supporting it.
Please consider specifying a lower framerate, a different muxer or -vsync 2
[libx264 @ 000002f178acfec0] using SAR=1/1
[libx264 @ 000002f178acfec0] MB rate (1600000000) > level limit (16711680)
[libx264 @ 000002f178acfec0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 000002f178acfec0] profile High, level 6.2, 4:2:0, 8-bit
[libx264 @ 000002f178acfec0] 264 - core 158 r2984 3759fcb - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 - 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=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
More than 1000 frames duplicated
Too many packets buffered for output stream 0:0.
[libx264 @ 000002f178acfec0] frame I:1 Avg QP:16.45 size: 4679
[libx264 @ 000002f178acfec0] frame P:32 Avg QP:14.16 size: 33
[libx264 @ 000002f178acfec0] frame B:96 Avg QP:17.67 size: 30
[libx264 @ 000002f178acfec0] consecutive B-frames: 0.8% 0.0% 0.0% 99.2%
[libx264 @ 000002f178acfec0] mb I I16..4: 58.1% 34.8% 7.1%
[libx264 @ 000002f178acfec0] mb P I16..4: 0.1% 0.0% 0.0% P16..4: 0.0% 0.0% 0.0% 0.0% 0.0% skip:99.9%
[libx264 @ 000002f178acfec0] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 0.8% 0.0% 0.0% direct: 0.0% skip:99.2% L0: 0.0% L1:100.0% BI: 0.0%
[libx264 @ 000002f178acfec0] 8x8 transform intra:33.8%
[libx264 @ 000002f178acfec0] coded y,uvDC,uvAC intra: 4.6% 8.2% 7.3% inter: 0.0% 0.0% 0.0%
[libx264 @ 000002f178acfec0] i16 v,h,dc,p: 74% 22% 5% 0%
[libx264 @ 000002f178acfec0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 1% 16% 83% 0% 0% 0% 0% 0% 0%
[libx264 @ 000002f178acfec0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 24% 17% 26% 7% 5% 5% 5% 6% 5%
[libx264 @ 000002f178acfec0] i8c dc,h,v,p: 93% 3% 3% 1%
[libx264 @ 000002f178acfec0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 000002f178acfec0] ref P L0: 62.5% 37.5%
[libx264 @ 000002f178acfec0] ref B L1: 99.8% 0.2%
[libx264 @ 000002f178acfec0] kb/s:535069.75
Conversion failed!