
Recherche avancée
Médias (1)
-
MediaSPIP Simple : futur thème graphique par défaut ?
26 septembre 2013, par
Mis à jour : Octobre 2013
Langue : français
Type : Video
Autres articles (64)
-
Le profil des utilisateurs
12 avril 2011, parChaque utilisateur dispose d’une page de profil lui permettant de modifier ses informations personnelle. Dans le menu de haut de page par défaut, un élément de menu est automatiquement créé à l’initialisation de MediaSPIP, visible uniquement si le visiteur est identifié sur le site.
L’utilisateur a accès à la modification de profil depuis sa page auteur, un lien dans la navigation "Modifier votre profil" est (...) -
Configurer la prise en compte des langues
15 novembre 2010, parAccéder à la configuration et ajouter des langues prises en compte
Afin de configurer la prise en compte de nouvelles langues, il est nécessaire de se rendre dans la partie "Administrer" du site.
De là, dans le menu de navigation, vous pouvez accéder à une partie "Gestion des langues" permettant d’activer la prise en compte de nouvelles langues.
Chaque nouvelle langue ajoutée reste désactivable tant qu’aucun objet n’est créé dans cette langue. Dans ce cas, elle devient grisée dans la configuration et (...) -
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 (...)
Sur d’autres sites (5280)
-
libavcodec/ffmpeg reports two channels when decoding, but segfaults when trying to access the second
1er décembre 2017, par AstrognomeI am attempting to decode an audio file into raw pcm data using FFMpeg’s libavcodec. I have the following code so far, but it segfaults when trying to access the second audio channel for some reason.
#include
#include
#include <ao></ao>ao.h>
#include
#include <libavutil></libavutil>opt.h>
#include <libavcodec></libavcodec>avcodec.h>
#include <libavformat></libavformat>avformat.h>
#include <libswresample></libswresample>swresample.h>
#define BUF_SIZE 4096
#define AUDIO_INBUF_SIZE 20480
#define AUDIO_REFILL_THRESH 4096
int decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, uint8_t* out_data, int* index) {
int i, ch;
int ret, data_size;
ret = avcodec_send_packet(dec_ctx, pkt);
if (ret < 0) {
fprintf(stderr, "Error submitting packet to decoder\n");
exit(1);
}
while (ret >= 0) {
ret = avcodec_receive_frame(dec_ctx, frame);
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
return 0;
}
else if (ret < 0) {
fprintf(stderr, "Error during decoding\n");
exit(1);
}
data_size = av_get_bytes_per_sample(dec_ctx->sample_fmt);
if (data_size < 0) {
fprintf(stderr, "Failed to calculate data size\n");
exit(1);
}
for (i = 0; i < frame->nb_samples; ++i)
for (ch = 0; ch < dec_ctx->channels; ++ch) {
//Things go wrong here...
memcpy(out_data + *index, frame->data[ch] + (data_size*i), data_size);
*index += data_size;
}
}
return 0;
}
int decode_audio_file(const char* path, uint8_t* out_data, int size) {
const AVCodec *codec;
AVCodecContext *c = NULL;
AVCodecParserContext *parser = NULL;
int len, ret;
FILE *f;
uint8_t inbuf[AUDIO_INBUF_SIZE + AV_INPUT_BUFFER_PADDING_SIZE];
uint8_t *data;
size_t data_size;
AVPacket *pkt;
AVFrame *decoded_frame = NULL;
avcodec_register_all();
pkt = av_packet_alloc();
codec = avcodec_find_decoder(AV_CODEC_ID_FLAC);
if (!codec) {
fprintf(stderr, "Codec not found!\n");
return -1;
}
parser = av_parser_init(codec->id);
if (!parser) {
fprintf(stderr, "Parser not found!\n");
return -1;
}
c = avcodec_alloc_context3(codec);
if (!c) {
fprintf(stderr, "Could not allocate audio context!\n");
return -1;
}
if(avcodec_open2(c, codec, NULL) < 0) {
fprintf(stderr, "Could not open codec\n");
exit(1);
}
f = fopen(path, "rb");
if(!f) {
fprintf(stderr, "Could not open %s\n", path);
exit(1);
}
data = inbuf;
data_size = fread(inbuf, 1, AUDIO_INBUF_SIZE, f);
int index = 0;
while (data_size > 0) {
if (!decoded_frame) {
if (!(decoded_frame = av_frame_alloc())) {
fprintf(stderr, "Could not allocate audio frame\n");
exit(1);
}
}
ret = av_parser_parse2(parser, c, &pkt->data, &pkt->size, data, data_size, AV_NOPTS_VALUE, AV_NOPTS_VALUE, 0);
if (ret < 0) {
fprintf(stderr, "Error while parsing\n");
exit(1);
}
data += ret;
data_size -= ret;
if (pkt->size)
decode(c, pkt, decoded_frame, out_data, &index);
if (data_size < AUDIO_REFILL_THRESH) {
memmove(inbuf, data, data_size);
data = inbuf;
len = fread(data + data_size, 1, AUDIO_INBUF_SIZE - data_size, f);
if (len > 0)
data_size += len;
}
}
avcodec_free_context(&c);
av_parser_close(parser);
av_frame_free(&decoded_frame);
av_packet_free(&pkt);
return 0;
}
int main(int argc, char **argv)
{
int bsize = 1024*1024*60;
uint8_t* audio_buffer = calloc(bsize, sizeof(uint8_t));
decode_audio_file("testsong.flac", audio_buffer, bsize);
}Here is the offending line :
memcpy(out_data + *index, frame->data[ch] + (data_size*i), data_size);
If you access
frame->data[0]
it’s fine, but if you attempt to accessframe->data[1]
it segfaults. The context reports two channels and the file contains two channels (tried with several different tracks).
But it gets even weirder. If I switch the offending line tomemcpy(out_data + *index, frame->data[0] + (data_size*i*2 + ch), data_size);
it will have the left channel with correct data and the right channel is white noise.
This tells me (and I could be wrong) that the first channel actually contains 2 channels of audio interleaved, the actual left channel, plus a junk channel of white noise.
I was wrong, I forgot to multiplech
bydata_size
. If the line ismemcpy(out_data + *index, frame->data[0] + (data_size*i*2 + ch*data_size), data_size);
things seem to work as expected. This all still seems very sketchy though so if anyone can thoroughly explain what’s happening here, that would be nice.I have been working off the decode_audio example available in the ffmpeg documentation here although modified slightly.
This ALSO happens if I use the vanilla example with the only change being setting the codec to FLAC, so I assume it’s a bug in the library. In that case, how can I work around it.
-
ffmpeg commad with colorchannelmixer
12 décembre 2013, par bindalI am using following command :
command = "ffmpeg -y -i "+strFinalPath+" -vf colorchannelmixer=.3 :.4 :.3:0 :.3 :.4 :.3:0 :.3 :.4 :.3 "+strRotatePath ;But this command exit with error code 1
is there any mistake in this command
Please suggest me
Thanks
-
ffprobe to bitrate variable stopped working
6 novembre 2023, par BricktopI have a simple script to encode a video using the same bitrate as the original. I use ffprobe to fetch the bitrate like this :


