News:

--

Main Menu

Append same video without re-encoding? Loop "mux"?

Started by Cormy1, January 20, 2024, 03:11:24 AM

Previous topic - Next topic

Cormy1

So this is a bit of a weird request, but I recently tried ripping some Coub videos, and the way Coub seems to work is that it only serves a short video once, which it then loops for the duration of the audio it's being played with.
Obviously regular media players would not run that loop part properly, as I don't imagine such an instruction is stored in the video stream that I downloaded.
But, is there a means of adding it to the video container? Or using some kind of reference pointers to re-decode the past frames to display them again?
Or would I simply have to append the video multiple times and re-encode it with quality loss?

In this case, the video is only 10 seconds long, but is intended to loop for about 3 minutes straight.
Is such a thing possible without immense bloat or quality loss?

sark

Quote from: Cormy1 on January 20, 2024, 03:11:24 AMOr would I simply have to append the video multiple times and re-encode it with quality loss?

Appending the same video multiple times would not require re-encoding. You can save the appended files in Copy mode. Re-encoding is only necessary when there are differences with the appended inputs parameters.

eumagga0x2a

Quote from: Cormy1 on January 20, 2024, 03:11:24 AMis there a means of adding it to the video container?

Yes, this should be possible with edit lists, a feature of QuickTime / MPEG-4 container (mov/mp4). However, I am not aware of software other than hex editor paired with endless patience and precision on user's part which would actually perform such a manipulation.

If you have control over the equipment used to play a long audio track while looping a short video, the IMHO simplest way to do what you ask for is something along the lines of a bash script

#!/bin/bash
mpv --no-terminal --cursor-autohide=no --osc=no --fullscreen --no-audio --loop=inf /path/to/short-video-to-be-played-in-a-loop &
MPV_PID=$!
mpv --no-video $1
kill $MPV_PID > /dev/null 2>&1

put into a folder listed in $PATH and the path to audio file passed as the argument to this script.

(Options --cursor-autohide=no --osc=no --fullscreen are purely a matter of taste).

eumagga0x2a

#3
Quote from: eumagga0x2a on January 20, 2024, 07:40:04 PMI am not aware of software other than hex editor paired with endless patience and precision on user's part which would actually perform such a manipulation.

Probably MP4Box could do that, see the -edits option. However, there is no guarantee that a video player understands such advanced edit lists.

Cormy1

#4
Quote from: sark on January 20, 2024, 06:14:10 PMAppending the same video multiple times would not require re-encoding. You can save the appended files in Copy mode. Re-encoding is only necessary when there are differences with the appended inputs parameters.

File size limitations would require further compression if I were to simply append them.

Is there a good means of using a wide/large GOP and B-frame shenanigans to effectively compress such a video?
Could maybe use a profile/tune akin to stillimage for loops.
Frustrating how frequently frames are re-used in animation yet there isn't a good way of deduplicating those frames in the video stream (as far as I'm aware)

Quote from: Cormy1 on January 20, 2024, 03:11:24 AMOr would I simply have to append the video multiple times and re-encode it with quality loss?

eumagga0x2a

Quote from: Cormy1 on March 23, 2024, 04:03:54 PMCould maybe use a profile/tune akin to stillimage for loops.

No way, wrong tool for the task. The size of buffer for decoded pictures is constrained by codec specifications.