Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
Use ffmpeg to segment streaming video
7 juin 2016, par MarcSuppose I have a streaming video URL rtsp://whatever and I wish to store that video stream to my file system as a series of files off approximately the same size or duration. Ideally I would like to store the files with a start and stop timestamp as part of the filename, and each file should be such that it can stand on its own to be displayed as a video file if someone wants to view it. I understand that ffmpeg has a segment command option that allows me to segment by time and store in a series of files like outfile%3d.dat or whatever. But suppose I want to do this perpetually and cycle the files (age out old ones) when the total size of all the saved files exceeds a specific value. For example, suppose I want to save the most recent 500GB of video from this streaming URL and keep doing this day after day continuously into the distant future. What happens to the output filename after outfile999.dat is saved? Does the count start over at 0? Or does ffmpeg just stop or crash? Is there an ffmpeg command that can segment and age out old files, or is this something I would have to do running another program simultaneously or would I have to hack into ffmpeg itself to do this? I'm pretty new to ffmpeg so any suggestions you ffmpeg experts might have on how to do this would be welcome. I also welcome suggestions for other command line Linux tools that might be better for this application.
UPDATE: So it turns out that ffmpeg has a segmenter built in, and I can segment the files such that the filenames have the video start datetime as part of the filename. I used a command like this:
ffmpeg -i rtsp://camera_feed_url_here -c copy -f segment -segment_list out.list -segment_time 900 \ -segment_atclocktime 1 -strftime 1 "%Y-%m-%d_%H-%M-%S.mkv"
That's the good news. The bad news is that when I run this command, after about 1 minute it just throws this error and stops:
rtsp://camera_feed_url_here: Invalid data found when processing input
No other error or diagnostic mesages are printed out. Even when I run with -loglevel debug, it just seems to die with this error message.
When I built ffmpeg, used this:
./configure --enable-demux='rtsp,rtp,sdp,flac,gif,image2,image2pipe,matrosk' --enable-network --enable-protocols --enable-decoder=h264
Any ideas what I'm doing wrong and how I can make this error go away?
-
MoviePy/ffmpeg Progress Bar in Tkinter
7 juin 2016, par Alexander PerlmanMoviePy has a text-based progress indicator in my Sublime Text console. It looks like this:
0%| | 0/121 [00:00<?, ?it/s] 4%|4 | 5/121 [00:00<00:02, 42.43it/s] 8%|8 | 10/121 [00:00<00:02, 43.69it/s] 12%|#2 | 15/121 [00:00<00:02, 43.52it/s] 17%|#6 | 20/121 [00:00<00:02, 43.78it/s]
I want to pipe that progress to a text widget that I made in TKinter. I figured out how to send stdout to the textwidget, but these progress updates stay in Sublime.
Any input would be greatly appreciated. Thank you!
-
opencv cannot read MP4 file from sony camcorder
7 juin 2016, par JundongThe sony camcorder recorded video in MP4 format. I am reading the file by
import cv2 vid = cv2.VideoCapture('sample.MP4')
my OpenCV version is 2.4.8, as a Python module.
The codec of the 'sample.MP4' is H.264, Linear PCM.
ffprobe sample.MP4
returns:
> Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C0004.mp4': Metadata: > major_brand : XAVC > minor_version : 16785407 > compatible_brands: XAVCmp42iso2 > creation_time : 2016-06-06 13:41:51 Duration: 00:00:15.02, start: 0.000000, bitrate: 50439 kb/s > Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709/bt709/iec61966-2-4), 1920x1080 [SAR 1:1 DAR 16:9], > 48655 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default) > Metadata: > creation_time : 2016-06-06 13:41:51 > handler_name : Video Media Handler > encoder : AVC Coding > Stream #0:1(und): Audio: pcm_s16be (twos / 0x736F7774), 48000 Hz, 2 channels, s16, 1536 kb/s (default) > Metadata: > creation_time : 2016-06-06 13:41:51 > handler_name : Sound Media Handler > Stream #0:2(und): Data: none (rtmd / 0x646D7472), 245 kb/s (default) > Metadata: > creation_time : 2016-06-06 13:41:51 > handler_name : Timed Metadata Media Handler > Unsupported codec with id 0 for input stream 2
It seems that the codec for
h.264
is missing. The version of myFFmpeg
is3.0
.I tried
avconv -i sample.MP4 -c:a copy -c:v copy sample_converted.mp4
to convert the sample.MP4 to sample_converted.mp4, this command line did not work. The commandffmpeg -i sample.mp4 sample_converted.mp4
worked; however, it compromised the video quality badly.I used an online video converter: http://www.online-convert.com/ (which output nice quality video in mp4 format, but it has size limitation for free users) to convert the MP4 to mp4, the command in Terminal as below:ffprobe 'sample_converted.mp4'
returns
> Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C0001_converted.mp4': > Metadata: > major_brand : isom > minor_version : 512 > compatible_brands: isomiso2avc1mp41 > encoder : Lavf57.36.100 Duration: 00:00:02.02, start: 0.000000, bitrate: 16777 kb/s > Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 16801 kb/s, 59.94 > fps, 59.94 tbr, 60k tbn, 119.88 tbc (default) > Metadata: > handler_name : VideoHandler > Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default) > Metadata: > handler_name : SoundHandler
Obviously, the encoders, handler_names etc. of the sample.MP4 and sample_converted.mp4 are different. Any idea using FFmpeg or OpenCV to convert this raw video from camcorder to the readable format without compromising the video quality?
-
Is there a way to use EME with ClearKey encryption for HTML5 streaming protection ?
7 juin 2016, par user1152226I am trying to understand EME with Clear Key encryption. I am using MP4Box. From the documentation here, you specify decryption keys in an XML file that is used to encrypt/decrypt your mp4 files. https://gpac.wp.mines-telecom.fr/mp4box/encryption/common-encryption/
Basically, is there any point to EME with clear key encryption and is it possible to use this to protect content?
From my understanding, the encryption keys you specify in this XML, are the keys the clients need to use on the front end to decrypt the HTML5 audio/video streams. This means, at any time, the user could use a browser's dev tools to get the keys.
I suppose I could obfuscate the keys somehow, but anyone with determination would still be able to get the keys.
The other thing I could possibly do, is combine this with stream links that expire, but that also wouldn't project the keys.
I think you could also re-encrypt the media periodically, or encrypt the file multiple times with different keys, but that doesn't seem like it would scale well. Having a 1 time use key for each playback would be nice, but again, probably horribly inefficient.
Here is an example of an XML config for specific encryption keys:
<?xml version="1.0" encoding="UTF-8"?>
-
FFMpeg - Combine multiple filter_complex and overlay functions
7 juin 2016, par Mike JohnsonI am having trouble combining these 3 passes in ffmpeg into a single process.
Is this even possible?
Pass 1
ffmpeg -y -i C:\Users\MJ\Downloads\20151211_pmoney_pmpod.mp3 -loop 1 -i C:\Users\MJ\Documents\pm1080.png -filter_complex "[0:a]showwaves=s=1920x1080:mode=line,colorkey=0x000000:0.01:0.1,format=yuva420p[v];[1:v][v]overlay=0:270[outv]" -map "[outv]" -pix_fmt yuv420p -map 0:a -c:v libx264 -c:a copy -shortest C:\Users\MJ\Documents\20151211_pmoney_pmpod4.mp4
Pass 2
ffmpeg -i "C:\Users\MJ\Documents\20151211_pmoney_pmpod4.mp4" -vf drawtext="fontsize=50:fontcolor=white:fontfile=/Windows/Fonts/impact.ttf:text=Planet Money Podcast on NPR - A/B Split Testing:x=(w-text_w)/2:y=200" -acodec copy "C:\Users\MJ\Documents\20151211_pmoney_pmpod-overlay-text.mp4"
Pass 3
ffmpeg -i "C:\Users\MJ\Documents\20151211_pmoney_pmpod-overlay-text.mp4" -i C:\Users\MJ\Downloads\6.png -filter_complex "overlay=10:10" C:\Users\MJ\Documents\20151211_pmoney_pmpod-overlay-text1.mp4"
Thanks!