Issue
I am trying to package some videos on an ubuntu-ec2 machine using shaka packager and following href="https://shaka-project.github.io/shaka-packager/html/tutorials/tutorials.html" rel="nofollow noreferrer">official tutorial.
So I have a list of multi resolution files i.e. original=x.mp4
, converted are x_480p.mp4, x_360p.mp4
and so on. My lowest resolution is 360p.
My bash script automatically detects the height and converts lower than that automatically. Using ffmpeg it's done nicely. Now the problem is, I need to automatically package the files in converted
directory (all of them) using shaka.
If I run the script in a single line it works.
sudo packager in=dpnd_comp.mp4,stream=video,out=test/video.mp4 in=dpnd_comp.mp4,stream=audio,out=test/audio.mp4
For automatic process I am saving the paths in the vairable inputs
. when I run this using variable, it just processes the last video, here 360p
only.
This is the part -
# using a for loop here
inputs="$inputs in="$output_path"/"$content_id"_"$height"p.mp4,stream=video,output="$packaged_out"/"$content_id"_"$height"p.mp4 "
done
echo "$inputs"
sudo packager "$inputs"
Note, `echo "$inputs" returns this
in=../bin/converted/0001_720p.mp4,stream=video,output=../bin/packaged/0001_720p.mp4 in=../bin/converted/0001_480p.mp4,stream=video,output=../bin/packaged/0001_480p.mp4 in=../bin/converted/0001_360p.mp4,stream=video,output=../bin/packaged/0001_360p.mp4
Any kind of help would be highly appreciated. If anyone ever worked with shaka and made the process automatic, please help.
Edit: Need to add more arguments after the inputs like this -
sudo packager "$inputs" \
--enable_widevine_encryption \
--key_server_url "$key_server" \
--content_id "$content_id" \
--signer "$signer_uname" \
--aes_signing_key "$signing_key" \
--aes_signing_iv "$signing_iv" \
--mpd_output "$packaged_out"/"$content_id".mpd \
--hls_master_playlist_output "$packaged_out"/"$content_id".m3u8"
Solution
Ok I solved this problem (workaround) by running bash commands from python.
cmd_prefix = 'sudo packager..'
cmd_postfix = '--mpd_output "${packaged_out}/${content_id}.mpd" --hls_master_playlist_output "${packaged_out}/${content_id}.m3u8"
for inp in inputs
cmd_prefix += inp
drm_command = cmd_perfix + cmd_postfix
drm_processor_response = Popen(f"({drm_command})", stderr=PIPE, stdout=PIPE, shell=True)
output, errors = drm_processor_response.communicate()
log_update([drm_processor_response.returncode, errors.decode("utf-8"), output.decode("utf-8")])
This worked and with python I have more control.
Answered By - ashraf minhaj Answer Checked By - Dawn Plyler (WPSolving Volunteer)