Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
SNAP : Simulation and Neuroscience Application Platform
19 avril, par S_SIs there any documentation/help manual on how to use SNAP (Simulation and Neuroscience Application Platform)1.
I wanted to run the Motor Imagery sample scenario with a .avi file for the stimulus instead of the image. How can that be done?
The following error is obtained when using the AlphaCalibration scenario which gives code to play an avi file.Any help appreciated
:movies:ffmpeg(warning): parser not found for codec indeo4, packets or times may be invalid. :movies:ffmpeg(warning): max_analyze_duration 5000000 reached at 5000000 :movies(error): Could not open /e/BCI_Feb2014/SNAP-master/src/studies/SampleStudy/bird.avi :audio(error): Cannot open file: /e/BCI_Feb2014/SNAP-master/src/studies/SampleStudy/bird.avi :audio(error): Could not open audio /e/BCI_Feb2014/SNAP-master/src/studies/SampleStudy/bird.avi :movies:ffmpeg(warning): parser not found for codec indeo4, packets or times may be invalid. :movies:ffmpeg(warning): max_analyze_duration 5000000 reached at 5000000 :movies(error): Could not open /e/BCI_Feb2014/SNAP-master/src/studies/SampleStudy/bird.avi :gobj(error): Texture "/e/BCI_Feb2014/SNAP-master/src/studies/SampleStudy/bird.avi" exists but cannot be read. Traceback (most recent call last): File "E:\BCI_Feb2014\SNAP-master\src\framework\latentmodule.py", line 458, in _run_wrap self.run() File "modules\BCI\AlphaCalibration.py", line 30, in run Exception during run(): m = self.movie(self.moviefile, block=False, scale=[0.7,0.4],aspect=1.125,contentoffset=[0,0],volume=0.3,timeoffset=self.begintime+t*self.awake_duration,looping=True) Could not load texture: bird.avi File "E:\BCI_Feb2014\SNAP-master\src\framework\basicstimuli.py", line 348, in movie tex = self._engine.base.loader.loadTexture(filename) File "E:\BCI_Feb2014\Panda3D-1.8.0\direct\showbase\Loader.py", line 554, in loadTexture raise IOError, message IOError: Could not load texture: bird.avi
-
Could not update timestamps for discarded samples
19 avril, par skltynveI have a function for decoding audio in
C
usingffmpeg
:int read_and_decode(const char *filename, float **audio_buffer, int *sample_rate, int *num_samples) { AVFormatContext *fmt_ctx = NULL; AVCodecContext *codec_ctx = NULL; AVCodec *codec; AVPacket packet; AVFrame *frame = av_frame_alloc(); if (!frame) { fprintf(stderr, "Could not allocate memory for AVFrame\n"); return -1; } int audio_stream_index = -1, ret; if (avformat_open_input(&fmt_ctx, filename, NULL, NULL) != 0) { fprintf(stderr, "Could not open the file: %s\n", filename); return -1; } if (avformat_find_stream_info(fmt_ctx, NULL) < 0) { fprintf(stderr, "Could not retrieve stream info\n"); avformat_close_input(&fmt_ctx); return -1; } for (int i = 0; i < fmt_ctx->nb_streams; i++) { if (fmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { audio_stream_index = i; codec = avcodec_find_decoder(fmt_ctx->streams[i]->codecpar->codec_id); if (!codec) { fprintf(stderr, "Unsupported codec!\n"); avformat_close_input(&fmt_ctx); return -1; } break; } } if (audio_stream_index < 0) { fprintf(stderr, "Could not find any audio stream in the file\n"); avformat_close_input(&fmt_ctx); return -1; } codec_ctx = avcodec_alloc_context3(codec); if (!codec_ctx) { fprintf(stderr, "Could not allocate audio codec context\n"); avformat_close_input(&fmt_ctx); return -1; } if (avcodec_parameters_to_context(codec_ctx, fmt_ctx->streams[audio_stream_index]->codecpar) < 0) { fprintf(stderr, "Could not copy codec parameters\n"); avcodec_free_context(&codec_ctx); avformat_close_input(&fmt_ctx); return -1; } if (avcodec_open2(codec_ctx, codec, NULL) < 0) { fprintf(stderr, "Could not open codec\n"); avcodec_free_context(&codec_ctx); avformat_close_input(&fmt_ctx); return -1; } *sample_rate = codec_ctx->sample_rate; *num_samples = 0; int buffer_capacity = codec_ctx->sample_rate; // for 1 second *audio_buffer = (float *)malloc(sizeof(float) * buffer_capacity); if (!*audio_buffer) { fprintf(stderr, "Failed to allocate memory for audio buffer\n"); avcodec_free_context(&codec_ctx); avformat_close_input(&fmt_ctx); return -1; } av_init_packet(&packet); while (av_read_frame(fmt_ctx, &packet) >= 0) { if (packet.stream_index == audio_stream_index) { ret = avcodec_send_packet(codec_ctx, &packet); if (ret < 0) { fprintf(stderr, "Error sending a packet for decoding\n"); break; } while (ret >= 0) { ret = avcodec_receive_frame(codec_ctx, frame); if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) { break; } else if (ret < 0) { fprintf(stderr, "Error during decoding\n"); break; } if (*num_samples + frame->nb_samples > buffer_capacity) { buffer_capacity += codec_ctx->sample_rate; float *temp_buffer = (float *)realloc(*audio_buffer, sizeof(float) * buffer_capacity); if (!temp_buffer) { fprintf(stderr, "Failed to reallocate memory for audio buffer\n"); free(*audio_buffer); av_frame_free(&frame); avcodec_free_context(&codec_ctx); avformat_close_input(&fmt_ctx); return -1; } *audio_buffer = temp_buffer; } for (int i = 0; i < frame->nb_samples; i++) { (*audio_buffer)[*num_samples + i] = ((float *)(frame->data[0]))[i]; } *num_samples += frame->nb_samples; } } av_packet_unref(&packet); } av_frame_free(&frame); avcodec_free_context(&codec_ctx); avformat_close_input(&fmt_ctx); return 0; }
But any audio I test ends up giving messages like this:
[mp3float @ ....] Could not update timestamps for skipped samples. [mp3float @ ....] Could not update timestamps for discarded samples. [mp3float @ ....] Could not update timestamps for skipped samples. [mp3float @ ....] Could not update timestamps for discarded samples.
What is wrong in my code? Please, point out mistakes if you see any...
-
Error trying to decode 4K video using NVDEC
19 avril, par NestorajI am trying to convert a 4K HEVC MKV file of 70GB into another HECV file but with less size. I am using FFmpeg with Nvidia acceleration but when I execute the following command an error appears:
ffmpeg -y -vsync 0 -hwaccel_device 0 -hwaccel cuvid -c:v hevc_cuvid -i input.mkv -c:a copy -c:v hevc_nvenc -preset slow -b:v 10M -bufsize 10M -maxrate 15M -qmin 0 -g 250 -bf 2 -temporal-aq 1 -rc-lookahead 20 -i_qfactor 0.75 -b_qfactor 1.1 output.mkv
The error is:
[hevc_nvenc @ 0000021036b0d000] Provided device doesn't support required NVENC features Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
The video file has these details:
It seems that FFmpeg cannot recognize my GPU as a supported device to decode but I have read that Nvidia has support for my card with NVDEC.
I am running Windows 10 64 bits with i7 4790 and GTX 1080
-
Problems with modifying encoder metadata with FFMPEG
19 avril, par yrcjeI'm trying to change FFMPEG encoder writing application with FFMPEG -metadata and for whatever reason, it's reading the input but not actually writing anything out.
-map_metadata -metadata:s:v:0 -metadata writing_application, basically every single stack overflow and stack exchange thread, but they all won't write to the file at all.
ffmpeg -i x.mp4 -s 1920x1080 -r 59.94 -c:v h264_nvenc -b:v 6000k -vf yadif=1 -preset fast -fflags +bitexact -flags:v +bitexact -flags:a +bitexact -ac 2 x.mp4 ffmpeg -i x.mp4 -c:v copy -c:a copy -metadata Encoder="TeXT Encoder" -fflags +bitexact -flags:v +bitexact -flags:a +bitexact test.mp4 ffmpeg -i x.mp4 -vcodec copy -acodec copy -map_metadata out.mp4 ffmpeg -i x.mp4 -vcodec copy -acodec copy -metadata encoder="Encoder" -metadata comment="XX" testmeta.mp4 ffmpeg -i x.ts -c:v copy -c:a copy -metadata:s:v:0 h264 ISFT='TeXT' x.mp4 ffmpeg -i x.mp4 -i FFMETADATAFILE -map_metadata 1 -codec copy testcopy.mp4 ffmpeg -i x.ts -f ffmetadata FF
METADATAFILE
I tried to extracting the data and rewrite it back with FFMETADATAFILE but it doesn't show up. Tried forcing ffmpeg to write without any emtadata and write it back but doesn't work. Was wondering if I can write my own encoder that writes the specific encoder name, like how Handbrake/Lavf writes the encoder application into the METADATA of the video file. Or just use FFMPEG and modify the METADATA natively.
-
Decoder error not supported error when render 360 video on web application
19 avril, par Mattia PompitaI'm developing a simple scene with A-Frame and React.JS where there is a videosphere that will create and render when video are fully loaded and ready to play.
My goal is to render 4k (to device who can reproduce it) video on videosphere to show at the users the environment. On desktop versions all works fine also with 4K videos while on mobile works only for 1920x1080.
I already check if my phone can render a 4k texture video and it can render untill 4096, I checked also that video.videoWidth are 4096.
The error I have is with decoder
MediaError {code: 4, message: 'DECODER_ERROR_NOT_SUPPORTED: video decoder initialization failed'}
This error will show only on mobile, I can see it through Chrome Developer tools, I already try to re-encode both with Handbrake and ffmpeg but always the same error will appear on mobile.
My video is hosted on Firebase and have this resolution 4096x2048 I'm testing on Google Pixel 7 already checked if WEBGL can render 4k texture on it
I can't understand why decoder works fine on Desktop and not on mobile only with 4k video and with 1920x1080 it works
This is the only component rendered on page
import React, { useEffect, useRef } from 'react'; const XIV_360_Abbazia_San_Silvestro_4K = () => { const assetsRef = useRef(null); const videoRef = useRef(null); const sceneRef = useRef(null); return ( > { console.log('CAN PLAY THROUGH'); let videoSphere = document.createElement('a-videosphere'); videoSphere.setAttribute('src', '#video360'); sceneRef.current.appendChild(videoSphere); }} /> > { videoRef.current.play(); }} > PLAY ); }; export default XIV_360_Abbazia_San_Silvestro_4K;