Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
WriteVideoFrame() with Videocodec.Raw change pixel value
26 mai 2017, par Alex Gimondi
I'm using Accord.Video.ffmpeg to record a video in c#. It is actually a depth video with pixels indicating the depth magnitude. From depth array I create a bitmap and the save the bitmap with WriteVideoFrame method.
Afterward, I open the video in Matlab reading frame by frame. The problem is that I have differences between the bitmap in c# and the frame in Matlab?! The difference is more or less of 10 (in a range of 255 it's a big deal)(testing at the moment if it's constant).
Since from the bitmap to videoframe I do not perform any operation I think that the problem is in the video encoder. Is is possible even though the format is Raw?!
Hints?
Alex
UPDATEIf I run this code in a new project everything is fine
unsafe private void Button_Click_1(object sender, RoutedEventArgs e) { writerdepth.Open("testvideo.avi", 512, 424, 15, VideoCodec.Raw); for (int i = 0; i code>
going back to my code when I try to read the image instead of RGB = [100 100 100] I have [96 94 99].
My starting code is saving depth image from kinect v2, the function is called when a new valid frame arrives.
I have no idea of the reason for this difference... -
javafx show FFmpegFrameGrabber javacv
26 mai 2017, par Anastasia SisordiaI use org.bytedeco.javacv. Created
FFmpegFrameGrabber streamGrabber = new FFmpegFrameGrabber(filename);
When I use
CanvasFrame
i justgrab
thestreamGrabber
and convert thisframe
toBufferedImage
and show this imagecanvas.showImage(bi);
And this works perfect.
But if I want to show this image inside the
GridPane
, I convertBufferedImage
tojavafx.scene.image.Image
:Image image= SwingFXUtils.toFXImage(bi, null);
And my programm catch OutOfMemoryError .
May I add
Frame (org.bytedeco.javacv.Frame)
orBufferedImage
to myGridPane
without conver to image? What need to do? -
Muting ffmpeg warnings when loading video with OpenCV
26 mai 2017, par cbuchartI'm using OpenCV to process a set of MPEG videos. For some of them following warning is displayed when reading a frame or seeking (it is printed by the ffmpeg library).
[mpeg2video @ 026b0d20] warning: first frame is no keyframe
The thing is that such messages are printed together other valid output of my application and they are bothering final users. Is there any way to suppress such warning messages programmatically, other than re-coding the videos with an external tool?
I'm already muting the standard output and error, as well as using a custom (dummy) OpenCV error handler. Below a MCVE for testing.
PS: I understand the warning and actually the full project handles those scenarios so videos are correctly read.
Example code to reproduce the problem
#include
#include core/core.hpp> #include highgui/highgui.hpp> int handleError(int status, const char* func_name, const char* err_msg, const char* file_name, int line, void* userdata) { return 0; } int main() { std::cout << "Start!" << std::endl; cv::VideoCapture reader; if (!reader.open("Sample.mpg")) { std::cout << "Failed opening video" << std::endl; return 0; } cv::redirectError(handleError); std::cout.setstate(std::ios_base::failbit); std::cout << "std::cout mute test..." << std::endl; // OK, muted std::cerr.setstate(std::ios_base::failbit); std::cerr << "std::cerr mute test..." << std::endl; // OK, muted cv::Mat tmpImage; try { tmpImage = tmpImage * tmpImage; // OK, OpenCV error muted } catch (...) {} // Here the warning is printed reader.read(tmpImage); std::cout.clear(); std::cerr.clear(); std::cout << "Finished!" << std::endl; return 0; } The
Sample.mpg
video can be downloaded from the Internet Archive: https://archive.org/download/ligouHDR-HC1_sample1/Sample.mpgThis is the current output of the program:
I'm using VS 2010 and OpenCV 2.4.10. Following DLLs are the only ones with the executable (no other OpenCV-related DLL is reachable in the PATH).
- opencv_core2410.dll
- opencv_ffmpeg2410.dll
- opencv_highgui2410.dll
-
FFMPEG streaming in OSX via NSTask : Unknown input format : avfoundation
26 mai 2017, par SwatiIf i try to execute ffmpeg commands on terminal, things work fine however If i use ffmpeg binary in my xcode project and run ffmpeg command via NSTask then i get error.
Code:
NSString *str = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"ffmpeg-new"]; NSTask *task = [[NSTask alloc] init]; [task setLaunchPath:str]; NSArray *array = [NSArray arrayWithObjects: @"-f",@"avfoundation", @"-framerate",@"30", @"-i",@"0:0", @"-vcodec",@"h264", @"-acodec",@"aac", @"-ab",@"64000", @"-ar",@"48000", @"-ac",@"2", @"-f",@"flv",@"rtmp://url",nil]; [task setArguments:array]; [task launch]; [task waitUntilExit];
Error : unknown input format : avfoundation
-
WriteToUDP only works on same machine
26 mai 2017, par Anderson Scouto da SilvaThis script is intended to capture the output of ffmpeg and write to a UDP address.
It works correctly as I open the VLC 233.10.10.13:1234 and runs normally, but out of this computer the stream is not played, it's as if the stream does not exit from the machine to the multicast network, but on the same PC it works normally, I run the script go and open the VLC to run, it works perfectly.
To take the doubts that might be some problem in the interfaces, I made a VLC stream by capturing 233.1.1.13:1234 and exiting to 233.10.10.13:1234 and I can run anywhere outside the machine where VLC is, for example, in another VLC on another machine. It just does not work in the script I wrote on go.
Can anyone help?
package main import ( "os/exec" "io" "strings" "net" "net/url" "os" "github.com/juju/loggo" ) const ( BUFFER = 40 * 1024 DEBUG = true ) func verificaErro(e error) { if e != nil { logger.Errorf(e.Error()) } } var logger loggo.Logger func main() { initLogger() dir, _ := os.Getwd() // conexão UDP conn, err := net.ListenUDP("udp", &net.UDPAddr{IP: net.IPv4zero, Port: 0}) verificaErro(err) err = conn.SetWriteBuffer(BUFFER) verificaErro(err) inputSource := dir + "/in/teste-4k.mp4" inputSource = normalizeInputSource(inputSource) inputCodec := probeInputCodec(inputSource) outputCodec := probeOutputCodec(inputCodec) cmdName := "ffmpeg" argsPipe1 := []string{ "-hide_banner", "-loglevel", "panic", "-re", "-i", inputSource, "-preset", "superfast", "-c:v", inputCodec, "-crf", "0", "-c", "copy", "-f", outputCodec, "pipe:1", } cmdPipe1 := exec.Command(cmdName, argsPipe1...) logger.Debugf(strings.Join(argsPipe1, " ")) stdoutPipe1, err := cmdPipe1.StdoutPipe() verificaErro(err) err2 := cmdPipe1.Start() verificaErro(err2) chunk := make([]byte, BUFFER) for { nr, err5 := stdoutPipe1.Read(chunk) logger.Debugf("Lido %d bytes\n", nr) if nr > 0 { validData := chunk[:nr] nw, err6 := conn.WriteToUDP(validData, &net.UDPAddr{IP: net.IP{233, 10, 10, 13}, Port: 1234}) logger.Debugf("Escrito %d bytes\n", nw) verificaErro(err6) } if err5 != nil { // fim do arquivo if err5 == io.EOF { break } logger.Errorf("Erro = %v\n", err5) continue } } } func probeInputCodec(input string) string { cmdName := "ffprobe" args := []string{ "-v", "error", "-select_streams", "v:0", "-show_entries", "stream=codec_name", "-of", "default=noprint_wrappers=1:nokey=1", input, } out, err := exec.Command(cmdName, args...).Output() verificaErro(err) return strings.TrimSpace(string(out)) } func probeOutputCodec(inputCode string) string { switch inputCode { case "h264": return "mpegts" case "mpeg4": return "mpeg4" } return "mpegts" } func normalizeInputSource(inputSource string) (string) { isFile := false if _, err := os.Stat(inputSource); err == nil { isFile = true } if isFile { return inputSource } u, err := url.Parse(inputSource) verificaErro(err) if u.Scheme != "udp" && u.Scheme != "tcp" { errorMessage := "A entrada deve ser uma URL UDP/TCP ou um arquivo existente" logger.Errorf(errorMessage) os.Exit(1) } q := u.Query() if u.Scheme == "udp" { q.Set("overrun_nonfatal", "1") q.Set("fifo_size", "1000000") q.Set("buffer_size", "26214400") } u.RawQuery = q.Encode() return u.String() } func initLogger() { logger = loggo.GetLogger(loggo.DefaultWriterName) if DEBUG { logger.SetLogLevel(loggo.DEBUG) } else { logger.SetLogLevel(loggo.ERROR) } }