Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
FFMPEG libraries segfault on Android — C# UNITY
26 mai 2017, par oT2I got a unity project which has to run on Android and Windows. To be able to decode raw H264 frames, I am using a ffmpeg wrapper, It works great on Windows but on Android I get a segmentation fault on av_log_default_callback, called by avcodec_decode_video2.
here is the backtrace :
05-26 10:47:45.224 24270 24286 F libc : Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 24286 (UnityMain) 05-26 10:47:45.224 463 463 W : debuggerd: handling request: pid=24270 uid=10152 gid=10152 tid=24286 05-26 10:47:45.332 24535 24535 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 05-26 10:47:45.332 24535 24535 F DEBUG : Revision: '0' 05-26 10:47:45.333 24535 24535 F DEBUG : ABI: 'arm' 05-26 10:47:45.333 24535 24535 F DEBUG : pid: 24270, tid: 24286, name: UnityMain >>> com.my.app <<< 05-26 10:47:45.333 24535 24535 F DEBUG : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 05-26 10:47:45.333 24535 24535 F DEBUG : r0 cf444220 r1 00000000 r2 00010000 r3 00000000 05-26 10:47:45.333 24535 24535 F DEBUG : r4 e9254b1c r5 00000010 r6 e9254b14 r7 e9255c90 05-26 10:47:45.333 24535 24535 F DEBUG : r8 c860f670 r9 cf444220 sl e925531c fp e9254f1c 05-26 10:47:45.333 24535 24535 F DEBUG : ip 000003f0 sp e9254ac0 lr cffa5518 pc 00000000 cpsr a8010010 05-26 10:47:45.339 24535 24535 F DEBUG : 05-26 10:47:45.339 24535 24535 F DEBUG : backtrace: 05-26 10:47:45.339 24535 24535 F DEBUG : #00 pc 00000000
05-26 10:47:45.339 24535 24535 F DEBUG : #01 pc 00018514 /data/app/com.my.app/lib/arm/libavutil-55.so 05-26 10:47:45.339 24535 24535 F DEBUG : #02 pc 000189f4 /data/app/com.my.app/lib/arm/libavutil-55.so (av_log_default_callback+168) 05-26 10:47:45.339 24535 24535 F DEBUG : #03 pc 00018d38 /data/app/com.my.app/lib/arm/libavutil-55.so (av_log+80) 05-26 10:47:45.339 24535 24535 F DEBUG : #04 pc 001bf538 /data/app/com.my.app/lib/arm/libavcodec-57.so 05-26 10:47:45.339 24535 24535 F DEBUG : #05 pc 001c4eac /data/app/com.my.app/lib/arm/libavcodec-57.so 05-26 10:47:45.339 24535 24535 F DEBUG : #06 pc 0038cce0 /data/app/com.my.app/lib/arm/libavcodec-57.so (avcodec_decode_video2+380) 05-26 10:47:45.339 24535 24535 F DEBUG : #07 pc 00003490 I had to replace pointers by refs in the prototypes of the imported ffmpeg functions, to fix a Marshal error saying structs are not blittable and that I should use refs instead :
avcodec_decode_video2(AVCodecContext *ctx, AVFrame *frame, int *gotPicture,......);
became :
avcodec_decode_video2(ref AVCodecContext ctx, ref AVFrame frame, ref int gotPicture,.......);
everything works fine on Windows, using refs instead of pointer had no incidence and functions are now correctly imported on Android.
If anyone has infos that could be helpful to my research or know someone who had this bug, please share thank you !
-
Why is my ffmpeg not playing after converting it to .avi format
26 mai 2017, par JeevaI muxed the video and audio and then converted it to avi. The converted file has a size of 20mb but when i open it says cannot play the video. I tried playing it on a mobile also. Initially i tried converting it to mp4 but i was getting error like
muxer does not support non seekable output Could not write header for output file
Below is the code what i used. Can someone please tell me the mistake i'm doing.$video = "C:\Users\user.folder\Downloads\video_with_no_audio.mp4"; $audio = "C:\Users\user.folder\Downloads\just_audio.mp3"; $cmd = FCPATH.'ffmpeg/bin'; $cmd1 = $cmd.'\ffmpeg -i '.$video.' -i '.$audio.' -y 2>&1 -f avi-'; header('Content-type: video/avi'); header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; filename=file.avi"); echo passthru($cmd1);exit;
I Even tried with the following code
$cmd1 = $cmd.'\ffmpeg -i '.$video.' -i '.$audio.' -c:v copy -c:a copy -y 2>&1 -f avi -';
-
How can I tell ffmpeg to write the file frame by frame ?
26 mai 2017, par krvlA little background. I am using
ffmpeg
to record video stream from a camera (using thertsp
protocol) to a file. In my command I specified options to limit the output file size and to re-encode the video format.
The command I'm using is something like this:ffmpeg -i rtsp://my_camera_url/ -acodec copy -vcodec mjpeg -t 00:20 -y output_file.mp4
I noticed that the output file stays open as long as the ffmpeg function is running, that is the file size is 0 and I can't reproduce that video in any player. But that file will be available when the ffmpeg function exits (wether I stop it manually or it reaches the time limit). This suggests me that ffmpeg first writes the video in memory and only later on the file-system.
Is there a way to force ffmpeg to write the video stream on the file-system so that I can look at the video in real time? I read ffmpeg documentation but I wasn't able to find anything related to this issue.
-
strange artifacts in image - where does a frame start ?
26 mai 2017, par user3387542We are live broadcasting a webcam stream. No audio, video only. The current command that works great:
# Direct replay works well: ffmpeg -f video4linux2 -r 10 -s 1280x720 -i /dev/video0 -c:v rawvideo -f rawvideo -pix_fmt yuv420p - | \ ffplay -f rawvideo -pixel_format yuv420p -video_size 1280x720 -framerate 10 -
but as soon as we try to send this data over the network (udp broadcast / gigabit lan) we are getting strange artefacts into the image.
# server command: ffmpeg -f video4linux2 -r 10 -s 1280x720 -i /dev/video0 -c:v rawvideo -f rawvideo -pix_fmt yuv420p - | \ socat - UDP-DATAGRAM:10.0.0.255:12345,broadcast # client command: socat -u udp-recv:12345,reuseaddr - | \ ffplay -f rawvideo -pixel_format yuv420p -video_size 1280x720 -framerate 10 -
Where do these artifacts come from and how to get rid of them? Does this has something to do with the client not knowing where a certain video frame starts?
We have chosen to stream raw video to reduce latency. The final goal would be to apply opencv tools to the video and react live depending on the situation. Which works great, as long as the camera is plugged in directly into this computer. But we need to set it apart and need multiple clients.
The camera used is a Microsoft® LifeCam Studio(TM).
$ v4l2-ctl -d 0 --list-formats ioctl: VIDIOC_ENUM_FMT Index : 0 Type : Video Capture Pixel Format: 'YUYV' Name : YUYV 4:2:2 Index : 1 Type : Video Capture Pixel Format: 'MJPG' (compressed) Name : Motion-JPEG Index : 2 Type : Video Capture Pixel Format: 'M420' Name : YUV 4:2:0 (M420)
Update
To narrow down the issue, I tried to split it up into different tasks:
1.0. Writing the stream to a file:
ffmpeg -f video4linux2 -r 10 -s 1280x720 -i /dev/video0 -c:v rawvideo -f rawvideo -pix_fmt yuv420p - > ~/deltemp/rawout
1.1. Reading the file: The result looks great, no artefacts:
cat ~/deltemp/rawout | ffplay -f rawvideo -pixel_format yuv420p -video_size 1280x720 -framerate 10 -
2.0 Starting the stream and broadcasting the stream as mentioned in the server command above
2.1 Writing the UDP stream to a file. And watching the file (artifacts are back again)
socat -u udp-recv:12345,reuseaddr - > ~/deltemp/rawout cat ~/deltemp/rawout | ffplay -f rawvideo -pixel_format yuv420p -video_size 1280x720 -framerate 10 -
As test 1 showed no artifacts and test 2 did, it must be something with udp packet loss.
Test 3: Reducing quality to 640x480 did not help either.
-
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...