
Recherche avancée
Médias (1)
-
GetID3 - Bloc informations de fichiers
9 avril 2013, par
Mis à jour : Mai 2013
Langue : français
Type : Image
Autres articles (58)
-
La sauvegarde automatique de canaux SPIP
1er avril 2010, parDans le cadre de la mise en place d’une plateforme ouverte, il est important pour les hébergeurs de pouvoir disposer de sauvegardes assez régulières pour parer à tout problème éventuel.
Pour réaliser cette tâche on se base sur deux plugins SPIP : Saveauto qui permet une sauvegarde régulière de la base de donnée sous la forme d’un dump mysql (utilisable dans phpmyadmin) mes_fichiers_2 qui permet de réaliser une archive au format zip des données importantes du site (les documents, les éléments (...) -
Script d’installation automatique de MediaSPIP
25 avril 2011, parAfin de palier aux difficultés d’installation dues principalement aux dépendances logicielles coté serveur, un script d’installation "tout en un" en bash a été créé afin de faciliter cette étape sur un serveur doté d’une distribution Linux compatible.
Vous devez bénéficier d’un accès SSH à votre serveur et d’un compte "root" afin de l’utiliser, ce qui permettra d’installer les dépendances. Contactez votre hébergeur si vous ne disposez pas de cela.
La documentation de l’utilisation du script d’installation (...) -
Automated installation script of MediaSPIP
25 avril 2011, parTo overcome the difficulties mainly due to the installation of server side software dependencies, an "all-in-one" installation script written in bash was created to facilitate this step on a server with a compatible Linux distribution.
You must have access to your server via SSH and a root account to use it, which will install the dependencies. Contact your provider if you do not have that.
The documentation of the use of this installation script is available here.
The code of this (...)
Sur d’autres sites (8964)
-
avcodec/vp8 : Fix wrong vpx_rac_is_end() check
16 novembre 2022, par Hirokazu Hondaavcodec/vp8 : Fix wrong vpx_rac_is_end() check
The check of vpx_rac_is_end check(s) are added originally from
1afd246960202917e244c844c534e9c1e3c323f5. It causes a regression
of some vp8 stream. b6b9ac5698c8f911841b469af77199153278c55c fixes
the regression by a sort of band-aid way. This fixes the wrongness
of the original commit. vpx_rac_is_end() should be called against
the bool decoder for the vp8 headr context, not one for each
coefficient. Reference is vp8_dixie_tokens_process_row() in token.c
in spec 20.16.Fixes : Ticket 8069
Fixes : regression of 1afd246960202917e244c844c534e9c1e3c323f5.
Fixes : b6b9ac5698c8f911841b469af77199153278c55cCo-authored-by : Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by : Hirokazu Honda <hiroh@chromium.org>
Signed-off-by : Ronald S. Bultje <rsbultje@gmail.com> -
ffmpeg output gives file not found error in python
20 octobre 2022, par Batuhan YılmazTrying to build an auto subtitled video generator in Python. But couldn't generate the subtitled video of the input video using ffmpeg. Getting an error saying there is no output.mp4. FileNotFoundError : [Errno 2] No such file or directory : 'C :\Users\batuh\Desktop\auto-multipage\output.mp4'


Can you help me out ? Full code is here : https://github.com/BatuhanYilmaz26/auto-sub-exp/blob/main/pages/02_up3.py


Here's the parts where I used ffmpeg :


def inferecence(loaded_model, uploaded_file, task):
 with open(f"{save_dir}/audio.mp3" , "wb") as f:
 f.write(uploaded_file.read())
 audio = ffmpeg.input(f"{save_dir}/audio.mp3")
 audio = ffmpeg.output(audio, f"{save_dir}/output.wav", acodec="pcm_s16le", ac=1, ar="16k")
 ffmpeg.run(audio, overwrite_output=True)
 if task == "Transcribe":
 options = dict(task="transcribe", best_of=5)
 results = loaded_model.transcribe(f"{save_dir}/output.wav", **options)
 vtt = getSubs(results["segments"], "vtt", 80)
 srt = getSubs(results["segments"], "srt", 80)
 lang = results["language"]
 return results["text"], vtt, srt, lang
 elif task == "Translate":
 options = dict(task="translate", best_of=5)
 results = loaded_model.transcribe(f"{save_dir}/output.wav", **options)
 vtt = getSubs(results["segments"], "vtt", 80)
 srt = getSubs(results["segments"], "srt", 80)
 lang = results["language"]
 return results["text"], vtt, srt, lang
 else:
 raise ValueError("Task not supported")
 
 results = inferecence(loaded_model, input_file, task)
 
 subprocess.run(shlex.split(f"ffmpeg -i {save_dir}/input.mp4 -i {save_dir}/output.wav -i transcript.srt -c:v copy -c:a copy -c:s copy -map 0:a -map 1:v -map 2:s -metadata:s:a:0 language={results[3]} -y {save_dir}/output.mp4"))
 #subprocess.run(shlex.split(f"ffmpeg -i {save_dir}/input.mp4 -vf {save_dir}/transcript.srt -y {save_dir}/output.mp4"))
 with open(os.path.join(os.getcwd(), "output.mp4"), "rb") as f:
 data = f.read()
 st.video(data)
 st.download_button(label="Download Subtitled Video",
 data=data,
 file_name="output.mp4")



sorry about the indentations


Logfile :


ffmpeg started on 2022-10-20 at 23:43:53
Report written to "ffmpeg-20221020-234353.log"
Command line:
ffmpeg -i C:UsersbatuhDesktopauto-multipagepageslocaloutput/input.mp4 -i C:UsersbatuhDesktopauto-multipagepageslocaloutput/output.wav -i transcript.srt -c:v copy -c:a copy -c:s copy -map 0:a -map 1:v -map 2:s -metadata:s:a:0 "language=eng" -y C:UsersbatuhDesktopauto-multipagepageslocaloutput/output.mp4 -report
ffmpeg version 4.2.3 Copyright (c) 2000-2020 the FFmpeg developers
 built with gcc 9.3.1 (GCC) 20200523
 configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
 libavutil 56. 31.100 / 56. 31.100
 libavcodec 58. 54.100 / 58. 54.100
 libavformat 58. 29.100 / 58. 29.100
 libavdevice 58. 8.100 / 58. 8.100
 libavfilter 7. 57.100 / 7. 57.100
 libswscale 5. 5.100 / 5. 5.100
 libswresample 3. 5.100 / 3. 5.100
 libpostproc 55. 5.100 / 55. 5.100
Splitting the commandline.
Reading option '-i' ... matched as input url with argument 'C:UsersbatuhDesktopauto-multipagepageslocaloutput/input.mp4'.
Reading option '-i' ... matched as input url with argument 'C:UsersbatuhDesktopauto-multipagepageslocaloutput/output.wav'.
Reading option '-i' ... matched as input url with argument 'transcript.srt'.
Reading option '-c:v' ... matched as option 'c' (codec name) with argument 'copy'.
Reading option '-c:a' ... matched as option 'c' (codec name) with argument 'copy'.
Reading option '-c:s' ... matched as option 'c' (codec name) with argument 'copy'.
Reading option '-map' ... matched as option 'map' (set input stream mapping) with argument '0:a'.
Reading option '-map' ... matched as option 'map' (set input stream mapping) with argument '1:v'.
Reading option '-map' ... matched as option 'map' (set input stream mapping) with argument '2:s'.
Reading option '-metadata:s:a:0' ... matched as option 'metadata' (add metadata) with argument 'language=eng'.
Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'.
Reading option 'C:UsersbatuhDesktopauto-multipagepageslocaloutput/output.mp4' ... matched as output url.
Reading option '-report' ... matched as option 'report' (generate a report) with argument '1'.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option y (overwrite output files) with argument 1.
Applying option report (generate a report) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input url C:UsersbatuhDesktopauto-multipagepageslocaloutput/input.mp4.
Successfully parsed a group of options.
Opening an input file: C:UsersbatuhDesktopauto-multipagepageslocaloutput/input.mp4.
[NULL @ 000001fba186b9c0] Opening 'C:UsersbatuhDesktopauto-multipagepageslocaloutput/input.mp4' for reading
[file @ 000001fba186c140] Setting default whitelist 'file,crypto'
C:UsersbatuhDesktopauto-multipagepageslocaloutput/input.mp4: No such file or directory



-
ffmpeg video encoder skips first frames [duplicate]
19 octobre 2022, par Eduard BarnoviciuI am new to ffmpeg. I am trying to run this simple video encoding example :



#include <iostream>
#include <vector>
// FFmpeg
extern "C" {
#include <libavformat></libavformat>avformat.h>
#include <libavcodec></libavcodec>avcodec.h>
#include <libavutil></libavutil>imgutils.h>
#include <libswscale></libswscale>swscale.h>
}
// OpenCV
#include <opencv2></opencv2>opencv.hpp>
#include <opencv2></opencv2>highgui.hpp>


int main(int argc, char* argv[])
{
 if (argc < 2) {
 std::cout << "Usage: cv2ff <outfile>" << std::endl;
 return 1;
 }
 const char* outfile = argv[1];

 // av_log_set_level(AV_LOG_DEBUG);
 int ret;

 const int dst_width = 640;
 const int dst_height = 480;
 const AVRational dst_fps = {30, 1};

 // initialize OpenCV capture as input frame generator
 cv::VideoCapture cvcap(0);
 if (!cvcap.isOpened()) {
 std::cerr << "fail to open cv::VideoCapture";
 return 2;
 }
 cvcap.set(cv::CAP_PROP_FRAME_WIDTH, dst_width);
 cvcap.set(cv::CAP_PROP_FRAME_HEIGHT, dst_height);
 cvcap.set(cv::CAP_PROP_FPS, dst_fps.num);
 // some device ignore above parameters for capturing image,
 // so we query actual parameters for image rescaler.
 const int cv_width = cvcap.get(cv::CAP_PROP_FRAME_WIDTH);
 const int cv_height = cvcap.get(cv::CAP_PROP_FRAME_HEIGHT);
 const int cv_fps = cvcap.get(cv::CAP_PROP_FPS);

 // open output format context
 AVFormatContext* outctx = nullptr;
 ret = avformat_alloc_output_context2(&outctx, nullptr, nullptr, outfile);
 if (ret < 0) {
 std::cerr << "fail to avformat_alloc_output_context2(" << outfile << "): ret=" << ret;
 return 2;
 }

 // create new video stream
 AVCodec* vcodec = avcodec_find_encoder(outctx->oformat->video_codec);
 AVStream* vstrm = avformat_new_stream(outctx, vcodec);
 if (!vstrm) {
 std::cerr << "fail to avformat_new_stream";
 return 2;
 }

 // open video encoder
 AVCodecContext* cctx = avcodec_alloc_context3(vcodec);
 if (!vstrm) {
 std::cerr << "fail to avcodec_alloc_context3";
 return 2;
 }
 cctx->width = dst_width;
 cctx->height = dst_height;
 cctx->pix_fmt = vcodec->pix_fmts[0];
 cctx->time_base = av_inv_q(dst_fps);
 cctx->framerate = dst_fps;
 if (outctx->oformat->flags & AVFMT_GLOBALHEADER)
 cctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
 ret = avcodec_open2(cctx, vcodec, nullptr);
 if (ret < 0) {
 std::cerr << "fail to avcodec_open2: ret=" << ret;
 return 2;
 }
 avcodec_parameters_from_context(vstrm->codecpar, cctx);

 // initialize sample scaler
 SwsContext* swsctx = sws_getContext(
 cv_width, cv_height, AV_PIX_FMT_BGR24,
 dst_width, dst_height, cctx->pix_fmt,
 SWS_BILINEAR, nullptr, nullptr, nullptr);
 if (!swsctx) {
 std::cerr << "fail to sws_getContext";
 return 2;
 }

 // allocate frame buffer for encoding
 AVFrame* frame = av_frame_alloc();
 frame->width = dst_width;
 frame->height = dst_height;
 frame->format = static_cast<int>(cctx->pix_fmt);
 ret = av_frame_get_buffer(frame, 32);
 if (ret < 0) {
 std::cerr << "fail to av_frame_get_buffer: ret=" << ret;
 return 2;
 }

 // allocate packet to retrive encoded frame
 AVPacket* pkt = av_packet_alloc();

 // open output IO context
 ret = avio_open2(&outctx->pb, outfile, AVIO_FLAG_WRITE, nullptr, nullptr);
 if (ret < 0) {
 std::cerr << "fail to avio_open2: ret=" << ret;
 return 2;
 }

 std::cout
 << "camera: " << cv_width << 'x' << cv_height << '@' << cv_fps << "\n"
 << "outfile: " << outfile << "\n"
 << "format: " << outctx->oformat->name << "\n"
 << "vcodec: " << vcodec->name << "\n"
 << "size: " << dst_width << 'x' << dst_height << "\n"
 << "fps: " << av_q2d(cctx->framerate) << "\n"
 << "pixfmt: " << av_get_pix_fmt_name(cctx->pix_fmt) << "\n"
 << std::flush;

 // write media container header (if any)
 ret = avformat_write_header(outctx, nullptr);
 if (ret < 0) {
 std::cerr << "fail to avformat_write_header: ret=" << ret;
 return 2;
 }

 cv::Mat image;

 // encoding loop
 int64_t frame_pts = 0;
 unsigned nb_frames = 0;
 bool end_of_stream = false;
 for (;;) {
 if (!end_of_stream) {
 // retrieve source image
 cvcap >> image;
 cv::imshow("press ESC to exit", image);
 if (cv::waitKey(33) == 0x1b) {
 // flush encoder
 avcodec_send_frame(cctx, nullptr);
 end_of_stream = true;
 }
 }
 if (!end_of_stream) {
 // convert cv::Mat(OpenCV) to AVFrame(FFmpeg)
 const int stride[4] = { static_cast<int>(image.step[0]) };
 sws_scale(swsctx, &image.data, stride, 0, image.rows, frame->data, frame->linesize);
 frame->pts = frame_pts++;
 // encode video frame
 ret = avcodec_send_frame(cctx, frame);
 if (ret < 0) {
 std::cerr << "fail to avcodec_send_frame: ret=" << ret << "\n";
 break;
 }
 }
 while ((ret = avcodec_receive_packet(cctx, pkt)) >= 0) {
 // rescale packet timestamp
 pkt->duration = 1;
 av_packet_rescale_ts(pkt, cctx->time_base, vstrm->time_base);
 // write encoded packet
 av_write_frame(outctx, pkt);
 av_packet_unref(pkt);
 std::cout << nb_frames << '\r' << std::flush; // dump progress
 ++nb_frames;
 }
 if (ret == AVERROR_EOF)
 break;
 };
 std::cout << nb_frames << " frames encoded" << std::endl;

 // write trailer and close file
 av_write_trailer(outctx);
 avio_close(outctx->pb);

 av_packet_free(&pkt);
 av_frame_free(&frame);
 sws_freeContext(swsctx);
 avcodec_free_context(&cctx);
 avformat_free_context(outctx);
 return 0;
}
</int></int></outfile></vector></iostream>


The problem is, while using codecs such as HEVC, H265 or VP9, the encoder always drops first 27 frames.


More exactly, at line 163 :


while ((ret = avcodec_receive_packet(cctx, pkt)) >= 0) {



ret is equal to -11 and it doesn't go inside the while loop. From that point onward it's always equal to 0 and no issues are found.


If I use MPEG4 for example, ret is 0 from the start and no frames are dropped.