[MPlayer-users] Make a clip with subtitles?

Bill Crockett wsc4 at optusnet.com.au
Sun Apr 8 05:59:08 EEST 2018


From: "Eli the Bearded"
Sent: Sunday, April 08, 2018 9:30 AM


> On Sat, 7 Apr 2018, "Bill Crockett"  wrote, quoting me:
>>> mencoder -ss $ss  -endpos $td \
>>> -vf harddup -nosound -ovc copy -noskip -mc 0 \
>>> "$in" -o "$out"
>>>
>>> # START and DURATION are typically empty, when not empty they are
>>> # "-ss TIME" and "-endpos TIME2"
>>> mplayer $START $DURATION -nosound -vo "jpeg:outdir=$outdir" "$in"
>>>
>>> Given that workflow, I'd like to know what I can do to make substites
>>> appear (when I have them) in the final frames. Can mencoder create the
>>> soundless clip with the substitles written into the video stream?
>>>
>>> Baring that, if I made a subtitle file for my soundless clip (and I
>>> probably could automate that easily with a program), can I get the
>>> second stage to composite the subtitles in before writing the JPEG
>>> frames out?
>> I would run some tests with your final video of 20 seconds or what ever.
>>
>> mplayer -sub sub.srt input
>
> Yes, I can add subtitles like that, it's the second part of my question.
> That works. For testing purposes I created an srt file that puts a
> changing timestamp in for every second.
>
> https://qaz.wtf/tmp/generic.srt.gz
>
>> Copy the text (in-between the dash line). Name it as sub.srt and run it 
>> to
>> see if it works.  Adjust timing and text to your needs.  Run MEcoder
>> with -sub sub.srt
>
> When I do this, the newly encoded video does not have the subtitles in
> the video stream.
>
> ---------------------------------------------
> mencoder -ss 4485 -endpos 20 -vf harddup -nosound -sub 
> /var/tmp/generic.srt \
> -ovc copy -noskip -mc 0 walk.mkv -o /tmp/folder.avi
> MEncoder 1.2.1 (Debian), built with gcc-5.3.1 (C) 2000-2016 MPlayer Team
> success: format: 0  data: 0x0 - 0x1eae4e28
> libavformat version 56.40.101 (external)
> libavformat file format detected.
> [lavf] stream 0: video (h264), -vid 0
> [lavf] stream 1: audio (mp3), -aid 0, -alang eng, English AC3 640 kbps
> [lavf] stream 2: subtitle (ass), -sid 0, -slang eng, English Forced
> VIDEO:  [H264]  640x480  0bpp  23.976 fps    0.0 kbps ( 0.0 kbyte/s)
> [V] filefmt:44  fourcc:0x34363248  size:640x480  fps:23.976  ftime:=0.0417
> videocodec: framecopy (640x480 0bpp fourcc=34363248)
> Writing header...
> ODML: Aspect information not (yet?) available or unspecified, not writing 
> vprp header.
> Writing header...
> ODML: Aspect information not (yet?) available or unspecified, not writing 
> vprp header.
> Pos:  20.0s    480f (79%)  0.00fps Trem:   0min   1mb  A-V:0.000 [578:0]]
> Writing index...
> Writing header...
> ODML: Aspect information not (yet?) available or unspecified, not writing 
> vprp header.
>
> Video stream:  577.694 kbit/s  (72211 B/s)  size: 1445680 bytes  20.020 
> secs  480 frames
> ---------------------------------------------
>
> As I said, the output video does not have subtitles in the video stream.
> No matter, let's try again with stage two:
>
> ---------------------------------------------
> mplayer -sub /var/tmp/generic.srt -nosound \
> -vo jpeg:outdir=/tmp/frames /tmp/folder.avi
> MPlayer 1.2.1 (Debian), built with gcc-5.3.1 (C) 2000-2016 MPlayer Team
> mplayer: could not connect to socket
> mplayer: No such file or directory
> Failed to open LIRC support. You will not be able to use your remote 
> control.
>
> Playing /tmp/spoons2.avi.
> libavformat version 56.40.101 (external)
> AVI file format detected.
> [aviheader] Video stream found, -vid 0
> VIDEO:  [H264]  640x480  0bpp  23.976 fps  577.7 kbps (70.5 kbyte/s)
> Clip info:
> Software: MEncoder 1.2.1 (Debian), built with gcc-5.3.1
> SUB: Added subtitle file (1): /var/tmp/generic.srt
> Load subtitles in /tmp/
> jpeg: Progressive JPEG disabled.
> jpeg: Baseline JPEG enabled.
> ==========================================================================
> Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
> libavcodec version 56.60.100 (external)
> Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
> ==========================================================================
> Audio: no sound
> Starting playback...
> Could not find matching colorspace - retrying with -vf scale...
> Opening video filter: [scale]
> Movie-Aspect is 2.39:1 - prescaling to correct movie aspect.
> [swscaler @ 0x7f47fa231fa0]bicubic scaler, from yuv420p to rgb24 using 
> MMXEXT
> [swscaler @ 0x7f47fa231fa0]using unscaled yuv420p -> rgb24 special 
> converter
> VO: [jpeg] 640x480 => 1146x480 RGB 24-bit
> jpeg: output directory: /tmp/frames
> V:  20.0 480/480 10% 26%  0.0% 0 0
>
>
> Exiting... (End of file)
> ---------------------------------------------
>
> And now NONE of the output JPEG frames have subtitles. So what do I need
> to do?

mencoder -ss 4485 -endpos 20 -vf harddup -nosound -sub /var/tmp/generic.srt 
\
 -ovc copy -noskip -mc 0 walk.mkv -o /tmp/folder.avi

"-ovc copy" will not work.  You need to re-encode.  Stick with the avi 
container and try -ovc as:

-ovc lavc -lavcopts vcodec=mjpeg:autoaspect

mplayer -sub /var/tmp/generic.srt -nosound \
 -vo jpeg:outdir=/tmp/frames /tmp/folder.avi

"-vo jpeg" will not work also. It looks like it is a direct copy of the 
frames and bypasses subs and anything else.

have you looked at the -mf (make frames) command?

mplayer mf://[directory to jpeg files]\*.jpg -mf 
fps=25:w=1024:h=576:type=jpeg -sub sub.srt -aspect

You need to adjust the fps= w= h= to yours.

mencoder mf://[directory to]\*.jpg -mf fps=25:w=1024:h=576:type=jpeg -sub 
sub.srt -nosound -ovc lavc -lavcopts vcodec=mjpeg:autoaspect -of avi -o 
[output.avi] -msgcolor



More information about the MPlayer-users mailing list