Recherche avancée

Médias (0)

Mot : - Tags -/configuration

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (109)

  • Des sites réalisés avec MediaSPIP

    2 mai 2011, par

    Cette page présente quelques-uns des sites fonctionnant sous MediaSPIP.
    Vous pouvez bien entendu ajouter le votre grâce au formulaire en bas de page.

  • Support audio et vidéo HTML5

    10 avril 2011

    MediaSPIP utilise les balises HTML5 video et audio pour la lecture de documents multimedia en profitant des dernières innovations du W3C supportées par les navigateurs modernes.
    Pour les navigateurs plus anciens, le lecteur flash Flowplayer est utilisé.
    Le lecteur HTML5 utilisé a été spécifiquement créé pour MediaSPIP : il est complètement modifiable graphiquement pour correspondre à un thème choisi.
    Ces technologies permettent de distribuer vidéo et son à la fois sur des ordinateurs conventionnels (...)

  • De l’upload à la vidéo finale [version standalone]

    31 janvier 2010, par

    Le chemin d’un document audio ou vidéo dans SPIPMotion est divisé en trois étapes distinctes.
    Upload et récupération d’informations de la vidéo source
    Dans un premier temps, il est nécessaire de créer un article SPIP et de lui joindre le document vidéo "source".
    Au moment où ce document est joint à l’article, deux actions supplémentaires au comportement normal sont exécutées : La récupération des informations techniques des flux audio et video du fichier ; La génération d’une vignette : extraction d’une (...)

Sur d’autres sites (15418)

  • Non-monotonic DTS Errors in Concatenated FFmpeg Output with Multiple Streams

    23 février 2024, par lucemia

    I've encountered an issue while concatenating video files using FFmpeg, specifically when including multiple streams using the -map 0 option. Here are the details :

    


    I have two FFmpeg commands to trim the first three seconds of a video from a public sample :

    


      

    1. Without -map 0 :

      


      ffmpeg -i http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4 -t 3 output_t.mp4 -y


      


    2. 


    3. With -map 0 :

      


      ffmpeg -y -i http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4 -map 0 -t 3 output_t.mp4


      


    4. 


    


    When using the output from the first command in a concat demuxer, everything works fine. However, using the output from the second command results in numerous "Non-monotonic DTS in output stream" errors and the final video's length is incorrect.

    


    The whole process looks like

    


    ffmpeg -y -i http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4 -map 0 -t 3 output_t.mp4
ffmpeg -y -i http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4 -filter_complex '[0]trim=duration=3[s0];[0]atrim=duration=3[s1]' -map '[s0]' -map '[s1]' trim_atrim_duration.mp4
ffmpeg -y -f concat -safe 0 -i files.txt -map 0 -c copy concat_demuxer.mp4


    


    the body of files

    


    file 'output_t.mp4'
file 'trim_atrim_duration.mp4'


    


    Here are my questions :

    


    Why does including -map 0 (to include all streams) in the trimming process cause non-monotonic DTS errors when those segments are later used in a concat demuxer ?

    


    Any advice on how to diagnose and resolve these issues would be greatly appreciated. I'm particularly interested in understanding the underlying cause of the non-monotonic DTS errors and finding a reliable workflow for trimming and concatenating videos with multiple streams.

    


    Thank you for your help !

    


    I tried analysis the PTS & DTS to see if there is any difference between the w/o map output_t.mp4

    


    
ffprobe -v error -select_streams v -show_entries frame=pkt_pts_time,pkt_dts_time -of default=noprint_wrappers=1:nokey=1 output_t.mp4 > video_pts_dts.txt
ffprobe -v error -select_streams a -show_entries frame=pkt_pts_time,pkt_dts_time -of default=noprint_wrappers=1:nokey=1 output_t.mp4 > audio_pts_dts.txt


    


    but didn't find any difference

    


  • Invalid file for QuickTime player after ffmpeg encoding [closed]

    29 janvier 2024, par Stéphane MEX

    I'm having a compatibility problem with QuickTime player.

    


    To encode a video initially in ProRes 422 in H264 .mov to be played in an iPad.
