
Recherche avancée
Autres articles (23)
-
Emballe Médias : Mettre en ligne simplement des documents
29 octobre 2010, parLe plugin emballe médias a été développé principalement pour la distribution mediaSPIP mais est également utilisé dans d’autres projets proches comme géodiversité par exemple. Plugins nécessaires et compatibles
Pour fonctionner ce plugin nécessite que d’autres plugins soient installés : CFG Saisies SPIP Bonux Diogène swfupload jqueryui
D’autres plugins peuvent être utilisés en complément afin d’améliorer ses capacités : Ancres douces Légendes photo_infos spipmotion (...) -
Encoding and processing into web-friendly formats
13 avril 2011, parMediaSPIP automatically converts uploaded files to internet-compatible formats.
Video files are encoded in MP4, Ogv and WebM (supported by HTML5) and MP4 (supported by Flash).
Audio files are encoded in MP3 and Ogg (supported by HTML5) and MP3 (supported by Flash).
Where possible, text is analyzed in order to retrieve the data needed for search engine detection, and then exported as a series of image files.
All uploaded files are stored online in their original format, so you can (...) -
Possibilité de déploiement en ferme
12 avril 2011, parMediaSPIP peut être installé comme une ferme, avec un seul "noyau" hébergé sur un serveur dédié et utilisé par une multitude de sites différents.
Cela permet, par exemple : de pouvoir partager les frais de mise en œuvre entre plusieurs projets / individus ; de pouvoir déployer rapidement une multitude de sites uniques ; d’éviter d’avoir à mettre l’ensemble des créations dans un fourre-tout numérique comme c’est le cas pour les grandes plate-formes tout public disséminées sur le (...)
Sur d’autres sites (4878)
-
Format video to upload on instagram API (Nodejs)
6 octobre 2022, par Rafael de CarvalhoI'm trying to automate the process of posting photos and videos on instagram but I constantly get errors when uploading to instagram.


I will leave a video duration error here but several others happen, I need to follow the following requirements :


- 

- Container : MOV or MP4 (MPEG-4 Part 14), no edit lists, atom moov in front of file
- Audio codec : AAC, 48 kHz maximum sampling rate, 1 or 2 channel (mono or stereo)
- Video codec : HEVC or H.264, progressive scan, closed GOP, 4:2:0 chroma subsampling
- Frame rate : from 23 to 60 FPS
- photo size :

- 

- Maximum columns (horizontal pixels) : 1,920
- Minimum aspect ratio [columns/rows] : 4/5
- Maximum aspect ratio [columns/rows] : 9/16








- Video bitrate : 5Mbps maximum VBR
- Audio bitrate : 128 kbps
- Duration : maximum 60 seconds and minimum 3 seconds
- File size : max 100 MB




















My code :


import { S3 } from 'aws-sdk';
import { IgApiClient } from 'instagram-private-api';
import fs from 'fs';

const s3 = new S3();
const ig = new IgApiClient();
const bucket = 'posts';
const { INSTA_USER, INSTA_PASS } = process.env;

ig.state.generateDevice(INSTA_USER);

export const main = async () => {
 try {
 await ig.account.login(INSTA_USER, INSTA_PASS);

 const { Contents } = await s3.listObjectsV2({ Bucket: bucket, MaxKeys: 2, Prefix: 'memes/geral' }).promise();

 const files = await Promise.all(Contents.map(async ({ Key }) => {
 const file = await s3.getObject({
 Bucket: bucket,
 Key,
 }).promise();

 return file.Body;
 }));

 const publishResult = await ig.publish.video({
 video: files[0],
 coverImage: await fs.readFileAsync("../../src/assets/cover.png")
 });

 console.dir({ publishResult }, { depth: null })
 } catch (error) {
 console.error(error);
 throw error;
 }
}



When I get a file from s3, it comes in the following format.
I'm taking the content of the body property and put it in the video property of the publish method.
Is it right ?
I also tried to save the file with fs.writeFile and dps use readFileSync like in the example but it also gave the same error.


