
Recherche avancée
Médias (1)
-
Publier une image simplement
13 avril 2011, par ,
Mis à jour : Février 2012
Langue : français
Type : Video
Autres articles (111)
-
Websites made with MediaSPIP
2 mai 2011, parThis page lists some websites based on MediaSPIP.
-
Creating farms of unique websites
13 avril 2011, parMediaSPIP platforms can be installed as a farm, with a single "core" hosted on a dedicated server and used by multiple websites.
This allows (among other things) : implementation costs to be shared between several different projects / individuals rapid deployment of multiple unique sites creation of groups of like-minded sites, making it possible to browse media in a more controlled and selective environment than the major "open" (...) -
Publier sur MédiaSpip
13 juin 2013Puis-je poster des contenus à partir d’une tablette Ipad ?
Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir
Sur d’autres sites (6489)
-
ffmpeg hls duation is wrong on m3u8
26 juin 2018, par HarisI am using ffmpeg to store the video in hls format using below command
~/bin/ffmpeg -r 15 -i rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov -codec copy -hls_list_size 65535 -hls_time 2 -g 2 "./live.m3u8"
where I am getting lists of ts file and live.m3u8 file. Note in above command the duration of hls file segment set 2 second.
Here is the content of live.m3u8
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:2
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:2,
live0.ts
#EXTINF:2,
live1.ts
#EXTINF:2,
live2.ts
#EXTINF:2,
live3.ts
#EXTINF:1,
live4.ts
#EXTINF:2,
live5.ts
#EXT-X-ENDLISTNote in above file the duration is not always 2 second and it varies. And When I check the duration of actual ts file segment using ffprob I am getting float value,
For example,
~/bin/ffprobe -i live3.ts -show_entries format=duration -v quiet -of csv="p=0"
gives
2.261556
And
~/bin/ffprobe -i live4.ts -show_entries format=duration -v quiet -of csv="p=0"
gives the duration
1.298256
It seems the ffmpeg file round the
float
value toint
and write to live.m3u8 file. This cause some problem in seeking the video file(seek to incorrect timestamp) and also the total duration of video file is always displayed less than the actual duration. For example, if I record the video for 2 hour, and open the live.m3u8 using vlc player, I can see that the video duration is displayed 1:45 min and I am able to seek up to 2 hours.What could be the issue,
ffmpeg version :
ffmpeg version git-2014-06-24-b52637c
Reference image
Edit :
I have updated the ffmpeg to newer version based on the instruction here https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu. But still some issue. Now the live.m3u8 files generates the timing information in float, but the value is not accurate.
For exampleThe m3u8 file generated is
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:3.200000,
live0.ts
#EXTINF:3.100000,
live1.ts
#EXTINF:3.100000,
live2.ts
#EXTINF:2.340000,
live3.ts
#EXT-X-ENDLISTand if I check the duration of
live0.ts
using the command~/bin/ffprobe -i live0.ts -show_entries format=duration -v quiet -of csv="p=0"
it print2.3333
where as in the playlist file it’s3.200000
.What could be the issue ?.
-
FFmpeg python doesn't merge
24 avril 2021, par MaLoLHDXI was making this youtube downloader GUI with Python : it asks for the URL, gives you a list with the possible quality settings and downloads the selected video file and the best audio file with youtube-dl. However, when I tell ffmpeg to merge the two separate downloaded files, it doesn't do anything and it doesn't say anything in the console either. Is there anything I'm missing ?


Here's the relevant part of the code (starts at line 153) :


#Adding input arguments for ffmpeg
 ffmpeg_video = ffmpeg.input(self.video_title)
 ffmpeg_audio = ffmpeg.input(self.audio_title)
 output_ffmpeg_title = './videos/' + self.youtube_title
 #Merging with ffmpeg
 out = ffmpeg.output(ffmpeg_video, ffmpeg_audio, output_ffmpeg_title, vcodec='copy', acodec='aac')
 out.run



