
Recherche avancée
Médias (1)
-
Revolution of Open-source and film making towards open film making
6 octobre 2011, par
Mis à jour : Juillet 2013
Langue : English
Type : Texte
Autres articles (47)
-
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 -
Contribute to translation
13 avril 2011You can help us to improve the language used in the software interface to make MediaSPIP more accessible and user-friendly. You can also translate the interface into any language that allows it to spread to new linguistic communities.
To do this, we use the translation interface of SPIP where the all the language modules of MediaSPIP are available. Just subscribe to the mailing list and request further informantion on translation.
MediaSPIP is currently available in French and English (...) -
HTML5 audio and video support
13 avril 2011, parMediaSPIP uses HTML5 video and audio tags to play multimedia files, taking advantage of the latest W3C innovations supported by modern browsers.
The MediaSPIP player used has been created specifically for MediaSPIP and can be easily adapted to fit in with a specific theme.
For older browsers the Flowplayer flash fallback is used.
MediaSPIP allows for media playback on major mobile platforms with the above (...)
Sur d’autres sites (7602)
-
streaming an mkv file while processing with ffmpeg
2 avril 2019, par Phani RithvijWhat I want to do :
- I want to play an mkv video in Firefox.
- But Firefox doesn’t support the mkv format.
So I’ve searched a lot and found that,
I could stream instead of playing the video following these steps.- mkv can be converted to an m3u8 using FFmpeg
- The m3u8 points towards ts segment files
- then use hls.js on the browser side to play the video
But the catch is I want to do this programmatically.
What I actually want to do :
Steps
-
the client uploads a huge (>1 GB) mkv file to the client’s server (server is the client’s machine itself)
-
after the upload is done,
-
client requests to play the video.
-
the server starts transcoding and sends the client the m3u8 stream immediately instead of making the client wait for the transcoding to complete.
-
the client should be able to seek the video. (the most IMPORTANT part)
It is possible as Emby and Plex both have implemented it.
I was able to get this to work in chrome as it supports playing some mkv files.
I wrote a node js server that acceptsRange
header and pseudo-streams the video.But as I’ve mentioned Firefox says NO to mkv.
So I tried the hls thing but I couldn’t quite get the command to generate the stream and also play on the fly.
I started this on a command line
ffmpeg -i ../stream.mkv -hls_list_size 0 -acodec copy -vcodec copy file.m3u8
and a simple
http-server
on another shell instanceMy index.html file
<code class="echappe-js"><script src='http://stackoverflow.com/feeds/tag/hls.js'></script><script><br />
var video = document.getElementById('video');<br />
if(Hls.isSupported()) {<br />
var hls = new Hls();<br />
hls.loadSource('file.m3u8');<br />
hls.attachMedia(video);<br />
hls.on(Hls.Events.MANIFEST_PARSED,function() {<br />
video.play();<br />
});<br />
} else if (video.canPlayType('application/vnd.apple.mpegurl')) {<br />
video.src = 'file.m3u8';<br />
video.addEventListener('loadedmetadata',function() {<br />
video.play();<br />
});<br />
}<br />
</script>and while it was running I went ahead and requested the server.
I was able to get the video but It only seeks as far it’s converted into the ts files.
And it’s random and the video length keeps increasing. It won’t play sometimes and after the FFmpeg is done converting to m3u8 the video plays if I refresh the webpage.
I think this has to do with the continuous overwriting of the m3u8 file.
is there a way to predetermine the file contents of m3u8 and fill it up ?I want to be able to seek even further and somehow spawn another FFmpeg process
to start from that timestamp of the video ? How could I approach the seeking part ?So what I’d like to do again is
- I want to request the server to play a video file
- It spawns a child process FFmpeg that does the transcoding
- Sends the client the stream
- The client should be able to seek to the end and it should play the thing.
-
HEVC to mp4 video converter
7 juillet 2023, par Rahul RanjanWhile converting files HEVC to mp4 using python the error is comming by ffmpeg. I have used moviepy to convert video to mp4 formate.


Used moviepy Package to convert but throwing error


import os
from moviepy.editor import VideoFileClip

def convert_to_mp4(input_file, output_file):
 try:
 clip = VideoFileClip(input_file)
 codec = 'libx264' # Default codec is libx264
 if clip.reader.codec_name == 'hevc':
 codec = 'libx265'
 clip.write_videofile(output_file, codec=codec, audio_codec='aac')
 return True
 except Exception as e:
 print(f"Error converting video: {str(e)}")
 return False

def upload_and_convert(input_file_path, output_folder):
 if os.path.exists(input_file_path):
 # Convert to MP4
 mp4_file_path = os.path.join(output_folder, 'converted2.mp4')
 success = convert_to_mp4(input_file_path, mp4_file_path)

 if success:
 print(f"Conversion successful. MP4 saved at {mp4_file_path}")
 return mp4_file_path # Return the path of the converted MP4 file
 else:
 print("Failed to convert the video.")
 return None
 else:
 print("Input file not found.")
 return None

