Keep mplayer window open, chain sequential video files - linux

I have a script that parses a bunch of events from a given movie file and uses the -ss and -endpos flags to play specific portions of the file. Let's say there is one file available. What I want to do is run a chained command like:
mplayer vidfile.mp4 -ss 110 -endpos 5 -fs;mplayer vidfile.mp4 -ss 130
-endpos 9
The idea is to have both sections of the video play in full screen, sequentially. However, there is major flicker between the two videos as it exits to the desktop briefly. (Ubuntu 12.04.)
How can I keep mplayer open or make the switch less jarring? Doing this with 30 clips would give someone a massive headache, and I'd like to see if it can be done this way without writing a script to cut the movies and put them together (which sounds like a nightmare, but if anyone has ideas, please post those in the comments).

Not sure when it was introduced, but mplayer now supports this via the -fixed-vo parameter, from the man page:
-fixed-vo
Enforces a fixed video system for multiple files (one (un)initialization for all files).
Therefore only one window will be opened for all files.
Currently the following drivers are fixed-vo compliant:
gl, gl_tiled, mga, svga, x11, xmga, xv, xvidix and dfbmga.
in my testing this works well with full screen (-fs), no flicker.
example usage:
mplayer -fs -fixed-vo thats_marvellous.mp4 cliff.mp4

I ended up solving it with a quick solution that a friend suggested - take the semi-colon out since mplayer supports multiple files AND flags. (Works for a few files for now, will update if I run into problems down the line.)
mplayer vidfile.mp4 -ss 110 -endpos 5 -fs vidfile.mp4 -ss 130 -endpos 9 -fs

Related

How do I split a M4B file provided I have a CUE file?

I have a large M4B file and a CUE file for it. I want to either split it into many M4B files, or split it into many MP3 files (former preferred).
I want to do this in the command line (OS X, but can use Linux if needed) and not install sketchy software. I have ffmpeg and can install other command line audio programs.
There is 2-step process which I did and it worked well.
Step 1 - Convert M4B to MP3
For this, you can use VLC Media Player (not sure how to do via command line so here are the GUI instructions).
Go to Media->Convert/Save
Add the M4B file, click "Save/Convert"
Under Profile, choose Audio-MP3
Select the destination (output) file
Press Start
...wait...but you should see a progress bar
Step 1.5 - Fix missing tags
Unfortunately, using VLC to convert the m4b to mp3 will remove all tags. So you might want to use something like puddletag (linux) to add the tags back in.
Step 2 - Split the MP3 using the .cue file
Once you have the MP3, use mp3splt (command-line)
The -c flag allows you to use the cue file for the split points.
Both of these are well worn programs (at least I have used both for years) so I do not think they are considered "sketchy."
I don't know how strict the CUE sheet format is, but assuming yours follows this general format:
TRACK 1 AUDIO
TITLE "Chapter 01"
INDEX 01 0:0:00
TRACK 2 AUDIO
TITLE "Chapter 02"
INDEX 01 22:56:01
then you can do this with ffmpeg and a perl one-liner.
user#host:~$ INFILE=input.m4b
user#host:~$ OUTPREFIX=output
user#host:~$ OUTEXT=mp3
user#host:~$ perl -ne 'sub p{printf(qq#"%s" -ss %f -to %f "%s_Chapter_%02d%s"\n#, "'"$INFILE"'", $_[0], $_[1], "'$OUTPREFIX'", $_[2], "'$OUTEXT'")}; if(/^\s+INDEX (\d+) (\d+):(\d+):(\d+)$/){$a=$b;$b=$4/60+$2*60+$3; p($a, $b, ++$c)if$b>0}; END{p($b, $b*100, ++$c)}' CUEFILE.cue | xargs -n 6 ffmpeg -i
The perl one-liner ignores all lines in the cue sheet but the INDEX ... lines and also ignores the first index, assuming it is zero. It prints out arguments for ffmpeg. xargs takes the right number of arguments (6 at a time, in this case) and calls ffmpeg once for each chapter (or track, or whatever).
This method can be used with a cue sheet to split up and convert any audio/video file provided ffmpeg accepts the input and output file formats.

Joining MP3's via commandline with background track

