Recherche avancée

Médias (91)

Autres articles (43)

  • MediaSPIP v0.2

    21 juin 2013, par

    MediaSPIP 0.2 est la première version de MediaSPIP stable.
    Sa date de sortie officielle est le 21 juin 2013 et est annoncée ici.
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Comme pour la version précédente, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
    Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)

  • Les autorisations surchargées par les plugins

    27 avril 2010, par

    Mediaspip core
    autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs

  • Other interesting software

    13 avril 2011, par

    We don’t claim to be the only ones doing what we do ... and especially not to assert claims to be the best either ... What we do, we just try to do it well and getting better ...
    The following list represents softwares that tend to be more or less as MediaSPIP or that MediaSPIP tries more or less to do the same, whatever ...
    We don’t know them, we didn’t try them, but you can take a peek.
    Videopress
    Website : http://videopress.com/
    License : GNU/GPL v2
    Source code : (...)

Sur d’autres sites (5251)

  • ffmpeg video processing command does not end

    24 août 2023, par Harry

    I am using ffmpeg to create a video processing lambda, I attached the log for the processing input below and the process never completes sometimes and other times it takes no more than 2 minutes. This also does not throw and error but just does not complete for certain videos.

    


    2023-08-24T22:49:18.633Z    bebc42e9-a60a-4e12-a5a1-ad3f2950f1f3    INFO    Spawned Ffmpeg with command: ffmpeg -i /tmp/input.mp4 -i /tmp/background.mp4 -i /tmp/input_colored.ass -y -filter_complex 
  [0:v]scale=-1:853.3333333333334,crop=1080:853.3333333333334:540:426.6666666666667[videoOne];
  [1:v]scale=-1:1066.6666666666667,crop=1080:1066.6666666666667:540:533.3333333333334[videoTwo];
  [videoOne][videoTwo]vstack=shortest=1[vstacked];
  [vstacked]subtitles=/tmp/input_colored.ass:fontsdir=/tmp/fonts/:force_style='Alignment=2,Shadow=2,OutlineColour=#000000,Fontsize=18,Fontname=Burbank Big Condensed
'
 -c:v libx264 -preset fast -crf 18 -aspect 9:16 -f mp4 /tmp/_1692917333426-rah10.mp4_output.mp4



    


    The intention is to provide two videos with varying lengths and have them stack on top of each other vertically with subtitles and a length of the shortest video.
I am running the function in a lambda and even with a timeout of 10 minutes it does not complete for certain videos but for others it does complete, please help me to resolve this.

    


  • TS video copied to MP4, missing 3 first frames when programmatically read (ffmpeg bug)

    3 septembre 2023, par Vasilis Lemonidis

    Running :

    


    ffmpeg -i test.ts -fflags +genpts -c copy -y test.mp4


    


    for this test.ts, which has 30 frames, readable by opencv, I end up with 28 frames, out of which 27 are readable by opencv. More specifically :

    


    ffprobe -v error -select_streams v:0 -count_packets  -show_entries stream=nb_read_packets -of csv=p=0 tmp.ts 


    


    returns 30.

    


    ffprobe -v error -select_streams v:0 -count_packets     -show_entries stream=nb_read_packets -of csv=p=0 tmp.mp4


    


    returns 28.

    


    Using OpenCV in that manner

    


    cap = cv2.VideoCapture(tmp_path)
readMat = []
while cap.isOpened():
        ret, frame = cap.read()
        if not ret:
            break
        readMat.append(frame)


    


    I get for the ts file 30 frames, while for the mp4 27 frames.

    


    Could someone explain why the discrepancies ? I get no error during the transformation from ts to mp4 :

    


    ffmpeg version N-111746-gd53acf452f Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 11.3.0 (GCC)
  configuration: --ld=g++ --bindir=/bin --extra-libs='-lpthread -lm' --pkg-config-flags=--static --enable-static --enable-gpl --enable-libaom --enable-libass --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libsvtav1 --enable-libdav1d --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree --enable-cuda-nvcc --enable-cuvid --enable-nvenc --enable-libnpp 
  libavutil      58. 16.101 / 58. 16.101
  libavcodec     60. 23.100 / 60. 23.100
  libavformat    60. 10.100 / 60. 10.100
  libavdevice    60.  2.101 / 60.  2.101
  libavfilter     9. 10.100 /  9. 10.100
  libswscale      7.  3.100 /  7.  3.100
  libswresample   4. 11.100 /  4. 11.100
  libpostproc    57.  2.100 / 57.  2.100
