Get duration of encrypted video file - linux

When using the commands:
ffmpeg -i filename 2>&1 | grep Duration
ffprobe filename -show_format -hide_banner
The duration and bit rate appears as N/A but the rest of the format is correct, I believe this is because the file is encrypted using Lynk. I am wondering if there is away around this issue to get the duration even with the file being encrypted?
And this is program related as I use this command in a php script.
Thanks
Here is the log

Related

FFMPEG action on events

iam trying to make action on events in FFMPEG.
For example: ffmpeg -i http://domain/index.m3u8 -c copy -f segment -strftime 1 -segment_time 10 %Y-%m-%d-%H-%M-%S.mp4
FFMPEG take live stream, cut by slices and create files. I want to run a script do_with_file.sh after every slice created, without ffmpeg pausing.
Is there any option in ffmpeg to make it?
Ofcource, i can take stdout from ffmpeg and looking for "segment" text:
ffmpeg ....mp4 | grep 'segment #' | do_with_file.sh
First of all, info line about "segment" showed in stdout, before file was created.
It is not working, if i want run ffmpeg in background.
And in my mind, it is not geek way :)
P.S. English is not my native language, sorry for mistakes.
You can ask ffmpeg to tell you when a segment is finished recording:
-loglevel verbose
With this option you'll get the event you're looking for:
[segment # 0x0f0f0f0f0f0f] segment:'filename.ext' count:N ended
But, if you're prefer a "geek" way, you may try inotifywait:
while segment=$(inotifywait --quiet --event close_write --format %w%f path/to/dir); do
do_with_file $segment
done

How to record microphone to mp3 in Termux on Android?

I'm interested to try out Termux command line on Android to record microphone audio to mp3. I've tried running different commands but without much effect. Can anyone pinpoint correct example command to start recording of the microphone, to mp3, at a default location, for example downloads folder? (This is on Android Oreo)
termux-microphone-record
-d Start recording w/ defaults
-f Start recording to specific file
-l Start recording w/ specified limit (in seconds, unlimited for 0)
-e Start recording w/ specified encoder (aac, amr_wb, amr_nb)
-b Start recording w/ specified bitrate (in kbps)
-r Start recording w/ specified sampling rate (in Hz)
-c Start recording w/ specified channel count (1, 2, ...)
-i Get info about current recording
-q Quits recording
from https://wiki.termux.com/wiki/Termux-microphone-record
Termux does not (yet) appear to support recording directly to mp3 format. To get an mp3, you'll need to convert your recording using ffmpeg.
AWR Wide format has good quality for speech recording.
# Begin recording
termux-microphone-record -e awr_wide -f filename.amr
# Stop recording
termux-microphone-record -q
# Convert to mp3
ffmpeg -i filename.amr filename.mp3
The Below command will record for 10 sec and save your file.mp3 in your termux Home directory.
termux-microphone-record -d -f filename.mp3 -l 10
You need to install 1. the app for Android Termux.Api (i did from F-droid) and 2. the linux package (pkg install) 3. i had to give permission to microphone for termux.Api
after it records and stops automatically with -l.

How to find if the videos have sound in it?

I've a some hundreds of video files in a folder structure. All of them have video and audio streams, but some of them don't have any sound, despite having an audio stream. Is there a way to find out those files without having to resort to opening each file individually.
Most ways I know only check if there is an audio stream.
Thanks.
You can run the following in batch mode:
ffmpeg -hide_banner -i file.mp4 -af volumedetect -vn -f null - 2>&1 | grep mean_volume
The output for each file will be of the form
[Parsed_volumedetect_0 # 0000000002b1e800] mean_volume: -17.2 dB
Perfect digital silence will have a value of -91 dB, but anything below, say, -40 dB is probably just tape noise. Test and verify a few inputs manually and set a value.

Set up basic Batch or Node.JS prompts for FFMPEG?

I have some game clips from Nvidia shadow play that I like to casually shorten and / or turn them into webms or keep them as mp4s. I use the same ffmpeg line for them. I do slightly change the line because of the input file, start time, and output file.
How could I set up something like a batch file (I was thinking maybe node as well) where it just asks for the input file, start time, and output file?
The current ffmpeg command line I use is like this:
ffmpeg -i desktop.mp4 -ss 00:01:50 -b 900000 -vf scale=640:trunc(ow/a/2)*2 output.webm
You can prompt for user input using the following pattern:
SET /P FILENAME=Enter Filename:
ECHO USER ENTERED %FILENAME%
So with your code you'd setup your 3 variables then use:
ffmpeg -i "%INFILE%" -ss %STARTTIME% -b 900000 -vf scale=640:trunc(ow/a/2)*2 "%OUTFILE%"

restarting ffmpeg upon stop/disconnection

I'm recording a long audio m3u8 stream with ffmpeg (with -t to limit the time).
the problem is the stream resets its connection quite often.
how do I make ffmpeg restart upon hangs?
I was thinking of running of such a hack:
timeout <time> while [[ 1 ]]; do ffmpeg -i <mystream> <outfile.mp3>
but it would override the same file
any suggestions?
You should be able to concat mp3. Tell ffmpeg to write to stdout and redirect it to a file.
timeout 60 while [[ 1 ]]; do ffmpeg -i mystream - >> outfile.mp3
as it usually happens, a more careful reading of the man page revealed the solution.
I also learned that now it's better to use avconv over ffmpeg for its better support of hls.
once I marked the stream as an m3u8 one (actually it's called hls)
ffmpeg hls+http://<stream url> -t <timeout> <output file.mp3>
happy converting everyone

Resources