Here's the full code :


import youtube_dl
import tkinter as tk
import operator
import ffmpeg
class GUI:
 def __init__(self):
 #Creating initial window
 self.window = tk.Tk()
 self.window.title('YTDL')
 self.window.geometry('300x70')
 
 self.urlbox = tk.Entry(self.window)
 self.urlbox.pack(padx=5,pady=5)
 #Creating download button, which will open the format selection window
 downbutton = tk.Button(self.window, text="Download", command= self.check_url)
 downbutton.pack(padx=5, pady=5)
 #Creating a variable to keep track of the point in the GUI options selection
 self.format_select_process = False
 
 self.window.mainloop()
 def check_url(self):
 #Saving selected URL to variable
 self.selected_url = self.urlbox.get()
 self.urlbox.delete(0, 'end')
 #If something was written in the URL box, try to go the next step
 if len(self.selected_url) != 0:
 self.get_formats(self.selected_url)
 else:
 print('URL box is empty!')
 def get_formats(self, x):
 with youtube_dl.YoutubeDL() as ydl:
 meta = ydl.extract_info(x, download=False)
 #Save formats from 'meta' to 'self.formats'
 self.formats = meta.get('formats', [meta])
 self.youtube_title = meta.get('title', [meta])
 #Creating two dictionaries for the list of format sizes and extensions
 self.f_list_size_dict = {}
 self.f_list_ext_dict = {}
 #Creating audio format list
 self.audio_format_list = []
 #For every format in self.formats, add its format, extension, fps and filesize to self.f_list
 for f in self.formats:
 self.f_list = '-' + f['format']+ ' -' + f['ext'] + ' -' + str(f['fps']) + ' ' + str(f['filesize'])
 if 'audio only' in f['format']:
 #Add an element to each dictonary whose name is the format ID and whose value is its filesize/extension
 self.f_list_size_dict[f['format'].split(' -')[0]] = f['filesize']
 self.f_list_ext_dict[f['format'].split(' -')[0]] = f['ext']
 #Add to the audio format list the current audio format ID
 self.audio_format_list.append(f['format'].split(' -')[0])
 print('Audio format list:')
 print(self.audio_format_list)
 print('Size list dict:')
 print(self.f_list_size_dict)
 print('Ext list size dict:')
 print(self.f_list_ext_dict)
 """
 #Making a new list which only contains the audio format IDs
 self.audio_format_list = str(self.f_list_size_dict.keys()).split('([')[1]
 self.audio_format_list = self.audio_format_list.split('])')[0]
 self.audio_format_list = self.audio_format_list.replace("'", "")
 self.audio_format_list = self.audio_format_list.split(', ')
 print('Cleaned up audio format list:')
 print(self.audio_format_list)
 """
 #Here the program starts looking for the best audio format
 #In the try block, the program gets the best audio format's ID from the size dict and extension from the ext dict
 #In the except block, the program gets the ID from the audio format list and the extension from the ext dict
 try:
 self.highest_audio = max(self.f_list_size_dict.items(), key=operator.itemgetter(1))[0]
 self.highest_audio_ext = self.f_list_ext_dict.get(self.highest_audio)
 print('Best audio format ID: ' + self.highest_audio)
 print('Best audio format extension: ' + self.highest_audio_ext)
 except:
 self.highest_audio = max(self.audio_format_list)
 self.highest_audio_ext = self.f_list_ext_dict.get(self.highest_audio)
 print(self.highest_audio)
 print(self.highest_audio_ext)
 #Going to next sted of the code, which renders the format choice window
 self.format_select()
 def format_select(self):
 self.window.withdraw()
 format_select_window = tk.Toplevel()
 format_select_window.attributes('-topmost', True)
 format_select_window.geometry("300x350")
 format_select_window_label = tk.Label(format_select_window, text="Select the video format")
 format_select_window_label.pack(padx=5, pady=5)
 format_select_window.protocol('WM_DELETE_WINDOW', lambda: exit())

 self.format_listbox = tk.Listbox(format_select_window, height=15, width=40, yscrollcommand=1)
 self.format_listbox.pack(padx=10, pady=10)
 for index, item in enumerate(self.f_list):
 self.f_list_lenght = index
 download_button = tk.Button(format_select_window, text='Download', command=self.download)
 download_button.pack(padx=10, pady=10)
 #Adding options to the listbox
 for f in self.formats:
 #If it is adding an audio only format, it will add the ID, filesize (if possible with try block) and extension
 if 'audio only' in f['format'] + ' ' + str(f['fps']) + ' FPS ' + f['ext']:
 try:
 mb_filesize = round(f['filesize'] / 1024 / 1024, 2)
 self.format_listbox.insert(self.f_list_lenght, f['format'] + ' ' + str(mb_filesize) + ' MiB ' + f['ext']) 
 except:
 self.format_listbox.insert(self.f_list_lenght, f['format'] + ' ' + f['ext'])
 #If it is adding a video format, it will add the ID, FPS, filesize (if possible with the try block) and extension
 else:
 try:
 mb_filesize = round(f['filesize'] / 1024 / 1024, 2)
 self.format_listbox.insert(self.f_list_lenght, f['format'] + ' ' + str(f['fps']) + ' FPS' + ' ' + str(mb_filesize) + ' MiB ' + f['ext'])
 except:
 self.format_listbox.insert(self.f_list_lenght, f['format'] + ' ' + str(f['fps']) + ' FPS ' + f['ext'])
 def download(self):
 #Getting the list position of the selected format
 selected_format_list_position = self.format_listbox.curselection()
 #Getting the text of the selected format list item
 selected_format = self.format_listbox.get(selected_format_list_position)
 print('Selected format: ' + selected_format)
 #Cutting from the selected format list item text everything past ' -' to only get the format's ID
 selected_format_id = selected_format.split(' -')[0]
 print('Selected format ID: ' + selected_format_id)
 #Converting the ID to string
 final_selected_format_id = str(selected_format_id)
 print('Final selected format: ' + final_selected_format_id)
 #Cutting from the selected format list item text everything before ' ' to only get the extension
 final_ext = selected_format.split(' ')[1]
 print('Final video extension: ' + final_ext)
 if 'audio only' in selected_format:
 #Creating the download options dictionary (not working):
 #Setting the download location to the videos folder,
 #preventing the program from downloading a whole playlist,
 #telling youtube-dl to extract audio ('x'),
 #giving youtube-dl the requested format (which is only audio).
 self.ydl_opts = {'outtmpl':'./videos/%(title)s.%(ext)s', 'noplaylist': True, 'x': True, 'format': final_selected_format_id}
 #Downloading
 with youtube_dl.YoutubeDL(self.ydl_opts) as ydl:
 ydl.download([self.selected_url])
 elif 'audio only' not in selected_format:
 #Adding '+bestaudio' to the selected format ID (which is only a video ID in this case)
 final_selected_format_id_video_audio = str(selected_format_id) + '+bestaudio'
 #Creating the download options dictionary:
 #Setting the download location to the videos folder,
 #preventing the program from downloading a whole playlist,
 #giving youtube-dl the requested format with audio.
 self.ydl_opts = {'outtmpl':'./videos/%(title)s.%(ext)s', 'noplaylist': True, 'format': final_selected_format_id_video_audio}
 #Predicting the video file title and location for future ffmpeg merge
 self.video_title = './videos/' + self.youtube_title + '.f' + str(selected_format_id) + '.' + final_ext
 print('Video file title: ' + self.video_title)
 #Predicting the audio file title and location for future ffmpeg merge
 self.audio_title = './videos/' + self.youtube_title + '.f' + str(self.highest_audio) + '.' + self.highest_audio_ext
 print('Audio file title: ' + self.audio_title)
 #Downloading with youtube-dl
 with youtube_dl.YoutubeDL(self.ydl_opts) as ydl:
 ydl.download([self.selected_url])
 #Adding input arguments for ffmpeg
 ffmpeg_video = ffmpeg.input(self.video_title)
 ffmpeg_audio = ffmpeg.input(self.audio_title)
 output_ffmpeg_title = './videos/' + self.youtube_title
 #Merging with ffmpeg
 ffmpeg.output(ffmpeg_video, ffmpeg_audio, output_ffmpeg_title, vcodec='copy', acodec='aac')