input_file_path = '/Downloads/sample-hevc-file.hevc'
output_folder = '/Downloads'
download_link = upload_and_convert(input_file_path, output_folder)

if download_link:
 print(f"Download the converted MP4 file here: {download_link}")



Error


rror converting video: MoviePy error: failed to read the duration of file C:/Users/kjrah/Downloads/sample-hevc-file.hevc.
Here are the file infos returned by ffmpeg:

ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
 built with gcc 9.2.1 (GCC) 20200122
 configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
 libavutil 56. 31.100 / 56. 31.100
 libavcodec 58. 54.100 / 58. 54.100
 libavformat 58. 29.100 / 58. 29.100
 libavdevice 58. 8.100 / 58. 8.100
 libavfilter 7. 57.100 / 7. 57.100
 libswscale 5. 5.100 / 5. 5.100
 libswresample 3. 5.100 / 3. 5.100
 libpostproc 55. 5.100 / 55. 5.100
Input #0, hevc, from 'C:/Users/kjrah/Downloads/sample-hevc-file.hevc':
 Duration: N/A, bitrate: N/A
 Stream #0:0: Video: hevc (Main), yuv420p(tv), 320x240 [SAR 1:1 DAR 4:3], 15 fps, 15 tbr, 1200k tbn, 15 tbc
At least one output file must be specified

Failed to convert the video.



Throwing this error except HEVC mostly files are working fine.


-
Translating code snippet function from c++ to python, using ffmpeg to crop imageFile [closed]
5 octobre 2022, par MinaiThe code above is written in C++. It takes an input image file and crops its imageHeight and Width using ffmpeg libray, and saves the output image fractures to a txt file. I want the same code written in python. The fractures are saved using the new name of the original file plus the crop size to differentiate each image grid.


void shatterImages(string imagefiles, int imgWidth, int imgHeight, 
 int cropSizeW, int cropSizeH)
{
 cout << "Calculating subimage fractures for " << imagefiles << " fullframe images..." << endl;
 if(!imagefiles.isnull()){
 string outputCommand="";
 int i,j;
 ofstream myfile2 ("outputfile.txt");
 if (myfile2.is_open()) {
 //cout << "Fracturing: " << imagefiles << endl;
 outputCommand = "ffmpeg";
 for (i = 0; i < ceil(imgWidth / (0.0+cropSizeW)); i += 1) //loop vert over image
 {
 for (j = 0; j < ceil(imgHeight / (0.0+cropSizeH)); j += 1) //loop horizontally over image
 {
 //replace shattered images from fullframes to subframes
 outputCommand +=
 " -i " + imagefiles + " -qscale:v 1 -vf \"crop=" + to_string(cropSizeW) + ":" +
 to_string(cropSizeH) + ":" + to_string(i * cropSizeW) + ":" + to_string(j * cropSizeH) +
 "\" " + imagefiles.substr(0, imagefiles.length() - 4) + "-" +
 to_string(i * cropSizeW) + "-" + to_string(j * cropSizeH) + ".jpg";
 }
 }
 //print(outputCommand)
 myfile2 << outputCommand << endl;
 myfile2.close();
 cout << "Finished writing to: fractureAllImages.sh" << endl;
 }
 else
 cout << "Unable to open output file for: fractureAllImages.sh" << endl;
 }
}



I Transalted into python like this but I am getting an error :


import csv
from csv import reader, writer
from math import ceil
import string

#Using context managers to open file
with open ("coral.txt", 'w') as infile:
 outputFile = writer(infile)

 # writes to the file
 #infile.write('Test me, 123, abc, xyz')

 
#creating the main fucntion
def coral (imageFiles, imageWidth, imageHeight, cropWidth, cropHeight):
 print("calculating the subimage fractures for", imageFiles, "full frame images")
 
 if imageFiles != None:
 def outputCommand (i, j):
 outputFile.write("coral.txt")
 if (infile is open):
 print ("fracturing:", imageFiles)
 outputCommand = "ffmpeg"
 
 #looping vertically over the image
 for (i = 0, i < ceil(imageWidth/(0.0+cropWidth), i++)){

 #Looping horizontally over the image
 for (int j = 0; j(0.0+cropWidth); j++)){

 #replace shattered images from fullframes to subframes and saving
 outputCommand += " -i " + imageFiles + " -qscale:v 1 -vf \"crop=" + to_string(cropWidth) + ":" + to_string(cropHeight) + ":" + to_string(i * cropWidth) + ":" + to_string(j * cropHeight) + "\" " + imageFiles.substr(0, imageFiles.length() - 4) + "-" + to_string(i * cropWidth) + "-" + to_string(j * cropHeight) + ".jpg";
 
 }

 }


 
 #printing to the file coral.txt
 infile(outputCommand)
 infile.close() 
 print("Finnished writing to text file")
 

 else:
 print("Unable to open output file for fracturing")


#remember to close opened files
outputFile.close()