
Recherche avancée
Médias (1)
-
Revolution of Open-source and film making towards open film making
6 octobre 2011, par
Mis à jour : Juillet 2013
Langue : English
Type : Texte
Autres articles (112)
-
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 (...) -
Personnaliser en ajoutant son logo, sa bannière ou son image de fond
5 septembre 2013, parCertains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;
-
Amélioration de la version de base
13 septembre 2013Jolie sélection multiple
Le plugin Chosen permet d’améliorer l’ergonomie des champs de sélection multiple. Voir les deux images suivantes pour comparer.
Il suffit pour cela d’activer le plugin Chosen (Configuration générale du site > Gestion des plugins), puis de configurer le plugin (Les squelettes > Chosen) en activant l’utilisation de Chosen dans le site public et en spécifiant les éléments de formulaires à améliorer, par exemple select[multiple] pour les listes à sélection multiple (...)
Sur d’autres sites (13434)
-
How can I save the h264 encoded video as a sequence of AVPacket-s to the file using libav c++ ?
8 juillet 2023, par danvik13I'm trying to save video, which is generated and encoded on fly using libav (ffmpeg) functional. When I receive next non-empty AVPacket with encoded frame, I call writer.saveNextPacket() method.
Of cause, before saving, I properly init both codec and filewriter and close them in the very ending.
Here is some code :


#include "utils/FileWriter.h"

#define DEBUG 1

void tp::utils::FileWriter::open(const char* path, tp::encoders::IEncoder* encoder) {
 int hr;

 debI("guessing");
 format = av_guess_format(nullptr, path, nullptr);
 if (!format){
 debI("av_guess_format");
 }

 debI("allocating output");
 hr = avformat_alloc_output_context2(&formatContext, format, nullptr, nullptr);
 if (hr < 0){
 debI("avformat_alloc_output_context2", hr);
 }

 debI("allocating stream");
 stream = avformat_new_stream(formatContext, nullptr);
 if (!stream){
 debI("avformat_new_stream");
 }
 debI("setting parameters");
 AVCodecParameters* parameters = avcodec_parameters_alloc();
 hr = avcodec_parameters_from_context(parameters, encoder->getCodecContext());
 if (hr < 0){
 debI("avcodec_parameters_from_context", hr);
 }

 stream->codecpar = parameters;

 debI("opening");
 hr = avio_open(&formatContext->pb, path, AVIO_FLAG_WRITE);
 if (hr < 0){
 debI("avio_open", hr);
 }

 debI("writing headers");
 hr = avformat_write_header(formatContext, nullptr);
 if (hr < 0){
 debI("avformat_write_header", hr);
 }
 debI("writer is set");
}

#define DEBUG 0

void tp::utils::FileWriter::saveNextPacket(AVPacket* packet) {
 int hr;

 hr = av_interleaved_write_frame(formatContext, packet);
 if (hr < 0){
 logF("av_write_frame", hr);
 }
}

void tp::utils::FileWriter::close() {
 int hr;

 hr = av_write_trailer(formatContext);
 if (hr < 0){
 logF("av_write_trailer", hr);
 }

 hr = avio_close(formatContext->pb);
 if (hr < 0){
 logF("avio_close", hr);
 }

 avformat_free_context(formatContext);
}




Here is the setup part of the encoder :


codec = avcodec_find_encoder(AV_CODEC_ID_H264);
 if (!codec){
 logF("avcodec_find_encoder", hr);
 }
 codecContext = avcodec_alloc_context3(codec);
 if (!codecContext){
 logF("avcodec_alloc_context3");
 }
 codecContext->width = parameters.width;
 codecContext->height = parameters.height;
 codecContext->bit_rate = parameters.bitRate;
 codecContext->time_base = (AVRational){1, parameters.fps};
 codecContext->gop_size = 0;
 codecContext->max_b_frames = 0;
 codecContext->pix_fmt = AV_PIX_FMT_YUV420P;
 if (parameters.preset == EncoderParameters::Preset::Fast){
 av_opt_set(codecContext->priv_data, "preset", "ultrafast", 0);
 }else if (parameters.preset == EncoderParameters::Preset::Slow){
 av_opt_set(codecContext->priv_data, "preset", "slow", 0);
 }

 hr = avcodec_open2(codecContext, codec, nullptr);
 if (hr < 0){
 logF("avcodec_open2", hr);
 }



The problem : I open "output.mp4" file and assume that the class properly saves the header of the file. However, the file weights 262 bytes (there is no useful data such as frames) and it is corrupted for running video on any video players
ps : I've enabled libav logging, which seems to be ok, despite some messages :


- 

- [file @ 0000017a74c6c540] Setting default whitelist 'file,crypto,data'
I have some concers about the appropriateness of the whitelist as no crypto is expected
- [AVIOContext @ 0000017a6a249100] Statistics : 266 bytes written, 2 seeks, 3 writeouts
The actual size of the file is 262. Does it mean that there are some info leaking during saving and even the header is already broken ?






I've tried to adjust various codec settings. Even turning off any speed presets. Actually, the encoder was tested in the pair with various libav decoders and image rendering and I'm pretty sure about encoder part.
Moreover, I've written the FileWriter code three times as there are some dissimilar guides. Only the current code does not throw any warnings or errors.
Give me a hint, which part of code may be wrong or provide me with some samples of using latest ffmpeg and answer my questions, please.


-
avcodec/ac3dec : Hardcode tables to save space
23 mai, par Andreas Rheinhardtavcodec/ac3dec : Hardcode tables to save space
The code to initialize the ungrouped bap mantissa tables
(bap 3 or 5) takes more bytes of .text than the tables itself ;
they have therefore been hardcoded.For GCC (14, -O3, albeit in an av_cold function), the initialization
code takes 99B each for the fixed and floating point decoders
(the code is currently duplicated), whereas the hardcoded tables
only take 96B. For Clang 19 it were 374B each (I don't now what
Clang was doing there).Signed-off-by : Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
-
How to save decoded raw rgba frames using ffmpeg ?
13 novembre 2019, par peetonnI need to transcode mp4 video to a raw video frames stored in a file.
I’m trying this command but it fails withUnable to find a suitable output format for 'test.rgba'
:ffmpeg -i test.mp4 -vcodec rawvideo -pix_fmt rgba -an test.rgba