{
 AcceptRanges: 'bytes',
 LastModified: 2022-08-04T23:15:24.000Z,
 ContentLength: 3252472,
 ETag: '"c491cfe2fb5bc29777fc34391fc1d56a"',
 ContentType: 'application/octet-stream',
 Body: Buffer(3252472) [Uint8Array] [
 0, 0, 0, 32, 102, 116, 121, 112, 105, 115, 111, 109,
 0, 0, 2, 0, 105, 115, 111, 109, 105, 115, 111, 50,
 97, 118, 99, 49, 109, 112, 52, 49, 0, 0, 209, 0,
 109, 111, 111, 118, 0, 0, 0, 108, 109, 118, 104, 100,
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 0, 0, 3, 232, 0, 0, 250, 17, 0, 1, 0, 0,
 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 0, 0, 0, 0,
 ... 3252372 more items
 ]
 }



Error :


{
 "errorMessage": "POST /api/v1/media/upload_finish/?video=1 - 400 Bad Request; server processing error: VideoSourceDurationCheckException",
 "errorType": "IgUploadVideoError",
 "stackTrace": [
 "IgUploadVideoError: POST /api/v1/media/upload_finish/?video=1 - 400 Bad Request; server processing error: VideoSourceDurationCheckException",
 " at C:\\Users\\User\\Desktop\\dev\\Insta\\.webpack\\service\\src\\functions\\webpack:\\instagram-private-api\\dist\\services\\publish.service.js:26:1", 
 " at tryCatcher (C:\\Users\\User\\Desktop\\dev\\Insta\\.webpack\\service\\src\\functions\\webpack:\\bluebird\\js\\release\\util.js:16:1)"
}



when I try to post a video under 60 seconds (apparently within the requirements) :


{
 "errorMessage": "POST /api/v1/media/configure/?video=1 - 403 Forbidden; ",
 "errorType": "IgConfigureVideoError",
 "stackTrace": [
 "IgConfigureVideoError: POST /api/v1/media/configure/?video=1 - 403 Forbidden; ",
 " at PublishService.video (C:\\Users\\User\\Desktop\\dev\\Insta\\.webpack\\service\\src\\functions\\webpack:\\instagram-private-api\\dist\\services\\publish.service.js:123:1)", 
 " at C:\\Users\\User\\Desktop\\dev\\Insta\\.webpack\\service\\src\\functions\\webpack:\\src\\functions\\cronFreefireMemes.js:71:31",
 " at async Promise.all (index 1)",
 " at main (C:\\Users\\User\\Desktop\\dev\\Insta\\.webpack\\service\\src\\functions\\webpack:\\src\\functions\\cronFreefireMemes.js:47:5)"
 ]
}



I know that the error above is happening because of the size of the video which is longer than 60 seconds.


But I would like to know if there is any way I can format any video to fit the instagram requirements.


Any nodejs library ?


-
FFMPEG(Libav)-Creating AVpackets from Network Packets(TCP) Using av_parser_parse2() Function
21 août 2022, par Batuhan ZorluI am developing one software that takes frames using OpenCV then sends them over network. I was using RTMP protocol for that, i have created one middle rtmp server and solved it.However, i had to solve the problem using TCP. On the sender side I do not face any problem, i can smoothly convert From cv::Mat-> AVframe->Avpacket and send it over network.
However, on the receiver side, i can not create AVframes.
This is my sender code(dont have any issue, it sends over TCP AS EXPECTED) :


void write_frame(AVCodecContext *codec_ctx, AVFormatContext *fmt_ctx, AVFrame *frame)
{
AVPacket pkt = { 0 };
av_new_packet(&pkt, 0);

int ret = avcodec_send_frame(codec_ctx, frame);
if (ret < 0)
{
 std::cout << "Error sending frame to codec context!" << std::endl;
 exit(1);
}

ret = avcodec_receive_packet(codec_ctx, &pkt);
if (ret < 0)
{
 std::cout << "Error receiving packet from codec context!" << std::endl;
 exit(1);
}
av_interleaved_write_frame(fmt_ctx, &pkt);
av_packet_unref(&pkt);
}

void stream_video(double width, double height, int fps, int camID, int bitrate, std::string 
codec_profile, std::string server)
{
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100)
av_register_all();
#endif
avformat_network_init();

const char *output = server.c_str();
int ret;
auto cam = get_device(camID, width, height);
std::vector imgbuf(height * width * 3 + 16);
cv::Mat image(height, width, CV_8UC3, imgbuf.data(), width * 3);
AVFormatContext *ofmt_ctx = nullptr;
AVCodec *out_codec = nullptr;
AVStream *out_stream = nullptr;
AVCodecContext *out_codec_ctx = nullptr;

initialize_avformat_context(ofmt_ctx, "flv");
initialize_io_context(ofmt_ctx, output);

out_codec = const_cast(avcodec_find_encoder(AV_CODEC_ID_H264));
out_stream = avformat_new_stream(ofmt_ctx, out_codec);
out_codec_ctx = avcodec_alloc_context3(out_codec);

set_codec_params(ofmt_ctx, out_codec_ctx, width, height, fps, bitrate);
initialize_codec_stream(out_stream, out_codec_ctx, (out_codec), codec_profile);

out_stream->codecpar->extradata = out_codec_ctx->extradata;
out_stream->codecpar->extradata_size = out_codec_ctx->extradata_size;

av_dump_format(ofmt_ctx, 0, output, 1);

auto *swsctx = initialize_sample_scaler(out_codec_ctx, width, height);
auto *frame = allocate_frame_buffer(out_codec_ctx, width, height);

int cur_size;
uint8_t *cur_ptr;

ret = avformat_write_header(ofmt_ctx, nullptr);
if (ret < 0)
{
 std::cout << "Could not write header!" << std::endl;
 exit(1);
}

bool end_of_stream = false;
do
{
 cam >> image;
 const int stride[] = { static_cast<int>(image.step[0]) };
 sws_scale(swsctx, &image.data, stride, 0, image.rows, frame->data, frame->linesize);
 frame->pts += av_rescale_q(1, out_codec_ctx->time_base, out_stream->time_base);
 write_frame(out_codec_ctx, ofmt_ctx, frame);
} while (!end_of_stream);

av_write_trailer(ofmt_ctx);

av_frame_free(&frame);
avcodec_close(out_codec_ctx);
avio_close(ofmt_ctx->pb);
avformat_free_context(ofmt_ctx);
}
</int>