ffprobe "%file%" -v 0 -select_streams v:0 -show_entries stream=bit_rate -print_format compact=p=0:nokey=1 >%temp%\bitrate.txt



However, while fixing a but in the script where I had an odd number of
"
marks, I suddenly ran into this problem with ffprobe :

Argument ' -v 0 -select_streams v:0 -show_entries stream=bit_rate -print_format compact=p=0:nokey=1 >C:\Users\ADMINI~1\AppData\Local\Temp\bitrate.txt' provided as input filename, but 'D:\VIDEO\AMBIANCE\SCOPITONE\MUSIC TELEVISION\This Here - Calm - OFFICIAL VIDEO (1080p 25fps AV1-128kbit AAC).mp4' was already specified.



I am trying to understand this, scanning insanely for yet another
"
or something in my code but can't figure it out. Here is the full code :

:: write file to queue (first)
move /y "%~dpn0.txt" "%temp%\%~n0.tmp" >nul
echo "%~1" >"%~dpn0.txt"
type "%temp%\%~n0.tmp" >>"%~dpn0.txt"

:: desyncronize instances (todo: try support for adding 9 files at a time)
timeout /t %time:~9,1% /nobreak
:: if not first instance exit
tasklist /fi "imagename eq handbrakecli.exe" | find /i "handbrakecli" && exit
title Transcode

:: delegate queue
for /f "delims=" %%f in (%~dpn0.txt) do (
 set "name=%%~nf"
 set "file=%%~f"
 rem todo: if file has x264 or other video codec mentioned, change to x265
 set "code=%%~dpnf (x265 transcoded)%%~xf"
 call :transcode
)
echo all done!
exit /b

:transcode
title "%name%"
if not exist "%file%" echo %date% %time% source file missing %file% >>%~dpn0.log & goto cleanup
if exist "%code%" echo %date% %time% target file exists %file% >>%~dpn0.log & goto cleanup

:: determine appropriate bitrate (does not seem to work on .webm files, closing the script as a result)
%~dp0ffprobe "%file%" -v 0 -select_streams v:0 -show_entries stream=bit_rate -print_format compact=p=0:nokey=1 >%temp%\bitrate.txt
set /p bitrate=<%temp%\bitrate.txt
:: reduce to full kilobytes
set "bitrate=%bitrate:~0,-3%"
if not defined bitrate echo failed to fetch bitrate & echo %date% %time% no bitrate for %file% >>%~dpn0.log & exit /b
if %bitrate% gtr 7000 set bitrate=7000

:: transcode
%~dp0HandBrakeCLI -i "%file%" -o "%code%" --encoder x265_10bit --encoder-preset slow --encoder-profile main444-10 --vb %bitrate% --two-pass --turbo --audio 1-9 --aencoder copy --audio-copy-mask aac,ac3,mp2,mp3,opus --audio-fallback opus --ab 160 --drc 2.0

:: remove current file from queue, regardless
:cleanup
findstr /v /c:"%file%" "%~dpn0.txt" >"%temp%\%~n0.tmp"
move /y "%temp%\%~n0.tmp" "%~dpn0.txt"



It appears that the
set "file=%%~f"
is the problem, somehow it shows up asset "file=D:\VIDEO\this video here.mp4" "
where the last two characters"
should not belong, and I don't know what to change to fix this.

Every type of improvement to the script is very welcomed !