
Recherche avancée
Autres articles (94)
-
La file d’attente de SPIPmotion
28 novembre 2010, parUne file d’attente stockée dans la base de donnée
Lors de son installation, SPIPmotion crée une nouvelle table dans la base de donnée intitulée spip_spipmotion_attentes.
Cette nouvelle table est constituée des champs suivants : id_spipmotion_attente, l’identifiant numérique unique de la tâche à traiter ; id_document, l’identifiant numérique du document original à encoder ; id_objet l’identifiant unique de l’objet auquel le document encodé devra être attaché automatiquement ; objet, le type d’objet auquel (...) -
List of compatible distributions
26 avril 2011, parThe table below is the list of Linux distributions compatible with the automated installation script of MediaSPIP. Distribution nameVersion nameVersion number Debian Squeeze 6.x.x Debian Weezy 7.x.x Debian Jessie 8.x.x Ubuntu The Precise Pangolin 12.04 LTS Ubuntu The Trusty Tahr 14.04
If you want to help us improve this list, you can provide us access to a machine whose distribution is not mentioned above or send the necessary fixes to add (...) -
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 (6397)
-
VP8 Misplaced Plane
16 octobre 2010, par Multimedia Mike — VP8So I’m stubbornly plugging away at my toy VP8 encoder and I managed to produce this gem. See if you can spot the subtle mistake :
The misplaced color plane resulted from using the luma plane stride where it was not appropriate. I fixed that and now chroma planes are wired to use to the same naive prediction algorithm as the luma plane.
Also, I fixed the entropy encoder so that end of block conditions are signaled correctly (instead of my original, suboptimal hack to just encode all zeros). I was disappointed to see that this did not result in a major compression improvement. Then again, I’m using the lowest possible quantization settings for this outing, so perhaps this is to be expected.
Sigh… 4×4 luma prediction is next. Wish me luck.
-
RTSP relay using ffmpeg library
23 novembre 2015, par kiran_gI am implementing an RTSP relay using libavcodec (ffmpeg). Basically, it connects to an IP camera, which is an RTSP server, PULLs the stream and then PUSHes it to wowza. I am finding it very difficult to get any sample implementation for this in the internet. So I started implementing this using bits and pieces from here and there. I took code for code samples to a) read RTSP stream and write to file b)read from file and serve it over RTSP.
This is the current state of the code :
/*
* Copyright (c) 2010 Nicolas George
* Copyright (c) 2011 Stefano Sabatini
* Copyright (c) 2014 Andrey Utkin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
* @file
* API example for demuxing, decoding, filtering, encoding and muxing
* @example transcoding.c
*/
#include <libavcodec></libavcodec>avcodec.h>
#include <libavformat></libavformat>avformat.h>
#include <libavfilter></libavfilter>avfiltergraph.h>
#include <libavfilter></libavfilter>buffersink.h>
#include <libavfilter></libavfilter>buffersrc.h>
#include <libavutil></libavutil>opt.h>
#include <libavutil></libavutil>pixdesc.h>
static AVFormatContext *ifmt_ctx,*temp;
static AVFormatContext *ofmt_ctx;
typedef struct FilteringContext {
AVFilterContext *buffersink_ctx;
AVFilterContext *buffersrc_ctx;
AVFilterGraph *filter_graph;
} FilteringContext;
static FilteringContext *filter_ctx;
static int open_input_file(const char *filename)
{
int ret;
unsigned int i;
ifmt_ctx = NULL;
if ((ret = avformat_open_input(&ifmt_ctx, filename, NULL, NULL)) < 0) {
av_log(NULL, AV_LOG_ERROR, "Cannot open input file\n");
return ret;
}
if ((ret = avformat_find_stream_info(ifmt_ctx, NULL)) < 0) {
av_log(NULL, AV_LOG_ERROR, "Cannot find stream information\n");
return ret;
}
for (i = 0; i < ifmt_ctx->nb_streams; i++) {
AVStream *stream;
AVCodecContext *codec_ctx;
stream = ifmt_ctx->streams[i];
codec_ctx = stream->codec;
/* Reencode video & audio and remux subtitles etc. */
if (codec_ctx->codec_type == AVMEDIA_TYPE_VIDEO
|| codec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
/* Open decoder */
ret = avcodec_open2(codec_ctx,
avcodec_find_decoder(codec_ctx->codec_id), NULL);
if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Failed to open decoder for stream #%u\n", i);
return ret;
}
}
}
av_dump_format(ifmt_ctx, 0, filename, 0);
return 0;
}
static int open_output_file(const char *filename)
{
AVStream *out_stream;
AVStream *in_stream;
AVCodecContext *dec_ctx, *enc_ctx;
AVCodec *encoder,*codec;
int ret;
unsigned int i;
ofmt_ctx = NULL;
avformat_open_input(&temp, "rtsp://localhost:8554/live", NULL, NULL);
avformat_alloc_output_context2(&ofmt_ctx, temp->oformat,"rtsp", filename);
if (!ofmt_ctx) {
av_log(NULL, AV_LOG_ERROR, "Could not create output context\n");
return AVERROR_UNKNOWN;
}
for (i = 0; i < ifmt_ctx->nb_streams; i++) {
out_stream = avformat_new_stream(ofmt_ctx, NULL);
if (!out_stream) {
av_log(NULL, AV_LOG_ERROR, "Failed allocating output stream\n");
return AVERROR_UNKNOWN;
}
in_stream = ifmt_ctx->streams[i];
dec_ctx = in_stream->codec;
enc_ctx = out_stream->codec;
if (dec_ctx->codec_type == AVMEDIA_TYPE_VIDEO
|| dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
/* in this example, we choose transcoding to same codec */
encoder = avcodec_find_encoder(dec_ctx->codec_id);
printf("codec : %d",dec_ctx->codec_id);
if (!encoder) {
av_log(NULL, AV_LOG_FATAL, "Necessary encoder not found\n");
return AVERROR_INVALIDDATA;
}
/* In this example, we transcode to same properties (picture size,
* sample rate etc.). These properties can be changed for output
* streams easily using filters */
if (dec_ctx->codec_type == AVMEDIA_TYPE_VIDEO) {
enc_ctx->height = dec_ctx->height;
enc_ctx->width = dec_ctx->width;
enc_ctx->sample_aspect_ratio = dec_ctx->sample_aspect_ratio;
/* take first format from list of supported formats */
enc_ctx->pix_fmt = encoder->pix_fmts[0];
//enc_ctx->codec_id = AV_CODEC_ID_H264;
/* video time_base can be set to whatever is handy and supported by encoder */
enc_ctx->time_base = dec_ctx->time_base;
} else {
enc_ctx->sample_rate = dec_ctx->sample_rate;
enc_ctx->channel_layout = dec_ctx->channel_layout;
enc_ctx->channels = av_get_channel_layout_nb_channels(enc_ctx->channel_layout);
/* take first format from list of supported formats */
enc_ctx->sample_fmt = encoder->sample_fmts[0];
enc_ctx->pix_fmt =AV_PIX_FMT_RGB24 ;
enc_ctx->time_base = (AVRational){1, enc_ctx->sample_rate};
}
/* Third parameter can be used to pass settings to encoder */
//codec = avcodec_find_encoder(AV_CODEC_ID_H264);
ret = avcodec_open2(enc_ctx, encoder, NULL);
if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Cannot open video encoder for stream #%u\n", i);
return ret;
}
} else if (dec_ctx->codec_type == AVMEDIA_TYPE_UNKNOWN) {
av_log(NULL, AV_LOG_FATAL, "Elementary stream #%d is of unknown type, cannot proceed\n", i);
return AVERROR_INVALIDDATA;
} else {
/* if this stream must be remuxed */
ret = avcodec_copy_context(ofmt_ctx->streams[i]->codec,
ifmt_ctx->streams[i]->codec);
if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Copying stream context failed\n");
return ret;
}
}
if (ofmt_ctx->oformat->flags & AVFMT_GLOBALHEADER)
enc_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
}
av_dump_format(ofmt_ctx, 0, filename, 1);
if (!(ofmt_ctx->oformat->flags & AVFMT_NOFILE)) {
ret = avio_open(&ofmt_ctx->pb, filename, AVIO_FLAG_WRITE);
if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Could not open output file '%s'", filename);
return ret;
}
}
/* init muxer, write output file header */
ret = avformat_write_header(ofmt_ctx, NULL);
if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Error occurred when opening output file\n");
return ret;
}
return 0;
}
static int init_filter(FilteringContext* fctx, AVCodecContext *dec_ctx,
AVCodecContext *enc_ctx, const char *filter_spec)
{
char args[512];
int ret = 0;
AVFilter *buffersrc = NULL;
AVFilter *buffersink = NULL;
AVFilterContext *buffersrc_ctx = NULL;
AVFilterContext *buffersink_ctx = NULL;
AVFilterInOut *outputs = avfilter_inout_alloc();
AVFilterInOut *inputs = avfilter_inout_alloc();
AVFilterGraph *filter_graph = avfilter_graph_alloc();
if (!outputs || !inputs || !filter_graph) {
ret = AVERROR(ENOMEM);
goto end;
}
if (dec_ctx->codec_type == AVMEDIA_TYPE_VIDEO) {
buffersrc = avfilter_get_by_name("buffer");
buffersink = avfilter_get_by_name("buffersink");
if (!buffersrc || !buffersink) {
av_log(NULL, AV_LOG_ERROR, "filtering source or sink element not found\n");
ret = AVERROR_UNKNOWN;
goto end;
}
snprintf(args, sizeof(args),
"video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:pixel_aspect=%d/%d",
dec_ctx->width, dec_ctx->height, dec_ctx->pix_fmt,
dec_ctx->time_base.num, dec_ctx->time_base.den,
dec_ctx->sample_aspect_ratio.num,
dec_ctx->sample_aspect_ratio.den);
ret = avfilter_graph_create_filter(&buffersrc_ctx, buffersrc, "in",
args, NULL, filter_graph);
if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Cannot create buffer source\n");
goto end;
}
ret = avfilter_graph_create_filter(&buffersink_ctx, buffersink, "out",
NULL, NULL, filter_graph);
if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Cannot create buffer sink\n");
goto end;
}
ret = av_opt_set_bin(buffersink_ctx, "pix_fmts",
(uint8_t*)&enc_ctx->pix_fmt, sizeof(enc_ctx->pix_fmt),
AV_OPT_SEARCH_CHILDREN);
if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Cannot set output pixel format\n");
goto end;
}
} else if (dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
buffersrc = avfilter_get_by_name("abuffer");
buffersink = avfilter_get_by_name("abuffersink");
if (!buffersrc || !buffersink) {
av_log(NULL, AV_LOG_ERROR, "filtering source or sink element not found\n");
ret = AVERROR_UNKNOWN;
goto end;
}
if (!dec_ctx->channel_layout)
dec_ctx->channel_layout =
av_get_default_channel_layout(dec_ctx->channels);
snprintf(args, sizeof(args),
"time_base=%d/%d:sample_rate=%d:sample_fmt=%s:channel_layout=0x%"PRIx64,
dec_ctx->time_base.num, dec_ctx->time_base.den, dec_ctx->sample_rate,
av_get_sample_fmt_name(dec_ctx->sample_fmt),
dec_ctx->channel_layout);
ret = avfilter_graph_create_filter(&buffersrc_ctx, buffersrc, "in",
args, NULL, filter_graph);
if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Cannot create audio buffer source\n");
goto end;
}
ret = avfilter_graph_create_filter(&buffersink_ctx, buffersink, "out",
NULL, NULL, filter_graph);
if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Cannot create audio buffer sink\n");
goto end;
}
ret = av_opt_set_bin(buffersink_ctx, "sample_fmts",
(uint8_t*)&enc_ctx->sample_fmt, sizeof(enc_ctx->sample_fmt),
AV_OPT_SEARCH_CHILDREN);
if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Cannot set output sample format\n");
goto end;
}
ret = av_opt_set_bin(buffersink_ctx, "channel_layouts",
(uint8_t*)&enc_ctx->channel_layout,
sizeof(enc_ctx->channel_layout), AV_OPT_SEARCH_CHILDREN);
if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Cannot set output channel layout\n");
goto end;
}
ret = av_opt_set_bin(buffersink_ctx, "sample_rates",
(uint8_t*)&enc_ctx->sample_rate, sizeof(enc_ctx->sample_rate),
AV_OPT_SEARCH_CHILDREN);
if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Cannot set output sample rate\n");
goto end;
}
} else {
ret = AVERROR_UNKNOWN;
goto end;
}
/* Endpoints for the filter graph. */
outputs->name = av_strdup("in");
outputs->filter_ctx = buffersrc_ctx;
outputs->pad_idx = 0;
outputs->next = NULL;
inputs->name = av_strdup("out");
inputs->filter_ctx = buffersink_ctx;
inputs->pad_idx = 0;
inputs->next = NULL;
if (!outputs->name || !inputs->name) {
ret = AVERROR(ENOMEM);
goto end;
}
if ((ret = avfilter_graph_parse_ptr(filter_graph, filter_spec,
&inputs, &outputs, NULL)) < 0)
goto end;
if ((ret = avfilter_graph_config(filter_graph, NULL)) < 0)
goto end;
/* Fill FilteringContext */
fctx->buffersrc_ctx = buffersrc_ctx;
fctx->buffersink_ctx = buffersink_ctx;
fctx->filter_graph = filter_graph;
end:
avfilter_inout_free(&inputs);
avfilter_inout_free(&outputs);
return ret;
}
static int init_filters(void)
{
const char *filter_spec;
unsigned int i;
int ret;
filter_ctx = av_malloc_array(ifmt_ctx->nb_streams, sizeof(*filter_ctx));
if (!filter_ctx)
return AVERROR(ENOMEM);
for (i = 0; i < ifmt_ctx->nb_streams; i++) {
filter_ctx[i].buffersrc_ctx = NULL;
filter_ctx[i].buffersink_ctx = NULL;
filter_ctx[i].filter_graph = NULL;
if (!(ifmt_ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO
|| ifmt_ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO))
continue;
if (ifmt_ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
filter_spec = "null"; /* passthrough (dummy) filter for video */
else
filter_spec = "anull"; /* passthrough (dummy) filter for audio */
ret = init_filter(&filter_ctx[i], ifmt_ctx->streams[i]->codec,
ofmt_ctx->streams[i]->codec, filter_spec);
if (ret)
return ret;
}
return 0;
}
static int encode_write_frame(AVFrame *filt_frame, unsigned int stream_index, int *got_frame) {
int ret;
int got_frame_local;
AVPacket enc_pkt;
int (*enc_func)(AVCodecContext *, AVPacket *, const AVFrame *, int *) =
(ifmt_ctx->streams[stream_index]->codec->codec_type ==
AVMEDIA_TYPE_VIDEO) ? avcodec_encode_video2 : avcodec_encode_audio2;
if (!got_frame)
got_frame = &got_frame_local;
av_log(NULL, AV_LOG_INFO, "Encoding frame\n");
/* encode filtered frame */
enc_pkt.data = NULL;
enc_pkt.size = 0;
av_init_packet(&enc_pkt);
ret = enc_func(ofmt_ctx->streams[stream_index]->codec, &enc_pkt,
filt_frame, got_frame);
av_frame_free(&filt_frame);
if (ret < 0)
return ret;
if (!(*got_frame))
return 0;
/* prepare packet for muxing */
enc_pkt.stream_index = stream_index;
av_packet_rescale_ts(&enc_pkt,
ofmt_ctx->streams[stream_index]->codec->time_base,
ofmt_ctx->streams[stream_index]->time_base);
av_log(NULL, AV_LOG_DEBUG, "Muxing frame\n");
/* mux encoded frame */
ret = av_interleaved_write_frame(ofmt_ctx, &enc_pkt);
return ret;
}
static int filter_encode_write_frame(AVFrame *frame, unsigned int stream_index)
{
int ret;
AVFrame *filt_frame;
av_log(NULL, AV_LOG_INFO, "Pushing decoded frame to filters\n");
/* push the decoded frame into the filtergraph */
ret = av_buffersrc_add_frame_flags(filter_ctx[stream_index].buffersrc_ctx,
frame, 0);
if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Error while feeding the filtergraph\n");
return ret;
}
/* pull filtered frames from the filtergraph */
while (1) {
filt_frame = av_frame_alloc();
if (!filt_frame) {
ret = AVERROR(ENOMEM);
break;
}
av_log(NULL, AV_LOG_INFO, "Pulling filtered frame from filters\n");
ret = av_buffersink_get_frame(filter_ctx[stream_index].buffersink_ctx,
filt_frame);
if (ret < 0) {
/* if no more frames for output - returns AVERROR(EAGAIN)
* if flushed and no more frames for output - returns AVERROR_EOF
* rewrite retcode to 0 to show it as normal procedure completion
*/
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
ret = 0;
av_frame_free(&filt_frame);
break;
}
filt_frame->pict_type = AV_PICTURE_TYPE_NONE;
ret = encode_write_frame(filt_frame, stream_index, NULL);
if (ret < 0)
break;
}
return ret;
}
static int flush_encoder(unsigned int stream_index)
{
int ret;
int got_frame;
if (!(ofmt_ctx->streams[stream_index]->codec->codec->capabilities &
AV_CODEC_CAP_DELAY))
return 0;
while (1) {
av_log(NULL, AV_LOG_INFO, "Flushing stream #%u encoder\n", stream_index);
ret = encode_write_frame(NULL, stream_index, &got_frame);
if (ret < 0)
break;
if (!got_frame)
return 0;
}
return ret;
}
int main(int argc, char **argv)
{
int ret;
AVPacket packet = { .data = NULL, .size = 0 };
AVFrame *frame = NULL;
enum AVMediaType type;
unsigned int stream_index;
unsigned int i;
int got_frame;
int (*dec_func)(AVCodecContext *, AVFrame *, int *, const AVPacket *);
if (argc != 3) {
av_log(NULL, AV_LOG_ERROR, "Usage: %s <input file="file" /> <output file="file">\n", argv[0]);
return 1;
}
av_register_all();
avfilter_register_all();
avformat_network_init();
if ((ret = open_input_file(argv[1])) < 0)
goto end;
if ((ret = open_output_file(argv[2])) < 0)
goto end;
if ((ret = init_filters()) < 0)
goto end;
/* read all packets */
while (1) {
if ((ret = av_read_frame(ifmt_ctx, &packet)) < 0)
break;
stream_index = packet.stream_index;
type = ifmt_ctx->streams[packet.stream_index]->codec->codec_type;
av_log(NULL, AV_LOG_DEBUG, "Demuxer gave frame of stream_index %u\n",
stream_index);
if (filter_ctx[stream_index].filter_graph) {
av_log(NULL, AV_LOG_DEBUG, "Going to reencode&filter the frame\n");
frame = av_frame_alloc();
if (!frame) {
ret = AVERROR(ENOMEM);
break;
}
av_packet_rescale_ts(&packet,
ifmt_ctx->streams[stream_index]->time_base,
ifmt_ctx->streams[stream_index]->codec->time_base);
dec_func = (type == AVMEDIA_TYPE_VIDEO) ? avcodec_decode_video2 :
avcodec_decode_audio4;
ret = dec_func(ifmt_ctx->streams[stream_index]->codec, frame,
&got_frame, &packet);
if (ret < 0) {
av_frame_free(&frame);
av_log(NULL, AV_LOG_ERROR, "Decoding failed\n");
break;
}
if (got_frame) {
frame->pts = av_frame_get_best_effort_timestamp(frame);
ret = filter_encode_write_frame(frame, stream_index);
av_frame_free(&frame);
if (ret < 0)
goto end;
} else {
av_frame_free(&frame);
}
} else {
/* remux this frame without reencoding */
av_packet_rescale_ts(&packet,
ifmt_ctx->streams[stream_index]->time_base,
ofmt_ctx->streams[stream_index]->time_base);
ret = av_interleaved_write_frame(ofmt_ctx, &packet);
if (ret < 0)
goto end;
}
av_packet_unref(&packet);
}
/* flush filters and encoders */
for (i = 0; i < ifmt_ctx->nb_streams; i++) {
/* flush filter */
if (!filter_ctx[i].filter_graph)
continue;
ret = filter_encode_write_frame(NULL, i);
if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Flushing filter failed\n");
goto end;
}
/* flush encoder */
ret = flush_encoder(i);
if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Flushing encoder failed\n");
goto end;
}
}
av_write_trailer(ofmt_ctx);
end:
av_packet_unref(&packet);
av_frame_free(&frame);
for (i = 0; i < ifmt_ctx->nb_streams; i++) {
avcodec_close(ifmt_ctx->streams[i]->codec);
if (ofmt_ctx && ofmt_ctx->nb_streams > i && ofmt_ctx->streams[i] && ofmt_ctx->streams[i]->codec)
avcodec_close(ofmt_ctx->streams[i]->codec);
if (filter_ctx && filter_ctx[i].filter_graph)
avfilter_graph_free(&filter_ctx[i].filter_graph);
}
av_free(filter_ctx);
avformat_close_input(&ifmt_ctx);
if (ofmt_ctx && !(ofmt_ctx->oformat->flags & AVFMT_NOFILE))
avio_closep(&ofmt_ctx->pb);
avformat_free_context(ofmt_ctx);
if (ret < 0)
av_log(NULL, AV_LOG_ERROR, "Error occurred: %s\n", av_err2str(ret));
return ret ? 1 : 0;
}
</output>When we run this we are getting this error :
Input #0, rtsp, from 'rtsp://localhost:8554/live':
Metadata:
title : Unnamed
comment : N/A
Duration: N/A, start: 5294.642467, bitrate: N/A
Stream #0:0: Video: h264 (Constrained Baseline), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 30 fps, 30 tbr, 90k tbn, 60 tbc
[libx264 @ 0xe87c80] Specified pixel format -1 is invalid or not supported
Cannot open video encoder for stream #0
codec : 28 and pix :12
Error occurred: Invalid argumentBut I could see that the correct pixel format macro "AV_PIX_FMT_YUV420P" is provided.
UPDATE 1 :
This is the section in ffmpeg where the error is thrown from(utils.c line 1547) :if (avctx->codec->pix_fmts) {
for (i = 0; avctx->codec->pix_fmts[i] != AV_PIX_FMT_NONE; i++)
if (avctx->pix_fmt == avctx->codec->pix_fmts[i])
break;
if (avctx->codec->pix_fmts[i] == AV_PIX_FMT_NONE
&& !((avctx->codec_id == AV_CODEC_ID_MJPEG || avctx->codec_id == AV_CODEC_ID_LJPEG)
&& avctx->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL)) {
char buf[128];
snprintf(buf, sizeof(buf), "%d", avctx->pix_fmt);
av_log(avctx, AV_LOG_ERROR, "Specified pixel format %s is invalid or not supported\n",
(char *)av_x_if_null(av_get_pix_fmt_name(avctx->pix_fmt), buf));
ret = AVERROR(EINVAL);
goto free_and_end;
}Can someone suggest a solution for this.
Thanks
-
Ffmpeg avs to avi lossless conversion
21 février 2016, par PiotrHow to convert avs (Avisynth file) to avi without loss of quality ?
Firstly, I’m changing avs to 264 :
ffmpeg -i "Source.avs" -c:v libx264 -preset veryslow -crf 24 "Output.264"
Secondly, I’m trying to convert 264 to avi :
ffmpeg -i "input.264" "output.avi"
Final avi should have almost 200MB, but has only 2MB. 264 file has almost 150MB, so it should be good. I think that I should use some codec in second command, but I don’t know which. I’m trying to change this for a few days, but without effect.
Or maybe there is a way to lossless conversion without 264, only avs to avi ?
Thank you for your help.
Edit :
Thank you for answers. Unfortunatelly, both methods fail.
First gives me a video, which is blurry and I can’t see anything on it.Output :
C:\Users\Piotr>"C:\Users\Piotr\Documents\Visual Studio 2010\Projects\SoRecorder\
SoRecorder\bin\Release\Ffmpeg\ffmpeg.exe" -i "C:\Users\Piotr\Documents\Visual St
udio 2010\Projects\SoRecorder\SoRecorder\bin\Release\Scripts\-2016-02-20.avs" -c
copy "E:\-2016-02-20.avi"
ffmpeg version N-78559-g2e8ad2d Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.3.0 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --
enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-l
ibilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enab
le-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --en
able-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --ena
ble-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --
enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-lib
x265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-d
ecklink --enable-zlib
libavutil 55. 17.103 / 55. 17.103
libavcodec 57. 24.103 / 57. 24.103
libavformat 57. 25.100 / 57. 25.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 32.100 / 6. 32.100
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, avisynth, from 'C:\Users\Piotr\Documents\Visual Studio 2010\Projects\S
oRecorder\SoRecorder\bin\Release\Scripts\-2016-02-20.avs':
Duration: 00:00:21.80, start: 0.000000, bitrate: 0 kb/s
Stream #0:0: Video: rawvideo (BGRA / 0x41524742), bgra, 1280x720, 15 fps, 15
tbr, 15 tbn, 15 tbc
[avi @ 048d8cc0] bgra rawvideo cannot be written to avi, output file will be unr
eadable
Output #0, avi, to 'E:\-2016-02-20.avi':
Metadata:
ISFT : Lavf57.25.100
Stream #0:0: Video: rawvideo, bgra, 1280x720, q=2-31, 15 fps, 15 tbr, 15 tbn
, 15 tbc
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame= 41 fps=0.0 q=-1.0 size= 147606kB time=00:00:02.73 bitrate=442385.6kbit
frame= 65 fps= 63 q=-1.0 size= 234006kB time=00:00:04.33 bitrate=442379.5kbit
frame= 93 fps= 60 q=-1.0 size= 334806kB time=00:00:06.20 bitrate=442376.3kbit
frame= 110 fps= 51 q=-1.0 size= 396006kB time=00:00:07.33 bitrate=442375.2kbit
frame= 116 fps= 42 q=-1.0 size= 417606kB time=00:00:07.73 bitrate=442374.9kbit
frame= 122 fps= 37 q=-1.0 size= 439206kB time=00:00:08.13 bitrate=442374.6kbit
frame= 128 fps= 33 q=-1.0 size= 460807kB time=00:00:08.53 bitrate=442374.3kbit
frame= 133 fps= 31 q=-1.0 size= 478807kB time=00:00:08.86 bitrate=442374.1kbit
frame= 139 fps= 29 q=-1.0 size= 500407kB time=00:00:09.26 bitrate=442373.8kbit
frame= 145 fps= 27 q=-1.0 size= 522007kB time=00:00:09.66 bitrate=442373.6kbit
frame= 151 fps= 25 q=-1.0 size= 543607kB time=00:00:10.06 bitrate=442373.5kbit
frame= 157 fps= 24 q=-1.0 size= 565207kB time=00:00:10.46 bitrate=442373.3kbit
frame= 163 fps= 23 q=-1.0 size= 586807kB time=00:00:10.86 bitrate=442373.1kbit
frame= 169 fps= 22 q=-1.0 size= 608407kB time=00:00:11.26 bitrate=442373.0kbit
frame= 175 fps= 21 q=-1.0 size= 630007kB time=00:00:11.66 bitrate=442372.8kbit
frame= 181 fps= 21 q=-1.0 size= 651607kB time=00:00:12.06 bitrate=442372.7kbit
frame= 187 fps= 20 q=-1.0 size= 673207kB time=00:00:12.46 bitrate=442372.6kbit
frame= 193 fps= 19 q=-1.0 size= 694807kB time=00:00:12.86 bitrate=442372.5kbit
frame= 199 fps= 19 q=-1.0 size= 716407kB time=00:00:13.26 bitrate=442372.4kbit
frame= 204 fps= 19 q=-1.0 size= 734407kB time=00:00:13.60 bitrate=442372.3kbit
frame= 210 fps= 18 q=-1.0 size= 756007kB time=00:00:14.00 bitrate=442372.2kbit
frame= 215 fps= 18 q=-1.0 size= 774007kB time=00:00:14.33 bitrate=442372.1kbit
frame= 221 fps= 18 q=-1.0 size= 795607kB time=00:00:14.73 bitrate=442372.1kbit
frame= 226 fps= 17 q=-1.0 size= 813607kB time=00:00:15.06 bitrate=442372.0kbit
frame= 232 fps= 17 q=-1.0 size= 835207kB time=00:00:15.46 bitrate=442371.9kbit
frame= 238 fps= 17 q=-1.0 size= 856807kB time=00:00:15.86 bitrate=442371.8kbit
frame= 244 fps= 17 q=-1.0 size= 878407kB time=00:00:16.26 bitrate=442371.7kbit
frame= 250 fps= 16 q=-1.0 size= 900007kB time=00:00:16.66 bitrate=442371.7kbit
frame= 256 fps= 16 q=-1.0 size= 921608kB time=00:00:17.06 bitrate=442371.6kbit
frame= 261 fps= 16 q=-1.0 size= 939608kB time=00:00:17.40 bitrate=442371.6kbit
frame= 267 fps= 16 q=-1.0 size= 961208kB time=00:00:17.80 bitrate=442371.5kbit
frame= 273 fps= 16 q=-1.0 size= 982808kB time=00:00:18.20 bitrate=442371.5kbit
frame= 278 fps= 16 q=-1.0 size= 1000808kB time=00:00:18.53 bitrate=442371.4kbit
frame= 284 fps= 15 q=-1.0 size= 1022408kB time=00:00:18.93 bitrate=442371.4kbit
frame= 290 fps= 15 q=-1.0 size= 1044008kB time=00:00:19.33 bitrate=442371.3kbit
frame= 296 fps= 15 q=-1.0 size= 1065615kB time=00:00:19.73 bitrate=442374.1kbit
frame= 302 fps= 15 q=-1.0 size= 1087215kB time=00:00:20.13 bitrate=442374.0kbit
frame= 308 fps= 15 q=-1.0 size= 1108815kB time=00:00:20.53 bitrate=442373.9kbit
frame= 314 fps= 15 q=-1.0 size= 1130415kB time=00:00:20.93 bitrate=442373.8kbit
frame= 320 fps= 15 q=-1.0 size= 1152015kB time=00:00:21.33 bitrate=442373.7kbit
frame= 326 fps= 15 q=-1.0 size= 1173615kB time=00:00:21.73 bitrate=442373.7kbit
frame= 327 fps= 15 q=-1.0 Lsize= 1177215kB time=00:00:21.80 bitrate=442373.8kbi
ts/s speed=0.967x
video:1177200kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxi
ng overhead: 0.001301%EDIT : Output after PNG command :
C:\Users\Piotr>"C:\Users\Piotr\Documents\Visual Studio 2010\Projects\SoRecorder\
SoRecorder\bin\Release\Ffmpeg\ffmpeg.exe" -i "C:\Users\Piotr\Documents\Visual St
udio 2010\Projects\SoRecorder\SoRecorder\bin\Release\Scripts\-2016-02-21--1.avs"
-c:v png -pix_fmt bgra "E:\-2016-02-21.avi"
ffmpeg version N-78559-g2e8ad2d Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.3.0 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --
enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-l
ibilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enab
le-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --en
able-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --ena
ble-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --
enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-lib
x265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-d
ecklink --enable-zlib
libavutil 55. 17.103 / 55. 17.103
libavcodec 57. 24.103 / 57. 24.103
libavformat 57. 25.100 / 57. 25.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 32.100 / 6. 32.100
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, avisynth, from 'C:\Users\Piotr\Documents\Visual Studio 2010\Projects\S
oRecorder\SoRecorder\bin\Release\Scripts\-2016-02-21--1.avs':
Duration: 00:00:25.07, start: 0.000000, bitrate: 0 kb/s
Stream #0:0: Video: rawvideo (BGRA / 0x41524742), bgra, 640x480, 30 fps, 30
tbr, 30 tbn, 30 tbc
Incompatible pixel format 'bgra' for codec 'png', auto-selecting format 'rgba'
Output #0, avi, to 'E:\-2016-02-21.avi':
Metadata:
ISFT : Lavf57.25.100
Stream #0:0: Video: png (MPNG / 0x474E504D), rgba, 640x480, q=2-31, 200 kb/s
, 30 fps, 30 tbn, 30 tbc
Metadata:
encoder : Lavc57.24.103 png
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> png (native))
Press [q] to stop, [?] for help
frame= 18 fps=0.0 q=-0.0 size= 10716kB time=00:00:00.46 bitrate=188119.0kbit
frame= 35 fps= 34 q=-0.0 size= 23722kB time=00:00:01.03 bitrate=188065.8kbit
frame= 48 fps= 27 q=-0.0 size= 33668kB time=00:00:01.46 bitrate=188052.7kbit
frame= 61 fps= 26 q=-0.0 size= 43614kB time=00:00:01.90 bitrate=188045.7kbit
frame= 74 fps= 26 q=-0.0 size= 53560kB time=00:00:02.33 bitrate=188041.3kbit
frame= 89 fps= 26 q=-0.0 size= 65036kB time=00:00:02.83 bitrate=188037.8kbit
frame= 106 fps= 27 q=-0.0 size= 78042kB time=00:00:03.40 bitrate=188035.1kbit
frame= 123 fps= 28 q=-0.0 size= 91048kB time=00:00:03.96 bitrate=188033.2kbit
frame= 137 fps= 28 q=-0.0 size= 101759kB time=00:00:04.43 bitrate=188032.0kbit
frame= 155 fps= 28 q=-0.0 size= 115530kB time=00:00:05.03 bitrate=188030.8kbit
frame= 186 fps= 31 q=-0.0 size= 125735kB time=00:00:06.06 bitrate=169783.8kbit
frame= 224 fps= 35 q=-0.0 size= 133831kB time=00:00:07.33 bitrate=149501.7kbit
frame= 261 fps= 37 q=-0.0 size= 142679kB time=00:00:08.56 bitrate=136438.4kbit
frame= 300 fps= 40 q=-0.0 size= 151249kB time=00:00:09.86 bitrate=125577.5kbit
frame= 338 fps= 42 q=-0.0 size= 159452kB time=00:00:11.13 bitrate=117326.2kbit
frame= 371 fps= 44 q=-0.0 size= 169169kB time=00:00:12.23 bitrate=113283.3kbit
frame= 407 fps= 45 q=-0.0 size= 178924kB time=00:00:13.43 bitrate=109112.3kbit
frame= 444 fps= 47 q=-0.0 size= 187571kB time=00:00:14.66 bitrate=104767.1kbit
frame= 488 fps= 49 q=-0.0 size= 194672kB time=00:00:16.13 bitrate=98848.5kbits
frame= 535 fps= 51 q=-0.0 size= 199781kB time=00:00:17.70 bitrate=92463.5kbits
frame= 569 fps= 52 q=-0.0 size= 208530kB time=00:00:18.83 bitrate=90705.2kbits
frame= 604 fps= 52 q=-0.0 size= 216658kB time=00:00:20.00 bitrate=88743.0kbits
frame= 622 fps= 52 q=-0.0 size= 229851kB time=00:00:20.60 bitrate=91404.7kbits
frame= 639 fps= 51 q=-0.0 size= 242857kB time=00:00:21.16 bitrate=93991.3kbits
frame= 656 fps= 50 q=-0.0 size= 255863kB time=00:00:21.73 bitrate=96443.0kbits
frame= 673 fps= 49 q=-0.0 size= 268869kB time=00:00:22.30 bitrate=98770.1kbits
frame= 690 fps= 49 q=-0.0 size= 281875kB time=00:00:22.86 bitrate=100981.9kbit
frame= 707 fps= 48 q=-0.0 size= 294881kB time=00:00:23.43 bitrate=103086.7kbit
frame= 724 fps= 48 q=-0.0 size= 307887kB time=00:00:24.00 bitrate=105092.1kbit
frame= 741 fps= 47 q=-0.0 size= 320893kB time=00:00:24.56 bitrate=107005.0kbit
frame= 752 fps= 46 q=-0.0 Lsize= 332381kB time=00:00:25.06 bitrate=108624.9kbi
ts/s speed=1.54x
video:332357kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxin
g overhead: 0.007042%