This is my receiver code that i have too many questions :


1.av_parser_parse2(acpc, out_codec_ctx, &pkt_demo->data, &out_buff_size, (uint8_t*)buffer_data, buffer_size, AV_NOPTS_VALUE, AV_NOPTS_VALUE, 0).


As i understand, this function takes bytes untill it can create AVpacket.(In my case this function for twice, in the first one reads as big as my buffer size (4096), at the second one it reads about 2900, then goes the decoding line.)
My questions about this function,
It takes AVpacket.pts, AVpacket.dst and AVpacket.pos but, while i am receiving some bytes how can I pass those variables.(I am already trying to fill AVpacket).
After passing this function, i am having error in int response = avcodec_send_packet(pCodecContext, pPacket), line. The error :The error
And sometimes getting this error :The error-2


////////CONFIG CODEC CONTEXT

avcodec_open2(out_codec_ctx, out_codec, NULL);

////////PARSER INITIALIZATION
AVCodecParserContext * acpc = av_parser_init(AV_CODEC_ID_H264);
uint8_t* out_buff;
int out_buff_size;

////////PARSER INITIALIZATION
size_t buffer_size = 4096;
uint8_t* buffer_data = new uint8_t[buffer_size];
//AVPacket pkt_demo;

AVPacket *pkt_demo = av_packet_alloc();
AVFrame *pFrame = av_frame_alloc();
int response = 0;



while (recv(ClientSocket, (char*)buffer_data, buffer_size, 0) > 0) {
 int len = av_parser_parse2(acpc, out_codec_ctx, &pkt_demo->data, &out_buff_size, 
(uint8_t*)buffer_data, buffer_size, pkt_demo->pts, pkt_demo->dts, -1);
 std::cout << "READING!!!!" << std::endl;
 if (out_buff_size > 0) {
 std::cout << "started!!!!" << std::endl;
 //pkt_demo->data = out_buff;
 pkt_demo->size = out_buff_size;
 response = decode_packet(pkt_demo, out_codec_ctx, pFrame);
 if (response < 0)break;
 }
 av_packet_unref(pkt_demo);
}
delete[] buffer_data;