[mpegts @ 0x4237240] DTS discontinuity in stream 0: packet 5 with DTS 306003, packet 6 with DTS 396001
Input #0, mpegts, from 'tmp.ts':
  Duration: 00:00:21.33, start: 3.400000, bitrate: 15 kb/s
  Program 1 
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
  Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(progressive), 300x300, 1 fps, 3 tbr, 90k tbn
Output #0, mp4, to 'test.mp4':
  Metadata:
    encoder         : Lavf60.10.100
  Stream #0:0: Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 300x300, q=2-31, 1 fps, 3 tbr, 90k tbn
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[out#0/mp4 @ 0x423e280] video:25kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 4.192123%
frame=   30 fps=0.0 q=-1.0 Lsize=      26kB time=00:00:21.00 bitrate=  10.3kbits/s speed=1e+04x 


    


    Additional information

    


    The origin of the video I am processing comes from a continuous stitching operation of still images ts videos, produced by this class update method :

    


    import cv2
import os
import subprocess
from tempfile import NamedTemporaryFile
class VideoUpdater:
    def __init__(
        self, video_path: str, framerate: int, timePerFrame: Optional[int] = None
    ):
        """
        Video updater takes in a video path, and updates it using a supplied frame, based on a given framerate.
        Args:
            video_path: str: Specify the path to the video file
            framerate: int: Set the frame rate of the video
        """
        if not video_path.endswith(".mp4"):
            LOGGER.warning(
                f"File type {os.path.splitext(video_path)[1]} not supported for streaming, switching to ts"
            )
            video_path = os.path.splitext(video_path)[0] + ".mp4"

        self._ps = None
        self.env = {
            
        }
        self.ffmpeg = "/usr/bin/ffmpeg "

        self.video_path = video_path
        self.ts_path = video_path.replace(".mp4", ".ts")
        self.tfile = None
        self.framerate = framerate
        self._video = None
        self.last_frame = None
        self.curr_frame = None


    def update(self, frame: np.ndarray):
        if len(frame.shape) == 2:
            frame = cv2.cvtColor(frame, cv2.COLOR_GRAY2BGR)
        else:
            frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)
        self.writeFrame(frame)

    def writeFrame(self, frame: np.ndarray):
        """
        The writeFrame function takes a frame and writes it to the video file.
        Args:
            frame: np.ndarray: Write the frame to a temporary file
        """


        tImLFrame = NamedTemporaryFile(suffix=".png")
        tVidLFrame = NamedTemporaryFile(suffix=".ts")

        cv2.imwrite(tImLFrame.name, frame)
        ps = subprocess.Popen(
            self.ffmpeg
            + rf"-loop 1 -r {self.framerate} -i {tImLFrame.name} -t {self.framerate} -vcodec libx264 -pix_fmt yuv420p -y {tVidLFrame.name}",
            env=self.env,
            shell=True,
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
        )
        ps.communicate()
        if os.path.isfile(self.ts_path):
            # this does not work to watch, as timestamps are not updated
            ps = subprocess.Popen(
                self.ffmpeg
                + rf'-i "concat:{self.ts_path}|{tVidLFrame.name}" -c copy -y {self.ts_path.replace(".ts", ".bak.ts")}',
                env=self.env,
                shell=True,
                stdout=subprocess.PIPE,
                stderr=subprocess.PIPE,
            )
            ps.communicate()
            shutil.move(self.ts_path.replace(".ts", ".bak.ts"), self.ts_path)

        else:
            shutil.copyfile(tVidLFrame.name, self.ts_path)
        # fixing timestamps, we dont have to wait for this operation
        ps = subprocess.Popen(
            self.ffmpeg
            + rf"-i {self.ts_path} -fflags +genpts -c copy -y {self.video_path}",
            env=self.env,
            shell=True,
            # stdout=subprocess.PIPE,
            # stderr=subprocess.PIPE,
        )
        tImLFrame.close()
        tVidLFrame.close()


    


  • Why ffmpeg hangs encoding a void audio track ?

    23 août 2023, par SkizZO

    I've googled an entire day experimenting all possible solutions, but noone had worked.
