Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
How to stream audio from ffserver
22 mai 2019, par DoroI trying to stream 2 files -
1.mkv
without audio (which streaming ok) and2.mkv
with audio encoded with Vorbis codec which i can't stream. For encoding I usedffmpeg -i 2.mp4 -strict -2 -c:a vorbis ex.mkv
And it playing ok with
ffplay
Server log:
Fri May 17 00:49:08 2019 Opening feed file '1.mkv' for stream 'test1-rtsp' Fri May 17 00:49:08 2019 [matroska,webm @ 0x200746c0]Unknown entry 0x55B0 Thu Dec 14 21:35:00 1950 [h264 @ 0x2007dcc0]gray chroma Fri May 17 00:49:08 2019 [h264 @ 0x2007dcc0]error while decoding MB 18 1, bytestream 1989 Fri May 17 00:49:08 2019 [h264 @ 0x2007dcc0]concealing 432 DC, 432 AC, 432 MV errors in I frame Fri May 17 00:49:08 2019 Opening feed file '2.mkv' for stream 'test2-rtsp' Fri May 17 00:49:08 2019 [matroska,webm @ 0x200746c0]Unknown entry 0x55B0 Fri May 17 00:49:08 2019 FFserver started. Fri May 17 00:49:25 2019 [matroska,webm @ 0x20080de0]Unknown entry 0x55B0 Fri May 17 00:49:25 2019 127.0.0.1:33582 - - "PLAY test2-rtsp/streamid=0 RTP/UDP" Fri May 17 00:49:25 2019 127.0.0.1 - - [SETUP] "rtsp://127.0.0.1:7654/test2-rtsp/ RTSP/1.0" 200 2553
Client log:
Bad packed header lengths (30,0,1250,2673) [udp @ 00000236f6318500] 'circular_buffer_size' option was set but it is not supported on this build (pthread support is required) [udp @ 00000236f63185c0] 'circular_buffer_size' option was set but it is not supported on this build (pthread support is required) [udp @ 00000236f633dc40] 'circular_buffer_size' option was set but it is not supported on this build (pthread support is required) [udp @ 00000236f634df00] 'circular_buffer_size' option was set but it is not supported on this build (pthread support is required) [rtsp @ 00000236f63153c0] method SETUP failed: 503 Service Unavailable rtsp://127.0.0.1:7654/test2-rtsp: Server returned 5XX Server Error reply
Configure ffserver file:
Port 8090 BindAddress 0.0.0.0 MaxHTTPConnections 2000 MaxClients 1000 MaxBandwidth 500000 CustomLog - NoDaemon RTSPPort 7654 RTSPBindAddress 0.0.0.0
Format rtp File "1.mkv" Format rtp Strict -2 AudioCodec vorbis File "2.mkv" -
Open CV Codec FFMPEG Error fallback to use tag 0x7634706d/'mp4v'
22 mai 2019, par CohenDoing a filter recording and all is fine. The code is running, but at the end the video is not saved as MP4. I have this error:
OpenCV: FFMPEG: tag 0x44495658/'XVID' is not supported with codec id 12 and format 'mp4 / MP4 (MPEG-4 Part 14)' OpenCV: FFMPEG: fallback to use tag 0x7634706d/'mp4v'
Using a MAC and the code is running correctly, but is not saving. I tried to find more details about this error, but wasn't so fortunate. I use as editor Sublime. The code run on Atom tough but is giving this error:
OpenCV: FFMPEG: tag 0x44495658/'XVID' is not supported with codec id 12 and format 'mp4 / MP4 (MPEG-4 Part 14)' OpenCV: FFMPEG: fallback to use tag 0x7634706d/'mp4v' 2018-05-28 15:04:25.274 Python[17483:2224774] AVF: AVAssetWriter status: Cannot create file
....
import numpy as np import cv2 import random from utils import CFEVideoConf, image_resize import glob import math cap = cv2.VideoCapture(0) frames_per_seconds = 24 save_path='saved-media/filter.mp4' config = CFEVideoConf(cap, filepath=save_path, res='360p') out = cv2.VideoWriter(save_path, config.video_type, frames_per_seconds, config.dims) def verify_alpha_channel(frame): try: frame.shape[3] # looking for the alpha channel except IndexError: frame = cv2.cvtColor(frame, cv2.COLOR_BGR2BGRA) return frame def apply_hue_saturation(frame, alpha, beta): hsv_image = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV) h, s, v = cv2.split(hsv_image) s.fill(199) v.fill(255) hsv_image = cv2.merge([h, s, v]) out = cv2.cvtColor(hsv_image, cv2.COLOR_HSV2BGR) frame = verify_alpha_channel(frame) out = verify_alpha_channel(out) cv2.addWeighted(out, 0.25, frame, 1.0, .23, frame) return frame def apply_color_overlay(frame, intensity=0.5, blue=0, green=0, red=0): frame = verify_alpha_channel(frame) frame_h, frame_w, frame_c = frame.shape sepia_bgra = (blue, green, red, 1) overlay = np.full((frame_h, frame_w, 4), sepia_bgra, dtype='uint8') cv2.addWeighted(overlay, intensity, frame, 1.0, 0, frame) return frame def apply_sepia(frame, intensity=0.5): frame = verify_alpha_channel(frame) frame_h, frame_w, frame_c = frame.shape sepia_bgra = (20, 66, 112, 1) overlay = np.full((frame_h, frame_w, 4), sepia_bgra, dtype='uint8') cv2.addWeighted(overlay, intensity, frame, 1.0, 0, frame) return frame def alpha_blend(frame_1, frame_2, mask): alpha = mask/255.0 blended = cv2.convertScaleAbs(frame_1*(1-alpha) + frame_2*alpha) return blended def apply_circle_focus_blur(frame, intensity=0.2): frame = verify_alpha_channel(frame) frame_h, frame_w, frame_c = frame.shape y = int(frame_h/2) x = int(frame_w/2) mask = np.zeros((frame_h, frame_w, 4), dtype='uint8') cv2.circle(mask, (x, y), int(y/2), (255,255,255), -1, cv2.LINE_AA) mask = cv2.GaussianBlur(mask, (21,21),11 ) blured = cv2.GaussianBlur(frame, (21,21), 11) blended = alpha_blend(frame, blured, 255-mask) frame = cv2.cvtColor(blended, cv2.COLOR_BGRA2BGR) return frame def portrait_mode(frame): cv2.imshow('frame', frame) gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) _, mask = cv2.threshold(gray, 120,255,cv2.THRESH_BINARY) mask = cv2.cvtColor(mask, cv2.COLOR_GRAY2BGRA) blured = cv2.GaussianBlur(frame, (21,21), 11) blended = alpha_blend(frame, blured, mask) frame = cv2.cvtColor(blended, cv2.COLOR_BGRA2BGR) return frame def apply_invert(frame): return cv2.bitwise_not(frame) while(True): # Capture frame-by-frame ret, frame = cap.read() frame = cv2.cvtColor(frame, cv2.COLOR_BGR2BGRA) #cv2.imshow('frame',frame) hue_sat = apply_hue_saturation(frame.copy(), alpha=3, beta=3) cv2.imshow('hue_sat', hue_sat) sepia = apply_sepia(frame.copy(), intensity=.8) cv2.imshow('sepia',sepia) color_overlay = apply_color_overlay(frame.copy(), intensity=.8, red=123, green=231) cv2.imshow('color_overlay',color_overlay) invert = apply_invert(frame.copy()) cv2.imshow('invert', invert) blur_mask = apply_circle_focus_blur(frame.copy()) cv2.imshow('blur_mask', blur_mask) portrait = portrait_mode(frame.copy()) cv2.imshow('portrait',portrait) if cv2.waitKey(20) & 0xFF == ord('q'): break # When everything done, release the capture cap.release() cv2.destroyAllWindows()
-
Overlaying a large image onto a small video like snapchat
22 mai 2019, par Tabassum LatifI want to add full screen overlay image on different size of video, I used ffmpeg it work fine if overlay and video has same scale ratio (same width and height). Overlay image squeezed if video height and width size is smaller than overlay image but i want to apply like snap chat video they add black view on top and bottom
Ffmpeg command is
String[]{"-y", "-i", filePath, "-i", overlayPath, "-preset", "ultrafast", "-filter_complex", "[1][0]scale2ref[i][m];[m][i]overlay[v]", "-map", "[v]", "-map", "0:a?", "-ac", "2", output};
I want following output link is mention below.
-
How to trim single ts file and concat with everything after with ffmpeg
22 mai 2019, par user3321348I have a number of ts files (h264, AAC) and I want to quickly cut out a portion without re-encoding more than the first chunk and last chunk. Then I want to concat them back together and make an mp4.
So I have 1.ts - 100.ts and each chunk is roughly 10 seconds. I want to cut from 1:05 to 10:05 minutes. I have code that finds the first and last ts file needed (let's say it's 11.ts for 1:05 and 61.ts for 10:05)
I run this to trim the first ts file to only the portion I need:
ffmpeg -i 11.ts -ss 5.0 -c:v libx264 -c:a aac 11.new.ts
Roughly the same thing happens to 61.ts to create 61.new.ts.
Now I want to concat 11.new.ts, 12.ts, 13.ts, ..., 61.new.ts into an mp4 without having to re-encode every single chunk. Currently, the resulting video plays the remaining portion of the first chunk just fine. After that point the audio continues but there's no more video. I'm sure that has something to do with start time offsets that's in the metadata of each ts file, but I can't figure out how to solve that. Is this even possible? And is this the best way to quickly do something like this?
-
I wanted to create video streaming website, but the problem that I want to hard sub
21 mai 2019, par hamad alafifiI want to hardsub all the movies and add watermark to them, I used ffmpeg once bu it’s slow, if you can recommend new way or how to use it faster.