static int decode_packet(AVPacket *pPacket, AVCodecContext *pCodecContext, AVFrame *pFrame)
{


int response = avcodec_send_packet(pCodecContext, pPacket);
std::cout << response << std::endl;

if (response < 0) {

 return response;
}

while (response >= 0)
{
 response = avcodec_receive_frame(pCodecContext, pFrame);
 if (response == AVERROR(EAGAIN) || response == AVERROR_EOF) {
 break;
 }
 else if (response < 0) {

 return response;
 }

}
return 0;
}



In addition to that, i have checked the CodecContext, i have hardcoded every property on the receiver side, so they are the same.(Which also thisis another thing that confuses me, because AVpacket should have already have the context information right ?)


-
About "ffmpeg -c copy" two ts files, can not play the problem
4 septembre 2022, par Orlando Bloomaaa.mp4


General
Complete name : C:/aaa.mp4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom (isom/iso2/avc1/mp41)
File size : 3.08 MiB
Duration : 11 s 512 ms
Overall bit rate : 2 248 kb/s
Writing application : Lavf57.83.100
Comment : GIFSHOW [899819595][iOS][11.4.1][iPhone9,2][5.8.5.606][Camera:f]#[720x1280][5327k][78k][C][1][tv=bec1_f80c][ags=0.455141][agm=0.747282][agsi=2000]

Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L3.1
Format settings : CABAC / 4 Ref Frames
Format settings, CABAC : Yes
Format settings, Reference frames : 4 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 11 s 512 ms
Bit rate : 2 161 kb/s
Width : 720 pixels
Height : 1 280 pixels
Display aspect ratio : 0.563
Frame rate mode : Constant
Frame rate : 29.970 (29970/1000) FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.078
Stream size : 2.96 MiB (96%)
Writing library : x264 core 148
Codec configuration box : avcC

Audio
ID : 2
Format : AAC LC SBR
Format/Info : Advanced Audio Codec Low Complexity with Spectral Band Replication
Commercial name : HE-AAC
Format settings : Explicit
Codec ID : mp4a-40-2
Duration : 11 s 501 ms
Bit rate mode : Constant
Bit rate : 78.8 kb/s
Channel(s) : 2 channels
Channel layout : L R
Sampling rate : 44.1 kHz
Frame rate : 21.533 FPS (2048 SPF)
Compression mode : Lossy
Stream size : 111 KiB (4%)
Default : Yes
Alternate group : 1





I want to merge this mp4 with another ts file, because my hardware configuration is very poor, so I choose "-c copy"


General
ID : 1 (0x1)
Complete name : C:/bbb.ts
Format : MPEG-TS
File size : 3.41 MiB
Duration : 15 s 315 ms
Overall bit rate mode : Variable
Overall bit rate : 1 861 kb/s

Video
ID : 256 (0x100)
Menu ID : 1 (0x1)
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L3.1
Format settings : CABAC / 4 Ref Frames
Format settings, CABAC : Yes
Format settings, Reference frames : 4 frames
Codec ID : 27
Duration : 15 s 382 ms
Width : 1 080 pixels
Height : 606 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

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 : 15 s 185 ms
Bit rate mode : Variable
Channel(s) : 1 channel
Channel layout : C
Sampling rate : 44.1 kHz
Frame rate : 43.066 FPS (1024 SPF)
Compression mode : Lossy
Delay relative to video : -46 ms






I directly -c copy them, can't play the whole thing,


Then I convert aaa.mp4 to ts
using "ffmpeg -i aaa.mp4 -bsf:v h264_mp4toannexb -codec copy -hls_list_size 0 aaa.ts" , this is what I googled.


Finally tried aaa.ts and bbb.ts with "-c copy", still can't play.


My machine configuration is acceptable, convert aaa.mp4 to the same encoding as bbb.ts


If I transcode both together, I can't do it because bbb.ts is too big.