GUI()



If there is a better way of integrating ffmpeg with youtube-dl in Python, please tell me.


-
How to record depth stream from realsense L515
22 avril 2022, par BilalI have a depth camera (Intel Realsense L515) and I do like to record a video of the depth.


I have seen this answer which is using FFMPEG, but I didn't know how to replicate it in my case !


I'm using this code :


import cv2
import numpy as np
import pyrealsense2 as rs
import time

pipeline = rs.pipeline()
config = rs.config()

"""
# Depth Mode
"""
# Resolution
res = [(1024, 768), (640, 480), (320, 240)]
resolution = res[0]
print("RealSense Resolution:{}\n".format(resolution))

# # initialize video writer
fourcc = cv2.VideoWriter_fourcc('F','F','V','1')
fps = 30
video_filename = 'output.avi'
out = cv2.VideoWriter(video_filename, fourcc, fps, resolution, False)


config.enable_stream(rs.stream.depth, resolution[0], resolution[1], rs.format.z16, 30)
profile = config.resolve(pipeline)
# Start streaming
pipeline.start(config)

# Declare sensor object and set options
depth_sensor = profile.get_device().first_depth_sensor()
depth_sensor.set_option(rs.option.visual_preset, 5) # 5 is short range, 3 is low ambient light
depth_sensor.set_option(rs.option.receiver_gain, 8)
depth_sensor.set_option(rs.option.pre_processing_sharpening, 0.0)
depth_sensor.set_option(rs.option.post_processing_sharpening, 3.0)
depth_sensor.set_option(rs.option.laser_power, 100)
depth_sensor.set_option(rs.option.confidence_threshold, 2)
# Get the sensor once at the beginning. (Sensor index: 1)