I have 2 HIK dvr (one is prehistoric vith analogic video). I've made a bash script to retrieve X seconds (as input) of the DVR stored videos (it cut seconds if video ends early) ; also record X seconds of Live view (used for saving Motion Alert in Home assistant).

    


    All works well, BUT i have some issues, and the big one is that when the video has no audio, the download hangs at 9.96 seconds for the old device, and 9.97sec for the new (damn !).

    


    Now let's look at the commands and the logs.

    


    Command : this works with cams with audio, but hangs if cam has an audio silent track ?

    


    makejob=$(ffmpeg -fflags +genpts -y -ac 1 -channel_layout mono -rtsp_transport tcp -hide_banner -loglevel info -err_detect ignore_err -i  "rtsp://$user:$dvrpasswd@$dvraddress:554/ISAPI/streaming/tracks/${camnumber}01?starttime=$starttime&endtime=$endTime" -map 0:v -map 0:a? -ar 44100 -filter:a "volume=$volume" -t $seconds -acodec aac -vcodec copy $filepathname)


    


    (A) result Cam with audio : errors too, but works recording both video and audio

    


    Downloading from DVR BeB-DVR a 7 seconds video of the CAM CAMERA-1 recorded from 2023-08-19 10:10:10
Input #0, rtsp, from 'rtsp://$user:$dvrpasswd@$dvraddress:554/ISAPI/streaming/tracks/101?starttime=20230819T101010Z&endtime=20230819T101020Z':
  Metadata:
    title           : HIK Media Server V4.32.116
    comment         : HIK Media Server Session Description : standard
  Duration: 462428:22:56.-75, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: h264 (Baseline), yuvj420p(pc, bt709, progressive), 1920x1080, 25 fps, 25 tbr, 90k tbn, 180k tbc
    Stream #0:1: Audio: pcm_mulaw, 8000 Hz, mono, s16, 64 kb/s
Output #0, mp4, to '/home/pi/hikdwn/downloaded/BeB-DVR-CAMERA-1-2023-08-19-h01010-(10s).mp4':
  Metadata:
    title           : HIK Media Server V4.32.116
    comment         : HIK Media Server Session Description : standard
    encoder         : Lavf57.56.101
    Stream #0:0: Video: h264 (Baseline) ([33][0][0][0] / 0x0021), yuvj420p(pc, bt709, progressive), 1920x1080, q=2-31, 25 fps, 25 tbr, 90k tbn, 90k tbc
    Stream #0:1: Audio: aac (LC) ([64][0][0][0] / 0x0040), 44100 Hz, mono, fltp, 69 kb/s
    Metadata:
      encoder         : Lavc57.64.101 aac
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (pcm_mulaw (native) -> aac (native))
Press [q] to stop, [?] for help
[mp4 @ 0x212a9d0] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
frame=  175 fps= 33 q=-1.0 Lsize=    1708kB time=00:00:07.00 bitrate=1998.8kbits/s speed=1.34x
video:1643kB audio:60kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.350157%
[aac @ 0x212cf00] Qavg: 111.884
Download completed!


    


    (B) result Cam withouth audio (on both DVRs) : hangs before completing the download, the file saved is 0kb

    


    (B) on DVR1 (newer one) hangs

    


    Input #0, rtsp, from 'rtsp://$user:$dvrpasswd@$dvraddress:554/ISAPI/streaming/tracks/501?starttime=20230819T101010Z&endtime=20230819T101020Z':
  Metadata:
    title           : HIK Media Server V4.32.116
    comment         : HIK Media Server Session Description : standard
  Duration: 462428:23:09.-90, start: 0.020000, bitrate: N/A
    Stream #0:0: Video: hevc (Main), yuv420p(tv), 2560x1440, 50 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1: Audio: pcm_mulaw, 8000 Hz, mono, s16, 64 kb/s
