Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
some codecs (ie. libx264) cannot be reused after draining
7 avril, par NeddieAfter draining an encoder (by sending it a null frame and then receiving packets until EOF) it enters draining mode after which
avcodec_send_frame
will fail, returning EOF. You're supposed to callavcodec_flush_buffers
which among other things sets the internaldraining
flag to 0, allowingavcodec_send_frame
to work again. Unfortunately it checksAV_CODEC_CAP_ENCODER_FLUSH
first and if not set it returns without resetting thedraining
flag.So the only way to reuse the codec is to close and reopen it, which is wasteful, plus
avcodec_close
is deprecated. Am I missing something?int attribute_align_arg avcodec_send_frame(AVCodecContext *avctx, const AVFrame *frame) { AVCodecInternal *avci = avctx->internal; int ret; if (!avcodec_is_open(avctx) || !av_codec_is_encoder(avctx->codec)) return AVERROR(EINVAL); if (avci->draining) return AVERROR_EOF; if (avci->buffer_frame->buf[0]) return AVERROR(EAGAIN); if (!frame) { avci->draining = 1; } else { ret = encode_send_frame_internal(avctx, frame); if (ret < 0) return ret; } if (!avci->buffer_pkt->data && !avci->buffer_pkt->side_data) { ret = encode_receive_packet_internal(avctx, avci->buffer_pkt); if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) return ret; } avctx->frame_num++; return 0; } void avcodec_flush_buffers(AVCodecContext *avctx) { AVCodecInternal *avci = avctx->internal; if (av_codec_is_encoder(avctx->codec)) { int caps = avctx->codec->capabilities; if (!(caps & AV_CODEC_CAP_ENCODER_FLUSH)) { // Only encoders that explicitly declare support for it can be // flushed. Otherwise, this is a no-op. av_log(avctx, AV_LOG_WARNING, "Ignoring attempt to flush encoder " "that doesn't support it\n"); return; } ff_encode_flush_buffers(avctx); } else ff_decode_flush_buffers(avctx); avci->draining = 0; avci->draining_done = 0; if (avci->buffer_frame) av_frame_unref(avci->buffer_frame); if (avci->buffer_pkt) av_packet_unref(avci->buffer_pkt); if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME && !avci->is_frame_mt) ff_thread_flush(avctx); else if (ffcodec(avctx->codec)->flush) ffcodec(avctx->codec)->flush(avctx); }
-
How to automatically rotate video based on camera orientation while recording ?
7 avril, par jestrabikrI am developing Mediasoup SFU and client web app, on the server I am recording client's stream by sending it to FFmpeg as plain RTP. FFmpeg creates HLS recording (.m3u8 and .ts files), because I need to be able to switch between WebRTC live stream and HLS recording before live stream ends.
My problem is that, when I am testing the app and I rotate my phone 90 degrees, the recording's aspect ratio stays the same but the image is rotated (as shown on images 1.1, 1.2 and 1.3 below). I need for it to change aspect ratio dynamically according to camera orientation. How can I do that using FFmpeg?
On the live stream it works perfectly fine (as shown on the images - 2.1 and 2.2 below), when the phone is rotated, the aspect ration is changed and video is shown correctly. I think it works on live stream because maybe WebRTC is signaling orientation changes somehow (but it does not project to the recording).
These are my ffmpeg command arguments for recording (version 6.1.1-3ubuntu5):
let commandArgs = [ "-loglevel", "info", "-protocol_whitelist", "pipe,udp,rtp", "-fflags", "+genpts+discardcorrupt", "-reinit_filter", "1", "-strict", "-2", "-f", "sdp", "-i", "pipe:0", "-map", "0:v:0", "-c:v", "libx264", "-b:v", "1500k", "-profile:v", "high", "-level:v", "4.1", "-pix_fmt", "yuv420p", "-g", "30", "-map", "0:a:0", "-c:a", "aac", "-b:a", "128k", "-movflags", "+frag_keyframe+empty_moov", "-f", "hls", "-hls_time", "4", "-hls_list_size", "0", "-hls_flags", "split_by_time", `${filePath}.m3u8` ];
Image 1.1 - Portrait mode in recording:
Image 1.2 - Landscape mode in recording (rotated 90deg to my left side - front camera is on my left side):
Image 1.3 - Landscape mode in recording (rotated 90deg to my right side):
Image 2.1 - Portrait mode in live stream (correct behavior):
Image 2.2 - Landscape mode in live stream (correct behavior):
-
ffmpeg : error while loading shared libraries : libnppig.so.12 : cannot open shared object file on CentOS [closed]
7 avril, par Rahib RasheedI'm trying to install ffmpeg on a CentOS server, but I'm running into a shared library error when I try to run it:
ffmpeg: error while loading shared libraries: libnppig.so.12: cannot open shared object file: No such file or directory
Running ldd shows some missing dependencies:
ldd $(which ffmpeg) | grep libnpp libnppig.so.12 => not found libnppicc.so.12 => /lib64/libnppicc.so.12 libnppidei.so.12 => /lib64/libnppidei.so.12 libnppif.so.12 => not found libnppc.so.12 => /lib64/libnppc.so.12
I’ve tried searching for the missing libraries but couldn’t find the correct packages for CentOS. What’s the best way to resolve this issue?
-
Look for fastest video encoder with least lag to stream webcam streaming to ipad [closed]
7 avril, par kellyI'm looking for the fastest way to encode a webcam stream that will be viewable in a html5 video tag. I'm using a Pandaboard: http://www.digikey.com/product-highlights/us/en/texas-instruments-pandaboard/686#tabs-2 for the hardware. Can use gstreamer, cvlc, ffmpeg. I'll be using it to drive a robot, so need the least amount of lag in the video stream. Quality doesn't have to be great and it doesn't need audio. Also, this is only for one client so bandwidth isn't an issue. The best solution so far is using ffmpeg with a mpjpeg gives me around 1 sec delay. Anything better?
-
How to use the ffmpeg command to write the data of a .ts file into a named pipe on windows [duplicate]
7 avril, par qytI first tested creating a named pipe using C++. The code is as follows.
"\\\\.\\pipe\\mpegts", PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, PIPE_UNLIMITED_INSTANCES, 1024 * 1024 * 10, 1024 * 1024 * 10, 0, NULL); if (hPipe == INVALID_HANDLE_VALUE) { } Sleep(1000000);
Then I tried to write data using the command:
./ffmpeg -re -stream_loop -1 -i .\1.ts -c copy -f mpegts \\.\pipe\mpegts
However, I encountered an error:File '\\.\pipe\mpegts' already exists. Overwrite? [y/N] y [out#0/mpegts @ 0000027df35a6900] Error opening output \\.\pipe\mpegts: Permission denied Error opening output file \\.\pipe\mpegts. Error opening output files: Permission denied
Another situation, if I input n:
File '\\.\pipe\mpegts' already exists. Overwrite? [y/N] n Not overwriting - exiting Error opening output file \\.\pipe\mpegts
and How should I solve this problem?