
Recherche avancée
Médias (10)
-
Demon Seed
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Demon seed (wav version)
26 septembre 2011, par
Mis à jour : Avril 2013
Langue : English
Type : Audio
-
The four of us are dying (wav version)
26 septembre 2011, par
Mis à jour : Avril 2013
Langue : English
Type : Audio
-
Corona radiata (wav version)
26 septembre 2011, par
Mis à jour : Avril 2013
Langue : English
Type : Audio
-
Lights in the sky (wav version)
26 septembre 2011, par
Mis à jour : Avril 2013
Langue : English
Type : Audio
-
Head down (wav version)
26 septembre 2011, par
Mis à jour : Avril 2013
Langue : English
Type : Audio
Autres articles (54)
-
Configurer la prise en compte des langues
15 novembre 2010, parAccéder à la configuration et ajouter des langues prises en compte
Afin de configurer la prise en compte de nouvelles langues, il est nécessaire de se rendre dans la partie "Administrer" du site.
De là, dans le menu de navigation, vous pouvez accéder à une partie "Gestion des langues" permettant d’activer la prise en compte de nouvelles langues.
Chaque nouvelle langue ajoutée reste désactivable tant qu’aucun objet n’est créé dans cette langue. Dans ce cas, elle devient grisée dans la configuration et (...) -
Contribute to documentation
13 avril 2011Documentation is vital to the development of improved technical capabilities.
MediaSPIP welcomes documentation by users as well as developers - including : critique of existing features and functions articles contributed by developers, administrators, content producers and editors screenshots to illustrate the above translations of existing documentation into other languages
To contribute, register to the project users’ mailing (...) -
Use, discuss, criticize
13 avril 2011, parTalk to people directly involved in MediaSPIP’s development, or to people around you who could use MediaSPIP to share, enhance or develop their creative projects.
The bigger the community, the more MediaSPIP’s potential will be explored and the faster the software will evolve.
A discussion list is available for all exchanges between users.
Sur d’autres sites (6836)
-
Automate removing segments of a video using ffmpeg-python
12 décembre 2024, par Hriday NSI'm very new to ffmpeg and unable to wrap my head around the concepts entirely. My goal for this little script I've been working on all day is to :


Step 1 : Read a list of timestamps from a text file like so :


00:00 - 00:14


00:30 - 00:45


So that works : for me :


def read_timestamps(file_path):
 timestamps = []
 with open(file_path, 'r') as f:
 for line in f.readlines():
 match = re.match(r'(\d{1,2}):(\d{2}) - (\d{1,2}):(\d{2})', line.strip())
 if match:
 start = int(match.group(1)) * 60 + int(match.group(2)) # minutes:seconds -> total seconds
 end = int(match.group(3)) * 60 + int(match.group(4)) # minutes:seconds -> total seconds

 timestamps.append((start, end))
 return timestamps



Parsed timestamps : [(0, 14), (30, 45)] --------> CORRECT !


Step 2 : Remove or Cut-out those parts from the original video file "input.mkv"


Rather, virtually "remember" the segments that are important leaving out the cut-out parts.


# Function to split the video based on the timestamps (no intermediate files)
def split_video(input_file, timestamps):
 segments = []
 
 # Assuming the input file is a long video, and we are removing the timestamp ranges
 video_duration = ffmpeg.probe(input_file, v="error", select_streams="v:0", show_entries="format=duration")["format"]["duration"]
 video_duration = float(video_duration)

 # Now we split the video based on the timestamp ranges
 prev_end = 0
 for start, end in timestamps:
 if start < end:
 # The part we want to keep is from prev_end to the start of the timestamp
 if prev_end < start:
 segments.append((prev_end, start)) # Add the segment before the removal range
 prev_end = end # After the removal range, the video continues from 'end'
 else:
 print(f"Invalid timestamp range: {start} to {end}. Skipping this range.")
 
 # After processing all timestamps, add the remaining part from prev_end to the end of the video
 if prev_end < video_duration:
 segments.append((prev_end, video_duration)) # Last segment to the end of the video

 return segments




So for the above input, I correctly get the segments :


Segments : [(14, 30), (45, 2379.784)] -------------> CORRECT ! (yes, input video is 39+ mins long)


Step 3 : From the rest of the video clips that remain, I wanted to concatenate them all into a single "output.mp4", while ensuring that :


a. the concatenated video tracks transition with a cross-dissolve (or xfade in ffmpeg ?)


b. the concatenated audio tracks transition with a cross-fade (or afade in ffmpeg ?)


I was trying to see if hardcoded values worked because none of my loops were working and I was shooting in the dark. Atleast if I can get the hardcoded version to work, I can reverse-engineer a loop for it :



