
Recherche avancée
Médias (91)
-
Les Miserables
9 décembre 2019, par
Mis à jour : Décembre 2019
Langue : français
Type : Textuel
-
VideoHandle
8 novembre 2019, par
Mis à jour : Novembre 2019
Langue : français
Type : Video
-
Somos millones 1
21 juillet 2014, par
Mis à jour : Juin 2015
Langue : français
Type : Video
-
Un test - mauritanie
3 avril 2014, par
Mis à jour : Avril 2014
Langue : français
Type : Textuel
-
Pourquoi Obama lit il mes mails ?
4 février 2014, par
Mis à jour : Février 2014
Langue : français
-
IMG 0222
6 octobre 2013, par
Mis à jour : Octobre 2013
Langue : français
Type : Image
Autres articles (41)
-
XMP PHP
13 mai 2011, parDixit Wikipedia, XMP signifie :
Extensible Metadata Platform ou XMP est un format de métadonnées basé sur XML utilisé dans les applications PDF, de photographie et de graphisme. Il a été lancé par Adobe Systems en avril 2001 en étant intégré à la version 5.0 d’Adobe Acrobat.
Étant basé sur XML, il gère un ensemble de tags dynamiques pour l’utilisation dans le cadre du Web sémantique.
XMP permet d’enregistrer sous forme d’un document XML des informations relatives à un fichier : titre, auteur, historique (...) -
Mise à jour de la version 0.1 vers 0.2
24 juin 2013, parExplications des différents changements notables lors du passage de la version 0.1 de MediaSPIP à la version 0.3. Quelles sont les nouveautés
Au niveau des dépendances logicielles Utilisation des dernières versions de FFMpeg (>= v1.2.1) ; Installation des dépendances pour Smush ; Installation de MediaInfo et FFprobe pour la récupération des métadonnées ; On n’utilise plus ffmpeg2theora ; On n’installe plus flvtool2 au profit de flvtool++ ; On n’installe plus ffmpeg-php qui n’est plus maintenu au (...) -
Ajout d’utilisateurs manuellement par un administrateur
12 avril 2011, parL’administrateur d’un canal peut à tout moment ajouter un ou plusieurs autres utilisateurs depuis l’espace de configuration du site en choisissant le sous-menu "Gestion des utilisateurs".
Sur cette page il est possible de :
1. décider de l’inscription des utilisateurs via deux options : Accepter l’inscription de visiteurs du site public Refuser l’inscription des visiteurs
2. d’ajouter ou modifier/supprimer un utilisateur
Dans le second formulaire présent un administrateur peut ajouter, (...)
Sur d’autres sites (4033)
-
How can I test and know what is the latency of streaming with ffmpeg ?
1er octobre 2017, par Davis8988I am using ffmpeg to stream a window of an app to another computer.
How can I measure/check/get/see exact value of latency ?Here is the script I use :
ffmpeg -y -rtbufsize 100M -f gdigrab -framerate 25 -probsize 100M -i
title="App Name" -c:v libx264 -r 25 -preset ultrafast -tune zerolatency
-crf 25 -f mpegts udp://30.30.2.38:1080And here is the script I use to capture it with ffplay on receiving computer :
ffplay -fflags nobuffer -sync ext udp://30.30.2.38:1080
-
FFmpeg : Green images from TS file
5 septembre 2017, par TatsianaI use ffmpeg to generate images from a TS file and at some places it generates green images. I checked a couple of ffmpeg versions. The issue reproduces on
3.3.3, 2.8.11, 2.7.7, but doesn’t on 2.6.9.
What might be the reason ?For example, the output of 2.8.11 :
$ ffmpeg -ss 00:42:20 -i video.ts -frames:v 1 out_42_20.jpg -loglevel debug ffmpeg version 2.8.11-0ubuntu0.16.04.1 Copyright (c) 2000-2017 the FFmpeg developers built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1 16.04.4) 20160609 configuration : —prefix=/usr —extra-version=0ubuntu0.16.04.1 —build-suffix=-ffmpeg —toolchain=hardened —libdir=/usr/lib/x86_64-linux-=/usr/include/x86_64-linux-gnu —cc=cc —cxx=g++ —enable-gpl —enable-shared —disable-stripping —disable-decoder=libopenjpeg —disable-dhroedinger —enable-avresample —enable-avisynth —enable-gnutls —enable-ladspa —enable-libass —enable-libbluray —enable-libbs2b —enab-enable-libcdio —enable-libflite —enable-libfontconfig —enable-libfreetype —enable-libfribidi —enable-libgme —enable-libgsm —enable—enable-libmp3lame —enable-libopenjpeg —enable-libopus —enable-libpulse —enable-librtmp —enable-libschroedinger —enable-libshine —enpy —enable-libsoxr —enable-libspeex —enable-libssh —enable-libtheora —enable-libtwolame —enable-libvorbis —enable-libvpx —enable-linable-libwebp —enable-libx265 —enable-libxvid —enable-libzvbi —enable-openal —enable-opengl —enable-x11grab —enable-libdc1394 —enab83 —enable-libzmq —enable-frei0r —enable-libx264 —enable-libopencv libavutil 54. 31.100 / 54. 31.100 libavcodec 56. 60.100 / 56. 60.100 libavformat 56. 40.101 / 56. 40.101 libavdevice 56. 4.100 / 56. 4.100 libavfilter 5. 40.101 / 5. 40.101 libavresample 2. 1. 0 / 2. 1. 0 libswscale 3. 1.101 / 3. 1.101 libswresample 1. 2.101 / 1. 2.101 libpostproc 53. 3.100 / 53. 3.100 Splitting the commandline. Reading option ’-ss’ ... matched as option ’ss’ (set the start time offset) with argument ’00:42:20’. Reading option ’-i’ ... matched as input url with argument ’video.ts’. Reading option ’-frames:v’ ... matched as option ’frames’ (set the number of frames to output) with argument ’1’. Reading option ’out_42_20.jpg’ ... matched as output url. Reading option ’-loglevel’ ... matched as option ’loglevel’ (set logging level) with argument ’debug’. Finished splitting the commandline. Parsing a group of options : global . Applying option loglevel (set logging level) with argument debug. Successfully parsed a group of options. Parsing a group of options : input url video.ts. Applying option ss (set the start time offset) with argument 00:42:20. Successfully parsed a group of options. Opening an input file : video.ts. [mpegts @ 0x22ba400] Format mpegts probed with size=2048 and score=100 [mpegts @ 0x22ba400] stream=0 stream_type=1b pid=1e1 prog_reg_desc= [mpegts @ 0x22ba400] stream=1 stream_type=f pid=1e2 prog_reg_desc= [mpegts @ 0x22ba400] stream=2 stream_type=6 pid=1e3 prog_reg_desc= [mpegts @ 0x22ba400] Before avformat_find_stream_info() pos : 0 bytes read:32768 seeks:0 [h264 @ 0x22be840] no picture [mpegts @ 0x22ba400] max_analyze_duration 5000000 reached at 5000000 microseconds st:0 [mpegts @ 0x22ba400] stream 0 : no PTS found at end of file, duration not set [mpegts @ 0x22ba400] After avformat_find_stream_info() pos : 0 bytes read:4026800 seeks:3 frames:550 Input #0, mpegts, from ’video.ts’ : Duration : 02:15:27.97, start : 1.079989, bitrate : 4983 kb/s Program 1 Stream #0:0[0x1e1], 216, 1/90000 : Video : h264 (High), 4 reference frames ([27][0][0][0] / 0x001B), yuv420p(left), 1920x1080 (1920x1088)R 16:9], 1/50, 25 fps, 50 tbr, 90k tbn, 50 tbc Stream #0:1[0x1e2](und), 203, 1/90000 : Audio : aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 127 kb/s Stream #0:2[0x1e3](und), 131, 1/90000 : Audio : ac3 ([6][0][0][0] / 0x0006), 48000 Hz, 5.1(side), fltp, 384 kb/s Successfully opened the file. Parsing a group of options : output url out_42_20.jpg. Applying option frames:v (set the number of frames to output) with argument 1. Successfully parsed a group of options. Opening an output file : out_42_20.jpg. Successfully opened the file. detected 1 logical cores [graph 0 input from stream 0:0 @ 0x22ba280] Setting ’video_size’ to value ’1920x1080’ [graph 0 input from stream 0:0 @ 0x22ba280] Setting ’pix_fmt’ to value ’0’ [graph 0 input from stream 0:0 @ 0x22ba280] Setting ’time_base’ to value ’1/90000’ [graph 0 input from stream 0:0 @ 0x22ba280] Setting ’pixel_aspect’ to value ’1/1’ [graph 0 input from stream 0:0 @ 0x22ba280] Setting ’sws_param’ to value ’flags=2’ [graph 0 input from stream 0:0 @ 0x22ba280] Setting ’frame_rate’ to value ’25/1’ [graph 0 input from stream 0:0 @ 0x22ba280] w:1920 h:1080 pixfmt:yuv420p tb:1/90000 fr:25/1 sar:1/1 sws_param:flags=2 [format @ 0x2328360] compat : called with args=[yuvj420p|yuvj422p|yuvj444p] [format @ 0x2328360] Setting ’pix_fmts’ to value ’yuvj420p|yuvj422p|yuvj444p’ [auto-inserted scaler 0 @ 0x2326600] Setting ’flags’ to value ’bicubic’ [auto-inserted scaler 0 @ 0x2326600] w:iw h:ih flags :’bicubic’ interl:0 [format @ 0x2328360] auto-inserting filter ’auto-inserted scaler 0’ between the filter ’Parsed_null_0’ and the filter ’format’ [AVFilterGraph @ 0x2327ba0] query_formats : 5 queried, 3 merged, 1 already done, 0 delayed [auto-inserted scaler 0 @ 0x2326600] picking yuvj420p out of 3 ref:yuv420p alpha:0 [swscaler @ 0x2310660] deprecated pixel format used, make sure you did set range correctly [auto-inserted scaler 0 @ 0x2326600] w:1920 h:1080 fmt:yuv420p sar:1/1 -> w:1920 h:1080 fmt:yuvj420p sar:1/1 flags:0x4 [mjpeg @ 0x2327620] Forcing thread count to 1 for MJPEG encoding, use -thread_type slice or a constant quantizer if you want to use multipl [mjpeg @ 0x2327620] intra_quant_bias = 96 inter_quant_bias = 0 Output #0, image2, to ’out_42_20.jpg’ : Metadata : encoder : Lavf56.40.101 Stream #0:0, 0, 1/25 : Video : mjpeg, 1 reference frame, yuvj420p(pc, left), 1920x1080 [SAR 1:1 DAR 16:9], 1/25, q=2-31, 200 kb/s, 25 fps tbc Metadata : encoder : Lavc56.60.100 mjpeg Stream mapping : Stream #0:0 -> #0:0 (h264 (native) -> mjpeg (native)) Press [q] to stop, [?] for help [h264 @ 0x232a040] Missing reference picture, default is 0 [h264 @ 0x232a040] decode_slice_header error [h264 @ 0x232a040] Missing reference picture, default is 0 [h264 @ 0x232a040] decode_slice_header error [h264 @ 0x232a040] Missing reference picture, default is 0 [h264 @ 0x232a040] decode_slice_header error timestamp discontinuity 0, new offset= -2541079989 [h264 @ 0x232a040] no picture [h264 @ 0x232a040] illegal short term buffer state detected [h264 @ 0x232a040] Missing reference picture, default is 65537 [h264 @ 0x232a040] decode_slice_header error [h264 @ 0x232a040] Missing reference picture, default is 65537 [h264 @ 0x232a040] decode_slice_header error [h264 @ 0x232a040] Missing reference picture, default is 65537 [h264 @ 0x232a040] decode_slice_header error [h264 @ 0x232a040] Missing reference picture, default is 65537 [h264 @ 0x232a040] decode_slice_header error [h264 @ 0x232a040] Missing reference picture, default is 65537 [h264 @ 0x232a040] decode_slice_header error [h264 @ 0x232a040] Missing reference picture, default is 65537 [h264 @ 0x232a040] decode_slice_header error [h264 @ 0x232a040] Missing reference picture, default is 65537 [h264 @ 0x232a040] decode_slice_header error [h264 @ 0x232a040] Missing reference picture, default is 65537 [h264 @ 0x232a040] decode_slice_header error [h264 @ 0x232a040] Missing reference picture, default is 65537 [h264 @ 0x232a040] decode_slice_header error [h264 @ 0x232a040] no picture *** 0 dup ! [AVIOContext @ 0x2448c00] Statistics : 0 seeks, 2 writeouts No more output streams to write to, finishing. frame= 1 fps=0.0 q=2.2 Lsize=N/A time=00:00:00.04 bitrate=N/A dup=1 drop=1 video:32kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead : unknown Input file #0 (video.ts) : Input stream #0:0 (video) : 9 packets read (261340 bytes) ; 3 frames decoded ; Input stream #0:1 (audio) : 0 packets read (0 bytes) ; Input stream #0:2 (audio) : 0 packets read (0 bytes) ; Total : 9 packets (261340 bytes) demuxed Output file #0 (out_42_20.jpg) : Output stream #0:0 (video) : 1 frames encoded ; 1 packets muxed (33209 bytes) ; Total : 1 packets (33209 bytes) muxed 3 frames successfully decoded, 0 decoding errors [AVIOContext @ 0x22c2e40] Statistics : 8798032 bytes read, 36 seeks
-
ffmpeg, opus encoded sound in webm does not work [on hold]
1er août 2017, par MockarutanI’m having trouble getting Opus encoded sound in the webm container to work. I’m using libopus in ffmpeg.
The file does work in VLC. But not in ffplay or on YouTube. If I take the raw wav data in a wav file and then convert it to Opus/webm with the ffmpeg.exe that comes pre-compiled. It works in VLC, ffplay and YouTube.
So ffmpeg can obviously do it correctly, I must be doing something wrong in my code.
The file my code produces : https://drive.google.com/file/d/0B16rIXjPXJCqcU5HVllIYW1iODg/view?usp=sharing
Edit, More details that I forgot in my frustration : The file can be opened by ffplay and uploaded to youtube (when I interlace it with VP9 video). But the sound is just "ticks", example : https://www.youtube.com/watch?v=j_ShBbuizeo&feature=youtu.be
I have read though all example codes that I know of from ffmpeg, but all of them is in the old API, not the send/receive api, so a big part of the code does not apply anymore. This codes works with all other Codes I’ve tested, including H.264+AAC in mp4, VP8+Opus in ogg and raw PCM F32LE in wav. I would have gone with VP8+Opus in ogg if the license was as straight forward as the webm license
I’ve looked though the source for the ffmpeg.exe command line tool and coped everything applicable in to my code base.
Here is my code : https://pastebin.com/4c999Uz2
#include "encoder.h"
#include <algorithm>
#include <iterator>
extern "C"
{
#include "libavcodec/avcodec.h"
#include "libavdevice/avdevice.h"
#include "libavfilter/avfilter.h"
#include "libavformat/avformat.h"
#include "libavutil/avutil.h"
#include "libavutil/imgutils.h"
#include "libswscale/swscale.h"
#include "libswresample/swresample.h"
enum InfoCodes
{
ENCODED_VIDEO,
ENCODED_AUDIO,
ENCODED_AUDIO_AND_VIDEO,
NOT_ENOUGH_AUDIO_DATA,
};
enum ErrorCodes
{
RES_NOT_MUL_OF_TWO = -1,
ERROR_FINDING_VID_CODEC = -2,
ERROR_CONTEXT_CREATION = -3,
ERROR_CONTEXT_ALLOCATING = -4,
ERROR_OPENING_VID_CODEC = -5,
ERROR_OPENING_FILE = -6,
ERROR_ALLOCATING_FRAME = -7,
ERROR_ALLOCATING_PIC_BUF = -8,
ERROR_ENCODING_FRAME_SEND = -9,
ERROR_ENCODING_FRAME_RECEIVE = -10,
ERROR_FINDING_AUD_CODEC = -11,
ERROR_OPENING_AUD_CODEC = -12,
ERROR_INIT_RESMPL_CONTEXT = -13,
ERROR_ENCODING_SAMPLES_SEND = -14,
ERROR_ENCODING_SAMPLES_RECEIVE = -15,
ERROR_WRITING_HEADER = -16,
ERROR_INIT_AUDIO_RESPAMLER = -17,
};
AVCodecID aud_codec_comp_id = AV_CODEC_ID_OPUS;
AVSampleFormat sample_fmt_comp = AV_SAMPLE_FMT_S16;
AVCodecID aud_codec_id;
AVSampleFormat sample_fmt;
char* compressed_cont = "webm";
AVCodec *aud_codec = NULL;
AVCodecContext *aud_codec_context = NULL;
AVFormatContext *outctx;
AVStream *audio_st;
AVFrame *aud_frame;
SwrContext *audio_swr_ctx;
uint8_t **dst_data = NULL;
AVRational conv_time_base;
int aud_frame_counter;
int dst_nb_samples, src_nb_samples, max_dst_nb_samples;;
int src_rate, dst_rate;
int dst_nb_channels;
int dst_linesize;
void write_error_to_file(const char* name, int value)
{
int buf_size = 100;
char* buf = new char[buf_size];
int ret = av_strerror(value, buf, buf_size);
FILE *f;
fopen_s(&f, name, "w");
if (f != NULL)
{
if (ret != 0)
fprintf(f, "Error erroring: , \n", ret);
else
fprintf(f, "Error code: %s\n", buf);
fclose(f);
}
}
void write_value_to_file(const char* name, float value)
{
FILE *f;
fopen_s(&f, name, "w");
if (f != NULL)
{
fprintf(f, "Value: %f\n", value);
fclose(f);
}
}
char* concat(const char *s1, const char *s2)
{
char *result = (char*)malloc(strlen(s1) + strlen(s2) + 1);
strcpy(result, s1);
strcat(result, s2);
return result;
}
int setup_audio_codec()
{
aud_codec_id = aud_codec_comp_id;
sample_fmt = sample_fmt_comp;
// Fixup audio codec
if (aud_codec == NULL)
{
aud_codec = avcodec_find_encoder(aud_codec_id);
avcodec_register(aud_codec);
}
if (!aud_codec)
return ERROR_FINDING_AUD_CODEC;
return 0;
}
int initialize_audio_stream(AVFormatContext *local_outctx, int sample_rate, int per_frame_audio_samples, int audio_bitrate)
{
aud_codec_context = avcodec_alloc_context3(aud_codec);
if (!aud_codec_context)
return ERROR_CONTEXT_CREATION;
/* select other audio parameters supported by the encoder */
aud_codec_context->bit_rate = audio_bitrate;
aud_codec_context->sample_rate = sample_rate;
aud_codec_context->sample_fmt = sample_fmt;
aud_codec_context->channel_layout = AV_CH_LAYOUT_STEREO;
aud_codec_context->channels = av_get_channel_layout_nb_channels(aud_codec_context->channel_layout);
aud_codec_context->codec = aud_codec;
aud_codec_context->codec_id = aud_codec_id;
AVRational time_base;
time_base.num = per_frame_audio_samples;
time_base.den = aud_codec_context->sample_rate;
aud_codec_context->time_base = time_base;
int ret = avcodec_open2(aud_codec_context, aud_codec, NULL);
if (ret < 0)
return ERROR_OPENING_AUD_CODEC;
local_outctx->audio_codec = aud_codec;
local_outctx->audio_codec_id = aud_codec_id;
audio_st = avformat_new_stream(local_outctx, aud_codec);
avcodec_parameters_from_context(audio_st->codecpar, aud_codec_context);
conv_time_base.num = aud_codec_context->frame_size;
conv_time_base.den = aud_codec_context->sample_rate;
aud_frame = av_frame_alloc();
aud_frame->nb_samples = aud_codec_context->frame_size;
aud_frame->format = aud_codec_context->sample_fmt;
aud_frame->channel_layout = aud_codec_context->channel_layout;
aud_frame->sample_rate = aud_codec_context->sample_rate;
int buffer_size;
if (aud_codec_context->frame_size == 0)
{
buffer_size = per_frame_audio_samples * 2 * 4;
aud_frame->nb_samples = per_frame_audio_samples;
}
else
{
buffer_size = av_samples_get_buffer_size(NULL, aud_codec_context->channels, aud_codec_context->frame_size,
aud_codec_context->sample_fmt, 0);
}
if (av_sample_fmt_is_planar(sample_fmt))
ret = av_frame_get_buffer(aud_frame, buffer_size / 2);
else
ret = av_frame_get_buffer(aud_frame, buffer_size);
if (!aud_frame || ret < 0)
return ERROR_ALLOCATING_FRAME;
audio_swr_ctx = swr_alloc();
if (!audio_swr_ctx)
return ERROR_INIT_AUDIO_RESPAMLER;
/* set options */
av_opt_set_int(audio_swr_ctx, "in_channel_layout", aud_codec_context->channel_layout, 0);
av_opt_set_int(audio_swr_ctx, "in_sample_rate", sample_rate, 0);
av_opt_set_int(audio_swr_ctx, "in_frame_size", per_frame_audio_samples, 0);
av_opt_set_sample_fmt(audio_swr_ctx, "in_sample_fmt", AV_SAMPLE_FMT_FLT, 0);
av_opt_set_int(audio_swr_ctx, "out_channel_layout", aud_codec_context->channel_layout, 0);
av_opt_set_int(audio_swr_ctx, "out_sample_rate", aud_codec_context->sample_rate, 0);
av_opt_set_int(audio_swr_ctx, "out_frame_size", aud_codec_context->frame_size, 0);
av_opt_set_sample_fmt(audio_swr_ctx, "out_sample_fmt", aud_codec_context->sample_fmt, 0);
/* initialize the resampling context */
if ((ret = swr_init(audio_swr_ctx)) < 0)
{
return ERROR_INIT_AUDIO_RESPAMLER;
}
dst_rate = aud_codec_context->sample_rate;
src_rate = sample_rate;
src_nb_samples = per_frame_audio_samples;
dst_nb_samples = aud_codec_context->frame_size;
max_dst_nb_samples = av_rescale_rnd(src_nb_samples, dst_rate, src_rate, AV_ROUND_UP);
dst_nb_channels = av_get_channel_layout_nb_channels(aud_codec_context->channel_layout);
ret = av_samples_alloc_array_and_samples(&dst_data, &dst_linesize, dst_nb_channels, dst_nb_samples, sample_fmt, 0);
aud_frame_counter = 0;
return 0;
}
int initialize_audio_only_encoding(int sample_rate, int per_frame_audio_samples, int audio_bitrate, const char *filename)
{
int ret;
avcodec_register_all();
av_register_all();
outctx = avformat_alloc_context();
char* full_filename;
char* with_dot = concat(filename, ".");
full_filename = concat(with_dot, compressed_cont);
ret = avformat_alloc_output_context2(&outctx, NULL, compressed_cont, full_filename);
free(with_dot);
if (ret < 0)
{
free(full_filename);
return ERROR_CONTEXT_CREATION;
}
ret = setup_audio_codec();
if (ret < 0)
return ret;
// Setup Audio
ret = initialize_audio_stream(outctx, sample_rate, per_frame_audio_samples, audio_bitrate);
if (ret < 0)
return ret;
av_dump_format(outctx, 0, full_filename, 1);
if (!(outctx->oformat->flags & AVFMT_NOFILE))
{
if (avio_open(&outctx->pb, full_filename, AVIO_FLAG_WRITE) < 0)
{
free(full_filename);
return ERROR_OPENING_FILE;
}
}
free(full_filename);
ret = avformat_write_header(outctx, NULL);
if (ret < 0)
return ERROR_WRITING_HEADER;
return 0;
}
int process_encode_loop(AVFormatContext *local_outctx, AVCodecContext *codec_context, AVStream *stream, AVRational time_base, bool flush)
{
int ret;
AVPacket pkt;
av_init_packet(&pkt);
pkt.data = NULL;
pkt.size = 0;
while (true)
{
ret = avcodec_receive_packet(codec_context, &pkt);
if (!ret)
{
pkt.stream_index = stream->index;
av_packet_rescale_ts(&pkt, time_base, stream->time_base);
av_interleaved_write_frame(local_outctx, &pkt);
av_packet_unref(&pkt);
}
if (ret == AVERROR(EAGAIN))
break;
else if (ret == AVERROR_EOF)
break;
else if (ret < 0)
return ERROR_ENCODING_FRAME_RECEIVE;
else if (flush == false)
break;
}
return 0;
}
int write_audio_frame(float_t *aud_sample)
{
int ret;
if (dst_nb_samples > max_dst_nb_samples)
{
av_free(&aud_frame->data[0]);
ret = av_samples_alloc(aud_frame->data, &dst_linesize, dst_nb_channels, dst_nb_samples, sample_fmt, 1);
if (ret < 0)
return ERROR_INIT_AUDIO_RESPAMLER;
max_dst_nb_samples = dst_nb_samples;
}
ret = swr_convert(audio_swr_ctx, dst_data, dst_nb_samples, (const uint8_t **)&aud_sample, src_nb_samples);
if (ret < 0)
{
return ERROR_INIT_AUDIO_RESPAMLER;
}
aud_frame->data[0] = (uint8_t*)dst_data[0];
aud_frame->extended_data[0] = (uint8_t*)dst_data[0];
aud_frame->pts = aud_frame_counter++;
ret = avcodec_send_frame(aud_codec_context, aud_frame);
if (ret < 0)
{
write_error_to_file("AVERROR.txt", ret);
return ERROR_ENCODING_SAMPLES_SEND;
}
ret = process_encode_loop(outctx, aud_codec_context, audio_st, conv_time_base, false);
if (ret < 0)
return ERROR_ENCODING_SAMPLES_RECEIVE;
return ENCODED_AUDIO;
}
int finish_audio_encoding()
{
//fclose(dst_file);
AVPacket pkt;
av_init_packet(&pkt);
pkt.data = NULL;
pkt.size = 0;
fflush(stdout);
int ret = avcodec_send_frame(aud_codec_context, NULL);
if (ret < 0)
return ERROR_ENCODING_FRAME_SEND;
while (true)
{
ret = avcodec_receive_packet(aud_codec_context, &pkt);
if (!ret)
{
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts = av_rescale_q(pkt.pts, aud_codec_context->time_base, audio_st->time_base);
if (pkt.dts != AV_NOPTS_VALUE)
pkt.dts = av_rescale_q(pkt.dts, aud_codec_context->time_base, audio_st->time_base);
av_write_frame(outctx, &pkt);
av_packet_unref(&pkt);
}
if (ret == -AVERROR(AVERROR_EOF))
break;
else if (ret < 0)
return ERROR_ENCODING_FRAME_RECEIVE;
}
av_write_trailer(outctx);
return 0;
}
void cleanup()
{
if (aud_frame)
{
av_frame_free(&aud_frame);
}
if (outctx)
{
for (int i = 0; i < outctx->nb_streams; i++)
av_freep(&outctx->streams[i]);
avio_close(outctx->pb);
av_free(outctx);
}
if (aud_codec_context)
{
avcodec_close(aud_codec_context);
av_free(aud_codec_context);
}
}
void fill_samples(float_t *dst, int nb_samples, int nb_channels, int sample_rate, float_t *t)
{
int i, j;
float_t tincr = 1.0 / sample_rate;
const float_t c = 2 * M_PI * 440.0;
/* generate sin tone with 440Hz frequency and duplicated channels */
for (i = 0; i < nb_samples; i++) {
*dst = sin(c * *t);
for (j = 1; j < nb_channels; j++)
dst[j] = dst[0];
dst += nb_channels;
*t += tincr;
}
}
int main()
{
int width = 1920;
int height = 1080;
int frame_rate = 30;
float t = 0, tincr = 0, tincr2 = 0;
int sec = 20;
int tot = 3 * width * height;
uint8_t* rgb24Data = new uint8_t[tot];
float_t** aud_samples_planar;
int16_t** aud_samples_s16;
int src_samples_linesize;
int src_nb_samples = 1024;
int src_channels = 2;
int sample_rate = 48000;
uint8_t **src_data = NULL;
int ret;
initialize_audio_only_encoding(48000, src_nb_samples, 256000, "only_sound");
ret = av_samples_alloc_array_and_samples(&src_data, &src_samples_linesize, src_channels,
src_nb_samples, AV_SAMPLE_FMT_FLT, 0);
for (size_t i = 0; i < frame_rate * sec; i++)
{
fill_samples((float *)src_data[0], src_nb_samples, src_channels, sample_rate, &t);
write_audio_frame((float *)src_data[0]);
}
finish_audio_encoding();
cleanup();
return 0;
}
}
</iterator></algorithm>Any any suggestion is appreciated, thanks in Advance !
Some things I tried :
I’ve looked at the header with the "MediaInfo" app built in to MVKTool :
https://i.gyazo.com/3b29b41629a28bd526bf7637ce3f2601.png
It all looks fine to me.I’ve also inspected the raw EBML file with EBML-Viewer (https://code.google.com/archive/p/ebml-viewer/) and in there I can se some difference between the files ;
My file : https://i.gyazo.com/6fa8c540a2698a8a4d3421d363aede0a.png
File produced with ffmpeg.exe : https://i.gyazo.com/04d60e64ff3c3040ea83e98cdf507530.pngIn my file it’s "Cluster" -> "BlockGroup" -> "Block", " ?"
In the other it’s just "Cluster" -> "SimpleBlock"
And in the webm specs, it says both are supported (https://www.webmproject.org/docs/container/)But I do not know much about these specific things, just looking for anything.