The encoding is done but the file is unreadable for QuickTime ...

    


    I use the following command :

    


              # Utiliser ffprobe pour extraire les métadonnées du fichier source
                metadata=$(ffprobe -v error -show_entries format_tags=title,artist,album,genre,comment,year -of default=noprint_wrappers=1:nokey=1 "$nouveau_chemin")

                # Convertir la vidéo et inclure les métadonnées
                ffmpeg -i "$nouveau_chemin" \
                       -c:v libx264 -preset medium -crf 20 \
                       -vf "scale=1920:1080" \
                       -pix_fmt yuv420p \
                       -c:a aac -b:a 256k \
                       -metadata title="${metadata[0]}" \
                       -metadata artist="${metadata[1]}" \
                       -metadata album="${metadata[2]}" \
                       -metadata genre="${metadata[3]}" \
                       -metadata comment="${metadata[4]}" \
                       -metadata year="${metadata[5]}" \
                       "$nouvelle_video"


    


    Thank's a lot for your help :)

    


  • Setting up multiple resolution value in Fast API for transcoding uploaded video files

    23 janvier 2024, par Sanji Vinsmoke

    I created an API for transcoding video files like adaptive bit rate of youtube. I used Fast API. Currently, I am trying to set resolution values for each file. But whenever I am adding multiple resolutions, I am recieving "422 unprocessible entity" error in the Swagger.

    


    Here is my code :

    


    async def transcode_video(input_path, output_folder, res, unique_id, total_files, pbar):
 # Use asyncio for command execution with progress bar
 output_path = os.path.join(output_folder, f"{res}p.m3u8")

 # Calculate the target size
 target_size = calculate_target_size(input_path)

 cmd_duration = f"ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 {input_path}"
 total_duration = float(subprocess.check_output(cmd_duration, shell=True, text=True).strip())

 cmd = (
     f"ffmpeg -i {input_path} -vf scale=-2:{res} -c:a aac -b:a 128k "
     f"-g 50 -hls_time 1 -hls_list_size 0 "
     f"-crf 23 -b:v 100k -fs {target_size} "
     f"-hls_segment_filename \"{output_path.replace('.m3u8', '_%03d.ts')}\" "
     f"{output_path}"
 )

 process = await asyncio.create_subprocess_shell(
     cmd,
     stdout=asyncio.subprocess.PIPE,
     stderr=asyncio.subprocess.PIPE
 )

 while True:
     line = await process.stderr.readline()
     if not line:
         break
     line = line.decode().strip()
     if "time=" in line:
         # Extracting the time progress from FFmpeg output
         time_str = line.split("time=")[1].split()[0]
         current_time = sum(x * float(t) for x, t in zip([3600, 60, 1], time_str.split(":")))
         progress = (current_time / total_duration) * 100
         pbar.update(progress - pbar.n)

 # Wait for the transcoding process to complete
 await process.wait()

 if process.returncode != 0:
     raise HTTPException(status_code=500, detail="Video transcoding failed.")
 pbar.close()

 # Increment the total number of transcoded files
 total_files[0] += 1

@app.post("/transcode/")
async def transcode_video_endpoint(files: List[UploadFile] = File(...), resolutions: List[int] = None):
 # Counters for transcoded videos
 total_files = [0]

 # Iterate over each file
 for file in files:
     # Check if the file is a valid video file based on its extension
     valid_video_extensions = {".mp4", ".avi", ".mkv", ".mov", ".wmv", ".flv"}
     if not any(file.filename.lower().endswith(ext) for ext in valid_video_extensions):
         print(f"Skipping non-video file: {file.filename}")
         continue

     # Assign a unique ID for each file
     unique_id = str(uuid.uuid4())

     # Log the filename and unique ID
     print(f"Processing file: {file.filename} with unique ID: {unique_id}")

     # Create a folder for the unique ID
     unique_id_folder = os.path.join(OUTPUT_FOLDER, unique_id)
     Path(unique_id_folder).mkdir(parents=True, exist_ok=True)

     # Save the uploaded file
     input_path = os.path.join(UPLOAD_FOLDER, file.filename)
     with open(input_path, "wb") as video_file:
         video_file.write(file.file.read())

     # Check if the file is a valid video file using ffprobe
     try:
         subprocess.run(
             ["ffprobe", "-v", "error", "-select_streams", "v:0", "-show_entries", "stream=codec_type", "-of", "csv=p=0", input_path],
             check=True, capture_output=True
         )
     except subprocess.CalledProcessError:
         print(f"Skipping non-video file: {file.filename}")
         continue

     # Determine the resolutions to transcode based on the provided or default resolution
     resolutions_to_transcode = [res for res in [240, 360, 480, 720] if resolutions is None or res in resolutions]

     # If resolutions is not exactly 360, 480, 720, or 1080, transcode to the nearest lower resolution
     if resolutions is not None:
         resolutions_to_transcode = [get_closest_lower_resolution(res) for res in resolutions]

     # Transcode the video into the specified resolutions
     for res in resolutions_to_transcode:
         output_folder = os.path.join(unique_id_folder, f"{res}p")
         Path(output_folder).mkdir(parents=True, exist_ok=True)

         # Call the transcode_video function with tqdm progress bar
         with tqdm(total=100, desc=f"Transcoding {res}p", position=0, leave=True) as pbar:
             await transcode_video(input_path, output_folder, res, unique_id, total_files, pbar)

     # Create index.m3u8 file after transcoding all resolutions
     create_index_m3u8(unique_id, resolutions_to_transcode)

 return JSONResponse(content={"message": f"{total_files[0]} videos transcoded."})


    


    If I provide one resolution it works fine. But if I provide a list of resolutions for all the uploaded videos I am getting error 422.

    


    
Code    Details
422 
Error: Unprocessable Entity

Response body
Download
{
  "detail": [
    {
      "loc": [
        "body",
        "resolutions",
        0
      ],
      "msg": "value is not a valid integer",
      "type": "type_error.integer"
    }
  ]
}


    


    I used python 3.8.18. Can you help me please ? I tried with list, object but always getting the error.