def concatenate_with_crossfade(input_file, segments, output_file):
 # Video inputs for two segments (start, end)
 input_video_1 = ffmpeg.input(input_file, ss=14, to=30) # Segment 1 video
 input_audio_1 = ffmpeg.input(input_file, ss=14, to=30) # Segment 1 audio

 input_video_2 = ffmpeg.input(input_file, ss=45, to=1000) # Segment 2 video
 input_audio_2 = ffmpeg.input(input_file, ss=45, to=1000) # Segment 2 audio


 filter_complex_str = (
 "[0:v][1:v]xfade=transition=fade:duration=1:offset=4[v1];" # Crossfade between video
 "[0:a]afade=type=out:duration=1:start_time=30[a1];" # Fade-out for first audio
 "[1:a]afade=type=in:duration=1:start_time=0[a2];" # Fade-in for second audio
 "[v1][a1][a2]concat=n=1:v=1:a=1[outv][outa]" # Concatenate the results
 )

 # Pass the filter_complex to the ffmpeg command
 ffmpeg.output(input_video_1, input_video_2, input_audio_1, input_audio_2, output_file,
 vcodec="libx264", acodec="aac", audio_bitrate="192k", 
 filter_complex=filter_complex_str, shortest=None).run()

# Main script
def main():
 input_file = 'input.mkv'
 timestamps_file = 'timestamps.txt'
 output_file = 'output.mp4'

 # Step 1: Read the timestamps
 timestamps = read_timestamps(timestamps_file)
 print(f"Parsed timestamps: {timestamps}")

 # Step 2: Split the video into segments based on the timestamps
 segments = split_video(input_file, timestamps)
 print(f"Segments to keep: {segments}")

 # Step 3: Concatenate with crossfade
 concatenate_with_crossfade(input_file, segments, output_file)

 print(f"Output saved to {output_file}")

# Run the script
if __name__ == "__main__":
 main()




Problems :


Throughout Step 3, all my attemps have been getting issues like :


[AVFilterGraph @ 0000013bf9904e80] More input link labels specified for filter 'concat' than it has inputs: 3 > 2
[AVFilterGraph @ 0000013bf9904e80] Error linking filters
Failed to set value '[0:v][1:v]xfade=transition=fade:duration=1:offset=4[v1];[0:a]afade=type=out:duration=1:start_time=30[a1];[1:a]afade=type=in:duration=1:start_time=0[a2];[v1][a1][a2]concat=n=1:v=1:a=1[outv][outa]' for option 'filter_complex': Invalid argument
Error parsing global options: Invalid argument



OR


[fc#0 @ 000001c1203d4ac0] Filter xfade:default has an unconnected output
Error binding filtergraph inputs/outputs: Invalid argument



OR


[AVFilterGraph @ 0000023dd82e4e80] More input link labels specified for filter 'concat' than it has inputs: 3 > 2
[AVFilterGraph @ 0000023dd82e4e80] Error linking filters
Failed to set value '[0:v][1:v]xfade=transition=fade:duration=1:offset=4[v1];[0:a]afade=type=out:duration=1:start_time=30[a1];[1:a]afade=type=in:duration=1:start_time=0[a2];[v1][a1][a2]concat=n=1:v=1:a=1[outv][outa]' for option 'filter_complex': Invalid argument
Error parsing global options: Invalid argument



OR


[aist#0:1/aac @ 000001b549c7bd00] Cannot decode a disabled input stream
[fc#0 @ 000001b549c748c0] Error binding an input stream to complex filtergraph input afade:default.
Error binding filtergraph inputs/outputs: Invalid argument



And I'm at a loss. Can anyone spot a mistake in the hardcoded filtergraph in the string filter_complex_str in step 3 - because I'm 90% sure I am messing that up in some way ? I would really appreciate your help on the matter ! Thank you !


-
Revision 71946 : Eviter des tests inutiles : Par exemple : [(#SET{titre, ...
11 avril 2013, par kent1@… — LogEviter des tests inutiles :
Par exemple :[(#SETtitre, <:accueil_site :>)] [(#ENVtitre|oui) #SETtitre, #ENV*titre|typo ]
devient
[(#SETtitre,[(#ENV*titre|typo|sinon<:accueil_site :>)])]
ou chaîner les tests avec le filtre |et{}
[(#ENVappel_menu|oui) [(#SESSIONid_auteur|>0|oui)...
devient
[(#ENVappel_menu|et#SESSIONid_auteur|>0|oui|oui)
On met également un rel="nofollow" sur le menu "espace_prive" sur le lien vers la page de login, évite d’avoir 2000 trucs indexés à cause du paramètre d’url &url=...
Version 1.4.3 -
How to decrypt SAMPLE-AES .m3u8 video streams ?
4 avril 2018, par Aaron WizzardI keep trying to download some HD videos that require a cable provider login (which is no problem), but I’m not able to download them because of the SAMPLE-AES encryption. The site uses HLS Streaming. When I try to use "video download helper" in Firefox, the error message says "HLS encryption method SAMPLE-AES is not supported"
I used this code in ffmpeg :
ffmpeg -i http://tve-vod.cdn.turner.com/adultswim/5219209fb9b00585da914ff30104c6e200000000/layer6/layer6_pt.m3u8 -c copy video.ts
Then I got this error message.
[hls,applehttp @ 05e07960] SAMPLE-AES encryption is not supported yet
[hls,applehttp @ 05e07960] Failed to open segment of playlist 0Can someone please help ? I used youtube-dl with some success, but it doesn’t give me the option to download the videos in HD. I also would love to github.com/selsta/hlsdl, but I don’t have a Linux/Unix computer to run it.