# # Filters
threshold_filter = rs.threshold_filter(min_dist=1.2, max_dist=1.4)
temporal_filter = rs.temporal_filter(smooth_alpha=0.1, smooth_delta = 9.0,persistence_control=7)

try:
 # # Filters
 threshold_filter = rs.threshold_filter(min_dist=1.2, max_dist=1.4)
 temporal_filter = rs.temporal_filter(smooth_alpha=0.1, smooth_delta = 75.0,persistence_control=0)

 tic = time.time()

 while True:
 # Wait for depth frames:
 frames = pipeline.wait_for_frames()
 depth_frame = frames.get_depth_frame()
 if not depth_frame:
 continue

 #------------
 # # FILTERS |
 #------------

 depth_frame = threshold_filter.process(depth_frame)
 depth_frame = temporal_filter.process(depth_frame)

 # Convert images to numpy arrays
 depth_array = np.asanyarray(depth_frame.get_data())
 # depth_array = np.asanyarray(colorizer.colorize(depth_frame).get_data())

 out.write(depth_array)
 toc = time.time()
 if(round(toc - tic) > 30):
 break

finally:
 out.release()
 pipeline.stop()



And getting this error :




out.write(depth_array)
cv2.error : OpenCV(4.5.4) /tmp/pip-req-build-kneyjnox/opencv/modules/videoio/src/cap_ffmpeg.cpp:186 : error : (-215:Assertion failed) image.depth() == CV_8U in function 'write'




Can you please tell me how can I record the depth from my camera ? thanks in advance.