VideoHelp Forum
+ Reply to Thread
Results 1 to 20 of 20
Thread
  1. Hello,

    I am a visual artist and at the moment I am working on a video. I want to add, as subtitles, about 100 different sentences that appear one by one every 5 seconds. The difficulty is: I want the sentences to appear in a random order. Does anyone know if it is possible to script a subtitle file in such a way that it randomly picks one sentence every 5 seconds?

    Thank you very much for your help!
    Luuk
    Quote Quote  
  2. I'm a MEGA Super Moderator Baldrick's Avatar
    Join Date: Aug 2000
    Location: Sweden
    Search Comp PM
    Scripting? I don't think so.

    But it would be easy in most programming language if you have any such experience. Like java, php, etc.
    Quote Quote  
  3. So maybe I should ask this question on a programming forum?
    Do you think it would be possible to create a blu-ray with java-programmed subtitles?

    Thank you
    Quote Quote  
  4. I'm a MEGA Super Moderator Baldrick's Avatar
    Join Date: Aug 2000
    Location: Sweden
    Search Comp PM
    And I was thinking of making ONE subtitle file with random sentences....making it random every time you play it would require a special subtitle decoder.
    Quote Quote  
  5. vanished El Heggunte's Avatar
    Join Date: Jun 2009
    Location: Misplaced Childhood
    Search Comp PM
    Probably you'll have to create your own special software
    (OR "hire" someone for doing that).

    Keep in mind that the "well-known" digital subtitle formats were designed for being «useful», not for being displayed *at random*.
    Quote Quote  
  6. It's important that it's random every time I play it. Otherwise I would just add the subtitles in Adobe Premiere...
    So I guess I'll need a special program for that, or some kind of subtitle decoder.
    Quote Quote  
  7. Member
    Join Date: Jun 2012
    Location: USA
    Search Comp PM
    Blu Ray spec won't allow for what you're trying to do. You're either going to have to use another medium or use other techniques (such as multiple versions of the same video) to give the "illusion" of randomness.
    Quote Quote  
  8. Member
    Join Date: Oct 2004
    Location: Freedonia
    Search Comp PM
    Yet another of the endless variations on what I call the old "I want to do something that nobody else in the world wants to do, so why doesn't software exist that allows me to do it?" question. This is almost always followed by a posting from the OP who is just shocked beyond belief that I would dare to suggest that nobody else in the world wants to do this and that surely hundreds of thousands of people at a minimum if not almost the entire population of the world wants to do this just like they do, yet they have no explanation at all for why there are no programs that can do it.
    Quote Quote  
  9. Member DB83's Avatar
    Join Date: Jul 2007
    Location: United Kingdom
    Search Comp PM
    Well I suppose, in theory, this is possible.

    You first create not one video but split that into 100 5 second chunks and place the 100 videos into a playlist - your player, obviously, has to support playlists.

    Now you need 100 sub-title files and a program that runs in the background that randomly selects one, renames it to match the video segment that plays next, so when that video starts it loads that sub-title segment.

    So that's the theory. Just do not ask me how to program for it
    Quote Quote  
  10. Perhaps a clever AviSynth guru could manage it?

    I think of storing 100 single lines in numbered text files and overlay these randomly every 5 seconds. I've seen these functions in the AviSynth docs that may be able to do it ? ...

    ConditionalReader
    rand
    subtitle


    The player should accept AviSynth scripts and the system must be fast to do it in real time.

    It's just a thought. I'm not that guru (and it's bed time too).
    Quote Quote  
  11. Member
    Join Date: Jun 2012
    Location: USA
    Search Comp PM
    Originally Posted by jman98 View Post
    Yet another of the endless variations on what I call the old "I want to do something that nobody else in the world wants to do, so why doesn't software exist that allows me to do it?" question. This is almost always followed by a posting from the OP who is just shocked beyond belief that I would dare to suggest that nobody else in the world wants to do this and that surely hundreds of thousands of people at a minimum if not almost the entire population of the world wants to do this just like they do, yet they have no explanation at all for why there are no programs that can do it.
    jman, I'm usually with you on this, but it sounds like OP is into a legitimate art project which, by definition should be unique. So I'd cut him (or her) some slack.
    Quote Quote  
  12. Member
    Join Date: Sep 2012
    Location: Australia
    Search Comp PM
    You could create a script that invents an SRT subtitle file from text within a .txt file then loads VLC or something to play the video with external subtitles, which then exits, repeat infinite.

    VLC has a --play-and-exit option.

    You could even make multiple SRTs and create a playlist with the --sub-file=<string> option.

    https://wiki.videolan.org/VLC_command-line_help
    Last edited by ndjamena; 1st Jun 2014 at 22:35.
    Quote Quote  
  13. There is a random function for playlists. I have no idea if this could be used for subtitles, or if a "master" subtitle script could play while the individual videos were randomized.
    Quote Quote  
  14. Thank you for so many reactions! I know that it might seem a bit impossible, but unfortunately that is the nature of my job. I personally find things more interesting when they haven't been done before.
    I'll take some time to research each of the options you have suggested me and I'll let you know if there is any progress.
    Thank you very much
    Quote Quote  
  15. Member
    Join Date: Sep 2012
    Location: Australia
    Search Comp PM
    It really shouldn't be that hard to pull off, even with batch

    --fullscreen will open a video in full screen with VLC. Assuming you use windows, if you kill explorer and install a Desktop Wallpaper that matches the video you could make the transitions a little neater.

    You could use %TIME% to check how long the video played, if it's too short, restart explorer and exit the batch. That way you can hide the Command Prompt and end the batch by simply closing VLC early. I'd use MediaInfoCLI or FFProbe to find the length of the video, but if you already know the length there's no need.

    .srt files would be simple enough to create with a simple echo Text>>"FileName.srt" [or >], so that would definitely work. Although it may be better to get it working without exiting the player constantly, if it's possible at all that will take a bit of research and fiddling to pull off.
    Quote Quote  
  16. Randomizing a text list is a trivial matter for any programmer. But if you want this on a Blu-ray or DVD disc I don't think there's any way do that it runtime.
    Quote Quote  
  17. Yes, maybe my blu-ray idea is a bit ambitious... I can also play it from a computer and connect it to a projector...
    Quote Quote  
  18. Originally Posted by LuukS View Post
    I can also play it from a computer and connect it to a projector...
    Then it's pretty easy to generate an SRT file with randomly ordered lines.
    Quote Quote  
  19. It is possible using LUA scripting in AviUtl.

    Demo video: see attached mp4 (around 1 minute, randomly select a sentence every 5 seconds)

    To adapt the script for your own use:

    Unzip the attached zip file
    Copy the obj file into the .\script folder of AviUtl installation
    Open the aup project file with AviUtl
    See if some text appears on the main window (if some text appears, it works)

    To customize the text:
    open the obj file with a text editor

    Add more text inside the brackets:
    Code:
      local phrase={
      "Eternity lies ahead of us and behind",
      "Have you drunk you fill?",
      "God does not play dice.",
      "Moe Culture",
      "More Text"
      }
    Save and close the file and open the project file again, see if it works.

    Parameters(sliders):
    Interval... time between re-picking subtitle
    Style... borderd text, shadowed text...
    Size... font size
    Color button... font color

    Other tweaks via script modification:
    Code:
    obj.setfont("MS UI Gothic",obj.track2,obj.track1, color, RGB(0,0,0))
    MS UI Gothic: font face
    0,0,0: Shadow/Border color

    That will become hard-coded into the video though, but different every time you encode it.
    Attached Files
    Last edited by MaverickTse; 4th Jun 2014 at 08:44.
    Quote Quote  
  20. I wrote a quick little C++ program that takes a list of 5 lines of text and creates an SRT subtitle file with the subs in shuffled order. The subs are spaced at 5 second intervals and each sub displays for 4 seconds. Given input that looks like this:

    Code:
    Subtitle 1
    Subtitle 2
    Subtitle 3 is\ntwo lines long
    Subtitle 4
    Subtitle 5
    It generates output that looks like this:


    Code:
    1
    00:00:00,000 --> 00:00:04,000
    Subtitle 2
    
    2
    00:00:05,000 --> 00:00:09,000
    Subtitle 5
    
    3
    00:00:10,000 --> 00:00:14,000
    Subtitle 4
    
    4
    00:00:15,000 --> 00:00:19,000
    Subtitle 3 is
    two lines long
    
    5
    00:00:20,000 --> 00:00:24,000
    Subtitle 1
    The order is random each time you run it. The program can be easily modified to include more subs, different intervals, and different display times.
    Quote Quote