Recherche avancée

Médias (0)

Mot : - Tags -/xmlrpc

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

Autres articles (108)

Sur d’autres sites (15686)

  • avcodec/cbs_av1 : support one byte long OBUs when the size is not set in the bitstream

    11 novembre 2019, par James Almer
    avcodec/cbs_av1 : support one byte long OBUs when the size is not set in the bitstream
    

    This will be needed by the next commit, where packets with a single Temporal
    Delimiter OBU with no size will need to be parsed

    Signed-off-by : James Almer <jamrial@gmail.com>

    • [DH] libavcodec/cbs_av1.c
  • ffmpeg as subprocess takes too long

    12 décembre 2019, par almosthero

    One part of my program requires FFMPEG to transcode files using GPU.

    When I execute the FFMPEG command alone in terminal, without Python, it takes aproximetly 0.7 second. Running 50 simultaneous commands doesn’t affect the results. The time is always around 0.7 sec (thanks to a powerful GPU that can handle that amount of requests).

    Putting this command to subprocess increases the time to 1.7 second and raises up to 20 seconds when I run multiple instance even though this command should work asynchronously.

    def run_ffmpeg(filename, gop, representation, output_filename=None):
       process_result = subprocess.run(
           args=[
               'sudo', FFMPEG_PATH,
               '-vsync', '0',
               '-hwaccel', 'cuvid', # transport decoded file through GPU without touching CPU
               '-hwaccel_device', '0',
               '-c:v', 'h264_cuvid', # Decoding using GPU
               '-i', filename,
               # ...
               '-c:v', 'hevc_nvenc', # Encoding using GPU
               # ...more filters...
               output_filename
           ]
       )
       log_process_result(process_result)
       return output_filename

    The sequence is way more complex :

    def transcode_file(media_id, target_repr, target_nr):
       # ... variables definitions
       run_ffmpeg(target_segment_path, gop='120', representation=target_repr, output_filename=result)

    def prepare_file(media_id, representation_id, file_name):
       # ... variables definitions
           path = transcode_file(media_id, target_repr, target_nr)

    async def download_media_handler(request):
       # ... variables definitions
       file_info = await loop.run_in_executor(
           executor, prepare_file, media_dir_name, representation_id, file_name)

    Neither GPU or CPU is fully used so this is not the case.

    Do you know why ? Does subprocess really takes so much time to run ?

    How can I rewrite this to minimize the time ? Are there any quicker alternatives ?

  • Clip long video segment quickly

    30 janvier 2020, par PRMan

    Let’s say I have a video called Concert.mp4. I want to extract a performance from it quickly with minimal reencoding. I want to do the equivalent of this, but faster :

    ffmpeg -i "Concert.mp4" -ss 00:11:45 -to 00:18:15  -preset veryfast -y artist.mp4

    This takes 17 seconds, which is way too long for our needs.

    Now, it turns out that 11:45 and 18:15 don’t fall on iframes, so if you try this you will get a 3 second delay at the beginning before the video shows :

    ffmpeg -i "Concert.mp4" -ss 00:11:45 -to 00:18:15 -c copy -y artist.mp4

    Running this command, we can see where we need to cut :

    ffprobe -read_intervals "11:00%19:00" -v error -skip_frame nokey -show_entries frame=pkt_pts_time -select_streams v -of csv=p=0 "Concert.mp4" > frames.txt

    So what we need to do is encode the first 3.708 seconds, copy the middle, and then encode the last 5.912 seconds.

    I can get the 3 segments to all look perfect (by themselves) like this :

    ffmpeg -ss 698.698 -i "Concert.mp4" -ss 6.302 -t 3.708 -c:v libx264 -c:a copy -c:s copy -y clipbegin.mp4

    ffmpeg -ss 708.708 -to 1089.088 -i "Concert.mp4" -c copy -y clipmiddle.mp4

    ffmpeg -ss 1089.088 -i "Concert.mp4" -t 5.912 -c:v libx264 -c:a copy -c:s copy -y clipend.mp4

    ffmpeg -f concat -i segments.txt -c copy -y artist.mp4

    segments.txt of course contains the following :

    file 'clipbegin.mkv'
    file 'clipmiddle.mkv'
    file 'clipend.mkv'

    I saw this solution presented here, but no amount of tweaking gets it to work for me :

    https://superuser.com/a/1039134/73272

    As far as I can tell, this method doesn’t work at all. It crashes VLC pretty hard no matter what I try.

    The combined video keeps glitching after the 3 seconds, probably because the PTS times are different or something (using some options, I have seen warning messages to this effect). Is there anything I can add to the commands above to get this to work ? The only requirement is that the middle command must not re-encode the video, but must do a fast copy.

    Thanks in advance.