I'm already taking advatage of two command line utilities. I'm using ffmpeg to convert m4a to mp3, and then I'm combining a few mp3's into one large one using mp3wrap. The resulting file is something like this:
BackgroundMusic.mp3 > Audio1.mp3 > Audio2.mp3
I need something more like
Audio1.mp3 > Audio2.mp3
|_____________________|
|
BackgroundMusic.mp3
To where the background music runs continuously in the background. Would be nice to be able to change the volume of each track too.
Does anyone know a command line program like mp3wrap but can also add in a background track?
I will not be able to use a GUI program such as Audacity, as all of this will be automated on the server.
Thanks!
You can do this with FFmpeg alone.
ffmpeg -i input_audio1 -i input_audio2 -i input_background_audio -filter_complex "
aevalsrc=0:d=10[s1];
[0:a]volume=volume=0.1[volume0];
[1:a]volume=volume=0.1[volume1];
[2:a]volume=volume=0.1[volume2];
[s1][volume1]concat=n=2:v=0:a=1[ac1];
[volume0][ac1]amix=inputs=2[amixed1];
[amixed1][volume2]amix=inputs=2:duration=first" output_audio
You need to use filter_complex to chain all the filters that you are going to use for adjusting the volumes, silent spaces, concat, etc. filters.
As the first step you can concatenate two audio files that you need to play one after the other. To do that I have first created and silent audio using aevalsrc filter with the same duration as the first audio clip. Then use concat filter to concatenate silent audio and the second audio.
To adjust the audio I have used volume filter. You can adjust the volume values accordingly. To mix the audios you can use amix filter. You can specify duration attribute to get the first input which is [amixed1] duration. With that option you can stop the whole audio with the duration of audio1+audio2 without play it for the full duration of background audio duration.
Hope this helps!

QT-FastStart Windows how to run it?

So I have a lot of mp4 files on my computer and I read that QT-FastStart is for moving the metadata from the end of the files to the beginning but how do I use or run it ?
Every time I drag and drop a file into qt-faststart, nothing seems to happen?
I downloaded the 64bit version from here:
https://web.archive.org/web/20140206214912/http://ffmpeg.zeranoe.com/blog/?p=59
Do I need a batch file or something or a specific command line parameter to make it run?
Note, QT-FastStart is described here https://manpages.debian.org/stretch/ffmpeg/qt-faststart.1.en.html
qt-faststart is a utility that rearranges a Quicktime file such that
the moov atom is in front of the data, thus facilitating network
streaming.
It can be used (perhaps among other purposes), for making a sample file when demonstrating an issue. One can take a large file, fix it with QT-FastStart, then use dd to cut a sample. And the sample should play. Whereas if you did dd without doing that then it wouldn't or may not play.
See Neil's answer qt-faststart infile.mp4 outfile.mp4
However, QT-FastStart has now been integrated into ffmpeg.
ffmpeg -i original.3gp -codec copy -movflags +faststart fixed.3gp
List item
simple. in CMD prompt run qt-faststart infile.mp4 outfile.mp4

mplayer playing gif animation at full screen?

I'm not familiar with mplayer and the tons of option seem like a jungle to me, when all I want to do is show an endless looped gif animation at full screen on my RPi running raspbian.
Can anyone help me, please?
I am now working in Windows and using
mplayer -fs –mf fps=1:type=jpeg *.jpg mf://*.jpg –vo direct3d, -ao dsound-sub-fuzziness 1 -loop 100
to play jpg file in mplayer in fullscreen mode. I did't test on linux but i think
mplayer -fs –mf fps=1:type=gif *.gif mf://*.jpg -ao dsound-sub-fuzziness 1 -loop 100
should work for you too.
I video DJ using the RPi. Making mplayer full-screen is often harder than it should be. The switch to make mplayer full-screen is -fs. The problem is that many video outputs (-vo) do not support full-screen. If the -vo does not support -fs, I often get around this by using the RCA connection instead of the HDMI on a screen that does not display the entire frame. Try mplayer -fs file.gif and report back. Which -vo are you using?

"batch" files in bash

I want to make a "batch" file so to say for some bash commands (convert.sh). I think it would be best to describe the situation. i have a $#!^ ton of mp4 videos that i want converted into mp3's. it would take me an unreasonable amount of time to convert them using ffmpeg -i /root/name\ of\ video.mp4 /name\ of\ video.mp3 for every single video. not to mention the fact that all the file names are long and complicated so typos are a possibility. so i want to know how to make a shell script (for bash) that will take every file with the extension .mp4 and convert it to a .mp3 with the same name one by one. as in it converts one then when it done it moves on to the next one. im using a lightweight version of linux so any 3rd part soft probably wont work so i need to use ffmpeg...
many thanks in advance for any assistance you can provide
PS: i cant seem to get the formatting sytax on the website to work right so if somone can format this for me and maybe post a link to a manual on how it works that would be much appreciated =)
PPS: i understand that questions about using the ffmpeg command should be asked on superuser however since i dont so much have any questions about the specific command and this relates more to scripting a bash file i figure this is the right place
A bash for loop should do it for you in no time:
SRC_DIR=/root
DST_DIR=/somewhereelse
for FILE in ${SRC_DIR}/*.mp4
do
ffmpeg -i "${FILE}" "${DST_DIR}/$(basename \"${FILE}\" .mp4).mp3"
done
Sorry - I don't know the ffmpeg command line options, so I just copied exactly what's in your post.
1) use find:
find . -name \*.mp4 | xargs ./my_recode_script.sh
2) my_recode_script.sh - see this question
so you can easily change the extension for output file name
the rest is trivial scripting job:
ffmpeg -i $name $new_name # in my_recode_script.sh after changing extension
this is enough for one-time script, if you want something reusable, wrap it with yet another script which receive path to dir, extensions from which to which to recode and call other parts :)

Resources