Output #0, mp4, to '/home/pi/hikdwn/downloaded/BeB-DVR-CAMERA-5-2023-08-19-h01010-(10s).mp4':
  Metadata:
    title           : HIK Media Server V4.32.116
    comment         : HIK Media Server Session Description : standard
    encoder         : Lavf57.56.101
    Stream #0:0: Video: hevc (Main) ([35][0][0][0] / 0x0023), yuv420p(tv), 2560x1440, q=2-31, 50 fps, 25 tbr, 90k tbn, 90k tbc
    Stream #0:1: Audio: aac (LC) ([64][0][0][0] / 0x0040), 44100 Hz, mono, fltp, 69 kb/s
    Metadata:
      encoder         : Lavc57.64.101 aac
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (pcm_mulaw (native) -> aac (native))
Press [q] to stop, [?] for help
frame=  251 fps=149 q=-1.0 size=       0kB time=00:00:09.97 bitrate=   0.0kbits/s speed=5.94x


    


    (B) on DVR2 (older) hangs with errors also

    


    Input #0, rtsp, from 'rtsp://$user:$dvrpasswd@$dvraddress:554/ISAPI/streaming/tracks/501?starttime=20230819T101010Z&endtime=20230819T101020Z':
  Metadata:
    title           : HIK Media Server V3.1.4
    comment         : HIK Media Server Session Description : standard
  Duration: 97123:37:11.-81, start: 0.240000, bitrate: N/A
    Stream #0:0: Video: h264 (Baseline), yuv420p(progressive), 352x288, 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1: Audio: pcm_mulaw, 8000 Hz, mono, s16, 64 kb/s
Output #0, mp4, to '/home/pi/hikdwn/downloaded/HomeDVR-VIALE-2023-08-19-h01010-(10s).mp4':
  Metadata:
    title           : HIK Media Server V3.1.4
    comment         : HIK Media Server Session Description : standard
    encoder         : Lavf57.56.101
    Stream #0:0: Video: h264 (Baseline) ([33][0][0][0] / 0x0021), yuv420p(progressive), 352x288, q=2-31, 25 fps, 25 tbr, 90k tbn, 90k tbc
    Stream #0:1: Audio: aac (LC) ([64][0][0][0] / 0x0040), 44100 Hz, mono, fltp, 69 kb/s
    Metadata:
      encoder         : Lavc57.64.101 aac
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (pcm_mulaw (native) -> aac (native))
Press [q] to stop, [?] for help
[mp4 @ 0x1377ce0] Non-monotonous DTS in output stream 0:0; previous: 2, current: -17998; changing to 3. This may result in incorrect timestamps in the output file.
[mp4 @ 0x1377ce0] Non-monotonous DTS in output stream 0:0; previous: 3, current: -14398; changing to 4. This may result in incorrect timestamps in the output file.
[mp4 @ 0x1377ce0] Non-monotonous DTS in output stream 0:0; previous: 4, current: -10798; changing to 5. This may result in incorrect timestamps in the output file.
[mp4 @ 0x1377ce0] Non-monotonous DTS in output stream 0:0; previous: 5, current: -7198; changing to 6. This may result in incorrect timestamps in the output file.
[mp4 @ 0x1377ce0] Non-monotonous DTS in output stream 0:0; previous: 6, current: -3600; changing to 7. This may result in incorrect timestamps in the output file.
[mp4 @ 0x1377ce0] Non-monotonous DTS in output stream 0:0; previous: 7, current: 2; changing to 8. This may result in incorrect timestamps in the output file.
frame=  256 fps= 49 q=-1.0 size=       0kB time=00:00:09.96 bitrate=   0.0kbits/s speed=1.89x


    


    I suppose it's due to the missing timestamps. Note that also when there is no audio, there is an audio track in the video. It hangs when trying to encode that void track.

    


    (i will comment with logs where no audio is recorded, it works with some errors... maybe other useful infos are there)